/* ============================================
   CALPADS CCI Data Audit Tool - Styles
   ============================================
   Shared SBCSS theme (colors, header, footer, container, typography,
   buttons) lives in /css/sbcss-tool.css. This file only covers audit-
   tool-specific styles (tables, drop zones, audit cards, etc.).

   The audit intentionally widens .container to full viewport below so
   data tables use all available space; see that rule's comment. */

/* ---- Main Container ---- */
.container {
    /* No max-width cap: the audit is a data-dense tool, so on wide
       monitors we let tables use the full viewport width (minus a bit
       of edge padding so content doesn't touch the window edge). */
    max-width: none;
    width: 100%;            /* explicit fill so child content can't resize us */
    margin: 0 auto;
    padding: 20px 32px 40px;
    flex: 1;
    min-width: 0;           /* flex children need min-width: 0 to respect width */
}

.audit-section {
    /* Explicit width lock so expanding a section can't make the card any
       wider than a collapsed one, regardless of the content inside it. */
    width: 100%;
    min-width: 0;
}

.section-body {
    /* Prevent any runaway-wide child (e.g. a data table with lots of
       columns) from stretching the section card. Internal tables use
       their own .audit-table-wrapper { overflow-x: auto } to scroll. */
    min-width: 0;
    max-width: 100%;
}

/* ---- Upload Section ---- */
.upload-section {
    background: white;
    border-radius: 10px;
    padding: 24px;
    text-align: center;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    margin-bottom: 24px;
}

/* Upload row — caps the two drop-zones so they don't stretch across the
   full viewport on wide monitors (the parent .container is uncapped on
   purpose for data tables; the upload step doesn't benefit from that
   width). Each column takes 50% up to 420px, then wraps and fills width
   on narrower screens. */
.upload-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 880px;
    margin: 0 auto;
}
.upload-col {
    flex: 1 1 280px;
    max-width: 420px;
    min-width: 0;
}

.upload-section h2 {
    color: #026AB0;
    margin: 0 0 6px;
    font-size: 1.1rem;
    font-weight: 600;
}

.upload-section .subtitle {
    color: #666;
    margin: 0 0 24px;
    font-size: 0.95rem;
}

.drop-zone {
    border: 2px dashed #80B4D7;
    border-radius: 8px;
    padding: 20px 16px;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
    position: relative;
    height: 240px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
}

.drop-zone:hover,
.drop-zone.drag-over {
    background-color: #e8f2fa;
    border-color: #026AB0;
}

.drop-zone .drop-icon {
    font-size: 1.5rem;
    margin-bottom: 6px;
    display: block;
    color: #80B4D7;
}

.drop-zone p {
    margin: 0 0 3px;
    font-size: 0.9rem;
    color: #555;
}

.drop-zone .browse-line {
    margin-top: auto;
}

.drop-zone .browse-link {
    color: #026AB0;
    font-weight: 600;
    text-decoration: underline;
    cursor: pointer;
}

.drop-zone .file-hint {
    font-size: 0.82rem;
    color: #999;
    margin-top: 5px;
}

#file-input,
#file-input-319 {
    display: none;
}

.file-info {
    margin-top: 8px;
    font-size: 0.82rem;
    color: #026AB0;
    font-weight: 500;
    display: none;
    max-width: 100%;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.file-info.visible {
    display: block;
}

/* ---- Toolbar (filter, print) ---- */
.toolbar {
    display: none;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
    background: white;
    padding: 16px 20px;
    border-radius: 10px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

.toolbar.visible {
    display: flex;
}

.toolbar label {
    font-weight: 600;
    font-size: 0.9rem;
    color: #333;
    margin-right: 8px;
}

.toolbar select {
    padding: 8px 14px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    min-width: 250px;
    background: white;
}

.toolbar-actions {
    display: flex;
    gap: 10px;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    font-size: 0.88rem;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    transition: background-color 0.2s;
}

.btn-primary {
    background-color: #026AB0;
    color: white;
}

.btn-primary:hover {
    background-color: #015a96;
}

.btn-accent {
    background-color: #FFBA2D;
    color: #026AB0;
}

.btn-accent:hover {
    background-color: #f0ad1e;
}

/* ---- Report Header ---- */
.report-header {
    display: none;
    background: white;
    border-left: 6px solid #026AB0;
    border-radius: 10px;
    padding: 24px 28px;
    margin-bottom: 24px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

.report-header.visible {
    display: block;
}

.report-header h2 {
    margin: 0 0 14px;
    color: #026AB0;
    font-size: 1.3rem;
}

.report-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 32px;
}

.report-meta-item {
    display: flex;
    flex-direction: column;
}

.report-meta-item .meta-label {
    font-size: 0.78rem;
    text-transform: uppercase;
    font-weight: 600;
    color: #999;
    letter-spacing: 0.04em;
}

.report-meta-item .meta-value {
    font-size: 0.95rem;
    font-weight: 500;
    color: #333;
    margin-top: 2px;
}

/* ---- Summary Cards ---- */
.summary-row {
    display: none;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.summary-row.visible {
    display: flex;
}

.summary-card {
    flex: 1;
    min-width: 140px;
    background: white;
    border-radius: 10px;
    padding: 20px;
    text-align: center;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

.summary-card .summary-count {
    font-size: 2rem;
    font-weight: 700;
    color: #026AB0;
}

.summary-card .summary-label {
    font-size: 0.82rem;
    color: #666;
    margin-top: 4px;
}

.summary-card.critical .summary-count {
    color: #c0392b;
}

/* ---- Audit Sections ---- */
.audit-section {
    background: white;
    border-radius: 10px;
    margin-bottom: 16px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    /* Note: no overflow: hidden — that would clip the sticky
       .section-collapse-rail-label inside .section-body. The header and
       body paint their own rounded corners so nothing leaks past. */
}

.section-header {
    border-radius: 10px 10px 0 0;
}

.section-header:not(.open) {
    border-radius: 10px;
}

.section-header {
    display: flex;
    align-items: center;
    padding: 18px 24px;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.15s;
    gap: 12px;
}

.section-header:hover {
    background-color: #f8fbfe;
}

.section-toggle {
    font-size: 0.8rem;
    transition: transform 0.25s;
    color: #999;
    flex-shrink: 0;
    width: 20px;
    text-align: center;
}

.section-header.open .section-toggle {
    transform: rotate(90deg);
}

.section-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: #333;
    flex: 1;
}

.section-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    padding: 0 10px;
    border-radius: 14px;
    font-size: 0.82rem;
    font-weight: 700;
    color: white;
    background-color: #026AB0;
    flex-shrink: 0;
}

.section-badge.critical {
    background-color: #c0392b;
}

.section-badge.warning {
    background-color: #e67e22;
}

.section-badge.info {
    background-color: #2ecc71;
}

.section-badge.zero {
    background-color: #bbb;
}

.section-body {
    display: none;
    padding: 16px 24px 24px;
    border-top: 1px solid #eef2f6;
    /* Two-column grid: a sticky "Collapse" rail on the left and the
       actual section content on the right. The rail stays visible
       within the viewport as the user scrolls through long sections. */
    grid-template-columns: 44px 1fr;
    gap: 16px;
}

.section-header.open + .section-body {
    display: grid;
}

.section-body-content {
    min-width: 0; /* allow the content column to shrink below its intrinsic width */
}

/* Vertical "Collapse section" rail on the left side of every expanded
   section. The <button> itself fills the full height of the section so
   clicking anywhere down the side collapses the section. Inside, a
   sticky label stays visible at the top of the viewport while the user
   scrolls through long sections. */
.section-collapse-rail {
    /* Fills the full height of the grid cell (= full length of the
       expanded section) so the click target runs the whole section. */
    height: 100%;
    min-height: 180px;
    width: 100%;
    padding: 0;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;

    background: linear-gradient(to right, #e8f0f7, #f5f9fc);
    border: 1px solid #dde6ef;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
}

.section-collapse-rail:hover,
.section-collapse-rail:focus {
    background: #d7e6f3;
    border-color: #026AB0;
}

/* The sticky inner label that actually shows "◀ Collapse section".
   Sticks 16px from the top of the viewport so it's always visible
   while the rail is on screen. */
.section-collapse-rail-label {
    position: sticky;
    top: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 16px 4px;

    color: #026AB0;
    font-weight: 600;
    font-size: 0.72rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.section-collapse-rail:hover .section-collapse-rail-label,
.section-collapse-rail:focus .section-collapse-rail-label {
    color: #01508A;
}

.section-collapse-rail-icon {
    font-size: 1rem;
}

.section-collapse-rail-text {
    /* Rotate the text so it reads bottom-to-top along the vertical rail. */
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    white-space: nowrap;
}

/* On narrow screens the grid collapses to a single column and the rail
   becomes a regular horizontal button above the content. */
@media (max-width: 700px) {
    .section-header.open + .section-body {
        grid-template-columns: 1fr;
    }
    .section-collapse-rail {
        height: auto;
        min-height: auto;
        padding: 0;
        flex-direction: row;
    }
    .section-collapse-rail-label {
        position: static;
        flex-direction: row;
        padding: 8px 14px;
    }
    .section-collapse-rail-text {
        writing-mode: horizontal-tb;
        transform: none;
    }
}

.section-description {
    font-size: 0.9rem;
    color: #666;
    margin: 16px 0 16px;
    line-height: 1.55;
}

/* ---- Data Tables ---- */
.audit-table-wrapper {
    overflow-x: auto;
    margin-top: 12px;
}

.audit-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    /* Fixed layout + <colgroup> widths (from JS COL_WIDTHS) so the same
       named column (e.g. "State Code") lines up at the same horizontal
       position across every audit section. */
    table-layout: fixed;
}

.audit-table thead th {
    background-color: #f0f5fa;
    text-align: left;
    padding: 10px 14px;
    font-weight: 600;
    color: #555;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-bottom: 2px solid #dde6ef;
    /* Allow long header titles to wrap onto multiple lines instead of
       truncating with an ellipsis — users need to read the full title. */
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    vertical-align: bottom;
}

.audit-table tbody td {
    padding: 9px 14px;
    border-bottom: 1px solid #eef2f6;
    color: #444;
    vertical-align: top;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.audit-table tbody tr:last-child td {
    border-bottom: none;
}

.audit-table tbody tr:hover {
    background-color: #f9fbfd;
}

.audit-table .code-cell {
    font-family: 'Consolas', 'Courier New', monospace;
    font-weight: 500;
    /* Dark navy (not link-blue) so monospace codes don't read as hyperlinks.
       Link-blue is reserved for actual <a> elements per WCAG 1.4.1. */
    color: #1a1a2e;
}

.audit-table .recommendation {
    color: #c0392b;
    font-weight: 500;
    font-size: 0.82rem;
}

/* School sub-group header in tables */
.school-group-header {
    background-color: #f7fafd;
    font-weight: 600;
    color: #026AB0;
    padding: 10px 14px;
    font-size: 0.88rem;
    border-bottom: 1px solid #dde6ef;
    margin-top: 16px;
}

/* ---- Body link style ---- */
/* Reused on the help/info links. Underlined at rest so that color alone
   isn't the only signal the text is interactive (WCAG 1.4.1 / 2.4.4). */
.body-link {
    color: #026AB0;
    font-weight: 500;
    text-decoration: underline;
}

.body-link:hover,
.body-link:focus {
    color: #01508A;
}

/* Footer row at the bottom of each expanded audit section — holds the
   "Learn more about this section" help link (right-aligned). Collapse
   is handled by the sticky .section-collapse-rail on the left. */
.section-footer {
    text-align: right;
    margin-top: 12px;
    padding-top: 8px;
    border-top: 1px solid #eef2f6;
    font-size: 0.78rem;
}

/* ---- Mismatch detail rows (same-school / cross-school cards) ---- */
/* A CSS grid with fixed column widths so State Code, Local IDs,
   Schools, and Grade Level line up vertically across every row. */
.mismatch-detail-row {
    display: grid;
    grid-template-columns: 180px 160px 1fr 90px;
    gap: 16px;
    padding: 10px 14px;
    border-top: 1px solid #eef2f6;
    align-items: start;
}

.mismatch-detail-cell {
    min-width: 0; /* allow text to wrap instead of forcing column to expand */
}

.mismatch-detail-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #888;
    margin-bottom: 2px;
}

.mismatch-detail-code {
    font-family: 'Consolas', 'Courier New', monospace;
    font-weight: 700;
    font-size: 1.1rem;
    /* Dark navy (not link-blue) so the state-code value doesn't read as a
       hyperlink. Link-blue is reserved for actual <a> elements per WCAG. */
    color: #1a1a2e;
    line-height: 1.3;
}

.mismatch-detail-sub {
    font-size: 0.85rem;
    color: #333;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.mismatch-detail-value {
    font-size: 0.85rem;
    color: #555;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.mismatch-detail-pill {
    font-size: 0.85rem;
    padding: 2px 8px;
    background: #eef2f6;
    border-radius: 3px;
    color: #555;
    display: inline-block;
}

@media (max-width: 700px) {
    .mismatch-detail-row {
        grid-template-columns: 1fr 1fr;
    }
}

.school-group-header:first-child {
    margin-top: 0;
}

/* ---- Pathway groups ---- */
.pathway-group {
    margin-bottom: 20px;
}

.pathway-group-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: #026AB0;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 2px solid #e8f0f7;
}

/* ---- No findings message ---- */
.no-findings {
    text-align: center;
    padding: 24px;
    color: #999;
    font-size: 0.9rem;
}

/* ---- Footer ---- */
footer {
    background-color: #026AB0;
    color: white;
    padding: 4px 16px;
    text-align: center;
    font-size: 0.7rem;
    margin-top: auto;
}

footer p {
    margin: 0;
}

/* ---- Loading spinner ---- */
.loading {
    display: none;
    text-align: center;
    padding: 40px;
}

.loading.visible {
    display: block;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e8f0f7;
    border-top-color: #026AB0;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ---- Print Styles ---- */
@media print {
    body {
        background: white;
        font-size: 9pt;
    }

    header {
        padding: 12px 16px;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    header h1 {
        font-size: 1.1rem;
    }

    header p {
        font-size: 0.8rem;
    }

    .header-logo {
        max-height: 36px;
    }

    .upload-section,
    .toolbar-actions,
    .toolbar,
    footer {
        display: none !important;
    }

    .container {
        padding: 0;
        max-width: 100%;
    }

    .report-header {
        display: block !important;
        box-shadow: none;
        border: 1px solid #ccc;
        padding: 12px 16px;
        page-break-after: avoid;
    }

    .report-header h2 {
        font-size: 1rem;
        margin-bottom: 8px;
    }

    .report-meta {
        gap: 16px;
    }

    .report-meta-item .meta-label {
        font-size: 0.65rem;
    }

    .report-meta-item .meta-value {
        font-size: 0.8rem;
    }

    .summary-row {
        display: flex !important;
        gap: 6px;
    }

    .summary-card {
        box-shadow: none;
        border: 1px solid #ccc;
        padding: 8px 10px;
    }

    .summary-card .summary-count {
        font-size: 1.2rem;
    }

    .summary-card .summary-label {
        font-size: 0.7rem;
    }

    .audit-section {
        box-shadow: none;
        border: 1px solid #ccc;
        margin-bottom: 8px;
        page-break-inside: auto;
    }

    .section-header {
        padding: 8px 12px;
        cursor: default;
    }

    .section-title {
        font-size: 0.85rem;
    }

    .section-badge {
        min-width: 20px;
        height: 20px;
        font-size: 0.7rem;
        padding: 0 5px;
    }

    .section-body {
        display: block !important;
        padding: 8px 12px;
    }

    .section-description {
        font-size: 0.75rem;
        margin-bottom: 6px;
    }

    .section-toggle {
        transform: rotate(90deg);
    }

    .audit-table {
        font-size: 0.75rem;
    }

    .audit-table th,
    .audit-table td {
        padding: 4px 6px;
    }

    .audit-table thead th {
        background-color: #f0f5fa !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .audit-section * {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .pathway-header {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .pathway-warning {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    header .header-inner {
        text-align: left;
    }

    .report-meta {
        flex-direction: column;
        gap: 12px;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar select {
        min-width: 100%;
    }

    .summary-row {
        flex-direction: column;
    }
}

/* ---- "When to Pull" Guidance Panel ---- */
.pull-guide {
    text-align: left;
    background-color: #f0f6fb;
    border: 1px solid #cfe0ef;
    border-left: 4px solid #026AB0;
    border-radius: 8px;
    margin: 16px 0 20px;
    padding: 0;
    overflow: hidden;
}

.pull-guide > summary {
    cursor: pointer;
    padding: 14px 18px;
    font-weight: 600;
    color: #01508A;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    user-select: none;
    background-color: #e8f1f9;
    transition: background-color 0.15s ease;
}

.pull-guide > summary::-webkit-details-marker {
    display: none;
}

.pull-guide > summary:hover {
    background-color: #dcebf7;
}

.pull-guide-title {
    font-size: 0.98rem;
}

.pull-guide-title::before {
    content: "\2139\FE0F\00a0\00a0";
}

.pull-guide-hint {
    font-size: 0.8rem;
    font-weight: 400;
    color: #555;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.pull-guide-hint::after {
    content: "\25BE";
    display: inline-block;
    font-size: 0.95rem;
    line-height: 1;
    transition: transform 0.2s ease;
}

.pull-guide[open] > summary .pull-guide-hint::after {
    transform: rotate(180deg);
}

.pull-guide-body {
    padding: 16px 20px 20px;
    font-size: 0.92rem;
    color: #333;
    background-color: white;
    border-top: 1px solid #cfe0ef;
}

.pull-guide-body h3,
.pull-guide-body h4 {
    color: #01508A;
    font-size: 0.98rem;
    margin: 18px 0 8px;
    padding-bottom: 4px;
    border-bottom: 2px solid #FFBA2D;
    display: inline-block;
}

.pull-guide-body p {
    margin: 8px 0;
}

.pull-guide-body ul,
.pull-guide-body ol {
    margin: 8px 0 10px;
    padding-left: 24px;
}

.pull-guide-body li {
    margin-bottom: 4px;
}

.pull-guide-body ul ul {
    margin: 4px 0;
}

.pull-guide-subheading {
    font-weight: 600;
    color: #01508A;
    margin-top: 12px !important;
    margin-bottom: 4px !important;
}

.pull-guide-callout {
    background-color: #fff8e1;
    border-left: 4px solid #FFBA2D;
    padding: 10px 14px;
    border-radius: 4px;
    margin: 12px 0;
}

.pull-guide-callout-title {
    font-weight: 700;
    color: #8a6000;
    margin: 0 0 4px !important;
    font-size: 0.95rem;
}

.pull-guide-callout p:last-child {
    margin-bottom: 0;
}

.pull-guide-table-wrapper {
    overflow-x: auto;
    margin: 10px 0 6px;
}

.pull-guide-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
    background-color: white;
    border: 1px solid #cfe0ef;
}

.pull-guide-table thead {
    background-color: #026AB0;
    color: white;
}

.pull-guide-table th,
.pull-guide-table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid #e5edf5;
    vertical-align: top;
}

.pull-guide-table th {
    font-weight: 600;
    font-size: 0.85rem;
    border-bottom: none;
}

.pull-guide-table tbody tr:nth-child(even) {
    background-color: #f7fbfe;
}

.pull-guide-table tbody tr:last-child td {
    border-bottom: none;
}

.pull-guide-note {
    font-size: 0.88rem;
    color: #555;
    font-style: italic;
    background-color: #f7fbfe;
    padding: 8px 12px;
    border-radius: 4px;
    margin: 6px 0 0;
}

.pull-guide-source {
    margin-top: 18px !important;
    padding-top: 12px;
    border-top: 1px solid #e5edf5;
    font-size: 0.85rem;
    color: #555;
}

.pull-guide-source a {
    color: #026AB0;
    font-weight: 500;
    text-decoration: underline;
}

.pull-guide-source a:hover {
    color: #01508A;
}

/* State Course Code Reference table styles moved to
   /css/state-course-codes.css so /audit/info.html and the standalone
   /state-course-codes/ page share them. */

.code-ref-expired {
    display: inline-block;
    margin-left: 8px;
    padding: 1px 7px;
    background: #b03030;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: 3px;
    vertical-align: middle;
    white-space: nowrap;
}
