/* =========================================================
   G2B 교복 입찰 분석 Viewer
   정리본
   - PC: DIV + CSS Grid
   - 모바일: 카드 UI
   - 상세: DIV + CSS Grid
   - 중복/구형 table CSS 제거
   - 상세 펼침 성능 최적화 유지
   ========================================================= */


/* =========================================================
   1. 기본
   ========================================================= */

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;

    font-family:
        Arial,
        "Malgun Gothic",
        sans-serif;

    background: #f5f6f8;
    color: #111;
}

.container {
    width: 95%;
    margin: 30px auto;
}


/* =========================================================
   2. 제목 / 교복·체육복 토글
   ========================================================= */

.page-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 20px;

    margin-bottom: 25px;
}

.page-title-row h1 {
    margin: 0;

    font-size: 28px;
}

.category-toggle {
    display: flex;
    gap: 6px;
}

.category-button {
    min-width: 58px;
    height: 28px;

    padding: 0 12px;

    border: 1px solid #444;
    border-radius: 5px;

    background: #f5f5f5;
    color: #333;

    font-size: 12px;
    font-weight: 700;

    cursor: pointer;

    transition:
        background-color 0.15s,
        color 0.15s,
        border-color 0.15s;
}

.category-button:hover {
    border-color: #000;
}

.category-button.active {
    border-color: #222;

    background: #222;
    color: #fff;
}

.category-button.active:hover {
    border-color: #000;
    background: #000;
}


/* =========================================================
   3. 필터
   ========================================================= */

.filter-box {
    display: flex;
    align-items: center;
    flex-wrap: wrap;

    gap: 20px;

    margin-bottom: 15px;
    padding: 15px;

    border: 1px solid #ddd;

    background: #fff;
}

.filter-item {
    display: flex;
    align-items: center;

    gap: 8px;
}

.filter-item label {
    font-weight: 700;
}

.filter-item select {
    padding: 6px 10px;

    font-size: 15px;
}

.filter-item select:disabled {
    background: #eee;
    color: #999;
}


/* =========================================================
   4. 차트
   ========================================================= */

.chart-panel {
    margin-top: 15px;
    margin-bottom: 15px;

    padding: 8px 5px 5px;

    border: 1px solid #ddd;

    background: #fff;
}

.chart-scroll {
    width: 100%;

    overflow-x: auto;
    overflow-y: hidden;

    padding-bottom: 2px;
}

.chart-wrap {
    position: relative;

    min-width: 1200px;
    height: 260px;
}

#bidRateChart {
    width: 100% !important;
    height: 100% !important;
}


/* =========================================================
   5. 요약
   ========================================================= */

.summary {
    margin-bottom: 10px;

    font-size: 14px;
}


/* =========================================================
   6. PC 공고 목록
   ========================================================= */

.desktop-notice-list {
    width: 100%;

    overflow-x: auto;

    border: 1px solid #d6d6d6;

    background: #fff;
}

.desktop-notice-grid {
    width: 100%;
    min-width: 1500px;
}


/*
 * 메인 목록 9개 열
 *
 * 공고년도 / 지역 / 학교 / 입찰마감 / 개찰일 /
 * 1위업체 / 1위투찰률 / 기초금액 / 공고명
 */
.notice-grid-header,
.desktop-notice-row {
    display: grid;

    grid-template-columns:
        70px
        195px
        150px
        145px
        145px
        165px
        115px
        120px
        minmax(500px, 1fr);

    align-items: stretch;
}


/* 헤더 */
.notice-grid-header {
    min-height: 36px;

    border-bottom: 1px solid #c8c8c8;

    background: #f0f1f3;

    font-size: 12px;
    font-weight: 700;
}

.notice-grid-header > div {
    display: flex;
    align-items: center;

    min-width: 0;

    padding: 7px 8px;

    white-space: nowrap;
}


/* 공고 한 행 */
.desktop-notice-row {
    min-height: 36px;

    border-bottom: 1px solid #d8d8d8;

    background: #fff;

    cursor: pointer;

    /*
     * 상세를 펼칠 때 아래 수백 개 행의
     * layout / paint 영향을 격리.
     * 이 부분은 성능상 반드시 유지.
     */
    contain: layout paint;
    contain-intrinsic-size: 36px;
}

.desktop-notice-row:last-child {
    border-bottom: 0;
}

.desktop-notice-row:hover {
    background: #f7f9fc;
}

.desktop-notice-row.selected {
    background: #e4f7c8;
}

.desktop-notice-row > .notice-grid-cell {
    display: flex;
    align-items: center;

    min-width: 0;

    padding: 7px 8px;

    font-size: 12px;
    line-height: 1.25;

    white-space: nowrap;

    overflow: hidden;
    text-overflow: ellipsis;
}


/*
 * 중요:
 * 가로 구분선은 각 셀에 주지 않고
 * .desktop-notice-row 자체에만 준다.
 * 그래서 전체 폭의 선이 끊기지 않는다.
 */
.desktop-notice-row > .notice-grid-cell {
    border: 0;
}

.school-name-cell {
    font-weight: 700;
    color: #111;
}

.desktop-notice-row .notice-rate-cell {
    justify-content: center;
}

.desktop-notice-row .notice-title-cell {
    overflow: hidden;
    text-overflow: ellipsis;
}


/* 메인 투찰률 배지 */
.rate-badge {
    display: inline-block;

    min-width: 75px;

    padding: 5px 9px;

    border-radius: 6px;

    font-size: 16px;
    font-weight: 700;

    text-align: center;
}

.desktop-notice-row .rate-badge {
    min-width: 74px;

    padding: 4px 8px;

    font-size: 14px;
}

.rate-black {
    color: #111;
    background: #eee;
}

.rate-navy {
    color: #17365d;
    background: #e1ebf7;
}

.rate-green {
    color: #157a32;
    background: #e0f4e6;
}

.rate-red {
    color: #c62828;
    background: #fde1e1;
}

.opening-status-badge {
    display: inline-block;

    padding: 2px 6px;

    border-radius: 4px;

    background: #fff;
    color: #c62828;

    font-size: 13px;
    font-weight: 700;
}


/*
 * 공고 목록 자체도 별도 layout 영역으로 격리.
 */
#noticeTableBody {
    contain: layout;
}


/* =========================================================
   7. PC 상세 참가업체
   ========================================================= */

.desktop-bid-detail {
    width: 100%;

    overflow-x: auto;

    border-bottom: 1px solid #aeb4ba;

    background: #fff;
}

.bid-detail-box {
    width: 100%;

    margin: 0;
    padding: 0;

    background: #fff;
}

.bid-detail-loading,
.bid-detail-error,
.bid-detail-empty {
    padding: 20px;

    text-align: center;
}


/*
 * 상세 6개 열
 *
 * 순위 / 투찰률 / 업체명 / 대표자 / 사업자번호 / 투찰금액
 *
 * 업체명만 과도하게 넓어지지 않도록
 * 비율을 고정.
 */
.bid-result-grid-box {
    width: 100%;
    min-width: 0;

    background: #fff;
}

.bid-result-grid {
    display: grid;

    grid-template-columns:
        6%
        10%
        32%
        20%
        17%
        15%;

    width: 100%;
}


/* 상세 타이틀 */
.bid-result-grid-header {
    background: #fff;
    color: #111;

    font-weight: 700;

    border-top: 1px solid #d5d5d5;
    border-bottom: 1px solid #c8c8c8;
}


/* 상세 데이터 행 */
.bid-result-grid-row {
    background: #fff;

    border-bottom: 1px solid #d5d5d5;
}

.bid-result-grid-row:last-child {
    border-bottom: 0;
}

.bid-result-grid-row:hover {
    background: #f8fafc;
}


/*
 * 상세 셀
 *
 * 세로선만 셀에 주고,
 * 가로선은 행에만 줌.
 */
.bid-result-grid-cell {
    display: flex;
    align-items: center;
    justify-content: center;

    min-width: 0;
    min-height: 32px;

    padding: 5px 8px;

    border-right: 1px solid #d5d5d5;

    font-size: 12px;
    line-height: 1.2;

    white-space: nowrap;

    overflow: hidden;
    text-overflow: ellipsis;
}

.bid-result-grid-cell:last-child {
    border-right: 0;
}

.bid-result-grid-header .bid-result-grid-cell {
    min-height: 30px;

    font-weight: 700;
}


/* 상세 투찰률 */
.detail-rate-cell {
    width: auto;

    text-align: center;
}

.detail-rate-badge {
    min-width: 0;

    padding: 2px 5px;

    border-radius: 4px;

    font-size: 12px;
    font-weight: 700;
}


/* 상세 투찰금액 */
.detail-bid-amount {
    font-weight: 500;
    text-align: center;
}


/* 상세 부적격 사유 */
.bid-remark {
    display: inline-block;

    padding: 2px 5px;

    border-radius: 4px;

    background: #fff;
    color: #c00020;

    font-size: 12px;
    font-weight: 700;

    white-space: nowrap;
}


/* =========================================================
   8. 모바일 - 촘촘한 리스트형
   ========================================================= */

.mobile-notice-list {
    display: none;
}

@media (max-width: 768px) {

    body {
        font-size: 13px;
    }

    .container {
        width: auto;
        margin: 8px;
    }

    /* 제목 */
    .page-title-row {
        gap: 8px;
        margin-bottom: 10px;
    }

    .page-title-row h1 {
        font-size: 19px;
    }

    .category-toggle {
        gap: 4px;
    }

    .category-button {
        min-width: 48px;
        height: 25px;
        padding: 0 8px;
        border-radius: 4px;
        font-size: 11px;
    }

    /* 필터 */
    .filter-box {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 6px 8px;
        margin-bottom: 8px;
        padding: 8px;
        border-radius: 6px;
    }

    .filter-item {
        display: flex;
        align-items: center;
        min-width: 0;
        gap: 4px;
    }

    .filter-item label {
        width: auto;
        flex-shrink: 0;
        font-size: 11px;
        font-weight: 700;
    }

    .filter-item select {
        flex: 1;
        min-width: 0;
        height: 32px;
        padding: 3px 5px;
        font-size: 12px;
    }

    /* 차트 */
    .chart-panel {
        margin-top: 6px;
        margin-bottom: 8px;
        padding: 5px 3px 3px;
    }

    .chart-scroll {
        width: 100%;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
    }

    .chart-wrap {
        min-width: 0;
        height: 220px;
    }

    /* 요약 */
    .summary {
        margin: 6px 2px;
        font-size: 12px;
    }

    /* PC 목록 숨김 */
    .desktop-notice-list {
        display: none;
    }

    /* 모바일 목록 */
    .mobile-notice-list {
        display: block;
        border-top: 1px solid #d5d8dc;
    }

    /*
     * 큰 카드 대신 촘촘한 리스트형
     */
    .mobile-notice-card {
        margin: 0;
        padding: 8px 6px 7px;

        border: 0;
        border-bottom: 1px solid #d8dadd;
        border-radius: 0;

        background: #fff;
        box-shadow: none;

        cursor: pointer;
    }

    .mobile-notice-card:active {
        background: #f4f7fa;
    }

    .mobile-notice-card.selected {
        background: #e4f7c8;
    }

    /* 1줄: 학교 + 투찰률 */
    .mobile-card-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        min-height: 23px;
    }

    .mobile-school-name {
        flex: 1;
        min-width: 0;

        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;

        color: #111;
        font-size: 15px;
        font-weight: 700;
    }

    .mobile-card-header .rate-badge {
        flex-shrink: 0;
        min-width: 62px;
        padding: 2px 5px;
        border-radius: 5px;
        font-size: 12px;
        line-height: 18px;
    }

    .mobile-card-header .opening-status-badge {
        flex-shrink: 0;
        padding: 1px 4px;
        font-size: 12px;
    }

    /* 2줄: 지역 + 입찰마감 */
    .mobile-list-subline {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        margin-top: 2px;
        min-width: 0;
    }

    .mobile-region {
        flex: 1;
        min-width: 0;
        margin: 0;

        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;

        color: #777;
        font-size: 11px;
    }

    .mobile-bid-deadline {
        flex-shrink: 0;
        color: #333;
        font-size: 11px;
        font-weight: 700;
        white-space: nowrap;
    }

    /* 3줄: 1위 업체 + 기초금액 */
    .mobile-list-bottom {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        margin-top: 3px;
        min-width: 0;
    }

    .mobile-rank1-company {
        flex: 1;
        min-width: 0;

        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;

        color: #333;
        font-size: 11px;
        font-weight: 700;
    }

    .mobile-base-amount {
        flex-shrink: 0;
        color: #555;
        font-size: 11px;
        white-space: nowrap;
    }

    /*
     * 예전 큰 카드 구성은 새 모바일 리스트에서 사용하지 않음
     */
    .mobile-card-grid,
    .mobile-notice-title,
    .mobile-detail-hint {
        display: none;
    }

    /* 모바일 상세 */
    .mobile-bid-detail {
        width: 100%;
        margin: 0 0 4px;

        overflow-x: auto;

        border: 0;
        border-bottom: 1px solid #aeb4ba;
        border-radius: 0;

        background: #fff;

        -webkit-overflow-scrolling: touch;
    }

    .mobile-bid-detail .bid-detail-box {
        width: auto;
        min-width: 620px;
    }

    .bid-result-grid-box {
        min-width: 620px;
    }

    .bid-result-grid {
        grid-template-columns:
            55px
            90px
            165px
            90px
            120px
            120px;
    }

    .bid-result-grid-cell {
        min-height: 30px;
        padding: 5px;
        font-size: 11px;
    }

    .detail-rate-badge {
        font-size: 11px;
    }
}

/* 모바일 3줄 리스트 날짜 스타일 */
@media (max-width: 768px) {
    .mobile-bid-deadline,
    .mobile-opening-date {
        flex-shrink: 0;

        color: #333;

        font-size: 11px;
        font-weight: 400;

        white-space: nowrap;
    }
}


/* =========================================================
   9. 조회구분 / 현재 발주·입찰 목록
   ========================================================= */

.view-type-select {
    min-width: 118px;
    font-weight: 700;
}

.current-summary {
    display: none;
    margin: 10px 2px;
    font-size: 14px;
}

.current-summary strong {
    font-size: 16px;
}

.notice-grid-header.mode-plan,
.desktop-notice-row.mode-plan {
    grid-template-columns:
        190px
        165px
        105px
        110px
        145px
        minmax(480px, 1fr);
}

.notice-grid-header.mode-bid,
.desktop-notice-row.mode-bid {
    grid-template-columns:
        190px
        165px
        105px
        145px
        145px
        100px
        minmax(440px, 1fr);
}

.desktop-notice-grid.mode-plan {
    min-width: 1180px;
}

.desktop-notice-grid.mode-bid {
    min-width: 1290px;
}

.current-row {
    cursor: default;
}

.external-link-row {
    cursor: pointer;
}

.external-link-row:hover {
    background: #f0f6ff;
}

.current-type-badge,
.current-status-badge {
    display: inline-block;
    flex-shrink: 0;

    padding: 2px 7px;

    border: 1px solid #c7ccd3;
    border-radius: 12px;

    background: #f5f7fa;
    color: #333;

    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}

.current-status-badge {
    border-color: #9bbce8;
    background: #edf5ff;
    color: #1d5f9f;
}

.current-empty {
    width: 100%;
    padding: 32px 16px;

    border-bottom: 1px solid #ddd;

    background: #fff;
    color: #777;

    font-size: 13px;
    text-align: center;
}

.mobile-current-title {
    margin-top: 4px;

    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;

    color: #333;
    font-size: 11px;
}

.mobile-current-empty {
    display: none;
}


@media (max-width: 768px) {

    .view-type-select {
        min-width: 0;
        width: 100%;
    }

    .current-summary {
        margin: 6px 2px;
        font-size: 12px;
    }

    .current-summary strong {
        font-size: 13px;
    }

    .current-type-badge,
    .current-status-badge {
        padding: 1px 6px;
        font-size: 10px;
    }

    .mobile-current-title {
        font-size: 11px;
    }

    .mobile-current-empty {
        display: block;
    }
}


/* =========================================================
   10. 조회구분 버튼형 UI
   ========================================================= */

.view-type-filter {
    gap: 10px;
}

.view-type-toggle {
    display: flex;
    align-items: center;
    gap: 5px;
}

.view-type-button {
    height: 32px;
    min-width: 82px;

    padding: 0 13px;

    border: 1px solid #b9bec5;
    border-radius: 5px;

    background: #fff;
    color: #333;

    font-size: 13px;
    font-weight: 700;

    cursor: pointer;

    transition:
        background-color 0.15s,
        border-color 0.15s,
        color 0.15s;
}

.view-type-button:hover {
    border-color: #6e7f91;
    background: #f5f8fb;
}

.view-type-button.active {
    border-color: #2584c6;
    background: #2584c6;
    color: #fff;
}

.view-type-button.active:hover {
    border-color: #1d72ad;
    background: #1d72ad;
}

.view-type-select-hidden {
    display: none !important;
}



.bid-result-grid {
    display: grid;

    grid-template-columns:
        65px
        110px
        130px
        minmax(360px, 1fr)
        minmax(180px, 0.65fr)
        135px;

    width: 100%;
}

@media (max-width: 768px) {

    .view-type-filter {
        grid-column: 1 / -1;
        width: 100%;
    }

    .view-type-toggle {
        flex: 1;
        min-width: 0;
    }

    .view-type-button {
        flex: 1;
        min-width: 0;
        height: 32px;
        padding: 0 5px;
        font-size: 11px;
    }
    
    .bid-result-grid {
        grid-template-columns:
            55px
            90px
            120px
            165px
            90px
            120px;
    }
}