/* Library Collection Analyzer — Styles */
:root {
    --primary: #2c5282;
    --primary-light: #ebf4ff;
    --primary-dark: #1a365d;
    --success: #276749;
    --success-bg: #f0fff4;
    --warning: #975a16;
    --warning-bg: #fffff0;
    --danger: #9b2c2c;
    --danger-bg: #fff5f5;
    --gray-50: #f7fafc;
    --gray-100: #edf2f7;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e0;
    --gray-600: #718096;
    --gray-700: #4a5568;
    --gray-800: #2d3748;
    --gray-900: #1a202c;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--gray-800);
    background: var(--gray-50);
    line-height: 1.6;
}

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 240px;
    background: var(--primary-dark);
    color: white;
    padding: 0;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h1 {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.sidebar-header .subtitle {
    font-size: 11px;
    opacity: 0.7;
    margin-top: 2px;
}

.sidebar nav {
    padding: 12px 0;
}

.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    font-size: 14px;
    transition: background 0.15s;
}

.sidebar nav a:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}

.sidebar nav a.active {
    background: rgba(255,255,255,0.15);
    color: white;
    font-weight: 500;
    border-left: 3px solid white;
}

.nav-section {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 10px 20px;
    background: none;
    border: none;
    border-top: 1px solid rgba(255,255,255,0.06);
    color: rgba(255,255,255,0.7);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 4px;
}

.nav-section::after {
    content: "\25B8";
    font-size: 10px;
    transition: transform 0.15s;
}

.nav-section.open::after {
    transform: rotate(90deg);
}

.nav-section:hover {
    color: rgba(255,255,255,0.8);
}

.nav-group {
    display: none;
}

.nav-group.open {
    display: block;
}

.nav-group a {
    padding-left: 28px;
    font-size: 13px;
}

.main-content {
    margin-left: 240px;
    flex: 1;
    padding: 32px 40px;
    max-width: 1200px;
}

/* Page header */
.page-header {
    margin-bottom: 28px;
}

.page-header h2 {
    font-size: 24px;
    font-weight: 600;
    color: var(--gray-900);
}

.page-header p {
    color: var(--gray-600);
    margin-top: 4px;
    font-size: 14px;
}

/* Cards */
.card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 20px;
}

.card h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 16px;
}

/* Stat grid */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
}

.stat-card .label {
    font-size: 13px;
    color: var(--gray-600);
}

.stat-card .value {
    font-size: 28px;
    font-weight: 700;
    color: var(--gray-900);
    margin-top: 4px;
}

.stat-card .detail {
    font-size: 12px;
    color: var(--gray-600);
    margin-top: 4px;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

thead th {
    text-align: left;
    padding: 10px 12px;
    font-weight: 600;
    color: var(--gray-700);
    border-bottom: 2px solid var(--gray-200);
    font-size: 13px;
}

tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--gray-100);
    color: var(--gray-700);
}

tbody tr:hover {
    background: var(--gray-50);
}

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 14px;
}

.alert-success { background: var(--success-bg); color: var(--success); }
.alert-error { background: var(--danger-bg); color: var(--danger); }
.alert-warning { background: var(--warning-bg); color: var(--warning); }
.alert-info { background: var(--primary-light); color: var(--primary); }

.dismiss-btn {
    float: right;
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: inherit;
    padding: 0 0.25rem;
    line-height: 1;
    opacity: 0.6;
}
.dismiss-btn:hover { opacity: 1; }

/* Upload form */
.upload-area {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius);
    padding: 48px;
    text-align: center;
    background: white;
    transition: border-color 0.2s;
}

.upload-area:hover {
    border-color: var(--primary);
}

.upload-area input[type="file"] {
    margin: 16px 0;
}

.btn {
    display: inline-block;
    padding: 10px 20px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s;
}

.btn:hover { background: var(--primary-dark); }

.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
}

/* Bar chart (CSS-only) */
.bar-chart {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.bar-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.bar-label {
    width: 180px;
    font-size: 13px;
    color: var(--gray-700);
    text-align: right;
    flex-shrink: 0;
}

.bar-track {
    flex: 1;
    height: 24px;
    background: var(--gray-100);
    border-radius: 4px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
    min-width: 2px;
    transition: width 0.3s ease;
}

.bar-value {
    width: 80px;
    font-size: 13px;
    color: var(--gray-600);
}

/* Gap badges */
.gap-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.gap-badge.high { background: #fef3c7; color: #92400e; }
.gap-badge.medium { background: var(--warning-bg); color: var(--warning); }
.gap-badge.low { background: var(--success-bg); color: var(--success); }

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray-600);
}

.empty-state .icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.empty-state h3 {
    font-size: 18px;
    color: var(--gray-700);
    margin-bottom: 8px;
    text-transform: none;
    letter-spacing: normal;
}

/* Inline form controls */
.inline-form {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.inline-form label {
    font-size: 13px;
    color: var(--gray-600);
}

.inline-form input[type="number"],
.inline-form select {
    padding: 6px 10px;
    border: 1px solid var(--gray-300);
    border-radius: 4px;
    font-size: 13px;
    width: 80px;
}

/* File info */
.file-info {
    font-size: 12px;
    color: rgba(255,255,255,0.7);
    padding: 10px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Column mapping status */
.col-status {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}
.col-status.full { background: #48bb78; }
.col-status.partial { background: #ecc94b; }
.col-status.empty { background: #e2e8f0; }

.status-label {
    font-size: 0.75rem;
    margin-left: 0.25rem;
    margin-right: 0.5rem;
}
.status-label.mapped { color: #276749; }
.status-label.partial { color: #975a16; }
.status-label.unmapped { color: var(--gray-500); }

/* Help / explainer boxes */
.help-box {
    background: var(--primary-light);
    border-left: 4px solid var(--primary);
    border-radius: 0 var(--radius) var(--radius) 0;
    max-width: 680px;
    padding: 16px 20px;
    margin-bottom: 24px;
    font-size: 14px;
    color: var(--gray-800);
    line-height: 1.7;
}

.help-box strong {
    color: var(--primary-dark);
}

.help-box ul {
    margin: 8px 0 0 20px;
    padding: 0;
}

.help-box ul li {
    margin-bottom: 4px;
}

.help-toggle {
    background: none;
    border: 1px solid var(--gray-300);
    border-radius: 4px;
    padding: 0.25rem 0.6rem;
    font-size: 0.8rem;
    cursor: pointer;
    color: var(--gray-600);
    float: right;
    margin: -0.25rem 0 0.5rem 0.5rem;
}
.help-toggle:hover { background: var(--gray-100); }
.help-body.collapsed { display: none; }

/* Jargon tooltips */
.jargon {
    text-decoration: underline dotted var(--gray-400);
    cursor: help;
    position: relative;
}
.jargon:hover::after,
.jargon:focus::after {
    content: attr(data-tip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--gray-800);
    color: #fff;
    padding: 0.4rem 0.6rem;
    border-radius: 4px;
    font-size: 0.8rem;
    max-width: 260px;
    white-space: normal;
    z-index: 100;
    pointer-events: none;
}

/* Step indicator for getting-started / upload walkthrough */
.steps {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin-bottom: 24px;
}

.step {
    display: flex;
    gap: 16px;
    padding: 20px 0;
    border-bottom: 1px solid var(--gray-100);
}

.step:last-child {
    border-bottom: none;
}

.step-number {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    flex-shrink: 0;
}

.step-number.done {
    background: var(--success);
}

.step-content h4 {
    font-size: 15px;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 4px;
}

.step-content p {
    font-size: 14px;
    color: var(--gray-600);
    margin: 0;
    line-height: 1.6;
}

/* Export button bar */
.export-bar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-bottom: 16px;
}

.btn-export {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    background: white;
    color: var(--primary);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: border-color 0.15s, background 0.15s;
}

.btn-export:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

/* MUSTIE flag badges */
.mustie-badge {
    display: inline-block;
    width: 22px;
    height: 22px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    text-align: center;
    line-height: 22px;
    margin-right: 2px;
}

.mustie-M { background: #fed7d7; color: #9b2c2c; }
.mustie-U { background: #fefcbf; color: #975a16; }
.mustie-S { background: #c6f6d5; color: #276749; }
.mustie-T { background: #e2e8f0; color: #4a5568; }
.mustie-I { background: #bee3f8; color: #2a4365; }
.mustie-E { background: #e9d8fd; color: #553c9a; }

/* Report availability grid */
.report-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.5rem;
}
.report-link {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    text-decoration: none;
    color: inherit;
    border: 1px solid var(--gray-200);
    font-size: 0.9rem;
    flex-wrap: wrap;
}
.report-link.available:hover { background: var(--gray-50); }
.report-link.unavailable { opacity: 0.55; }
.report-status {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    flex-shrink: 0;
    margin-top: 0.15rem;
}
.report-status.ready { background: var(--success-bg); color: var(--success); }
.report-status.not-ready { background: var(--gray-100); color: var(--gray-600); }
.report-name { font-weight: 500; }
.report-missing {
    font-size: 0.75rem;
    color: var(--gray-500);
    width: 100%;
    padding-left: 1.25rem;
}

/* ── Responsive ─────────────────────────────────── */

.hamburger {
    display: none;
    position: fixed;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 1100;
    background: var(--gray-800);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 0.5rem 0.65rem;
    font-size: 1.25rem;
    cursor: pointer;
    line-height: 1;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 999;
}
.sidebar-overlay.active { display: block; }

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

@media (max-width: 768px) {
    .hamburger { display: block; }

    .sidebar {
        position: fixed;
        left: -260px;
        top: 0;
        bottom: 0;
        z-index: 1000;
        transition: left 0.25s ease;
        width: 240px;
    }
    .sidebar.open { left: 0; }

    .main-content {
        margin-left: 0;
        padding: 1rem;
        padding-top: 3.5rem;
        max-width: 100%;
        overflow-wrap: break-word;
    }

    .stat-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
    }
}

@media (max-width: 480px) {
    .stat-grid { grid-template-columns: 1fr; }
    .stat-card { padding: 0.75rem; }
    .page-header h2 { font-size: 1.25rem; }
    .card { padding: 0.75rem; }
    table { font-size: 0.85rem; }
    th, td { padding: 0.35rem 0.5rem; }
    .help-toggle { float: none; display: block; margin: 0 0 0.5rem auto; }
    .help-box { overflow-wrap: break-word; word-wrap: break-word; }
}

@media (pointer: coarse) {
    nav a, .btn-export, .hamburger, button, input[type="file"] {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }
    select {
        min-height: 44px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0s !important;
        transition-duration: 0s !important;
    }
}

.summary-print-header { display: none; }

.flag-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: var(--blue-50, #eff6ff);
    border: 1px solid var(--blue-200, #bfdbfe);
    border-radius: 6px;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
}
.flag-count { font-weight: 600; color: var(--blue-700, #1d4ed8); }
.flag-checkbox { cursor: pointer; width: 18px; height: 18px; }

/* Print-friendly: hide sidebar, nav, export buttons when printing */
@media print {
    .sidebar, .hamburger, .sidebar-overlay { display: none !important; }
    .main-content { margin-left: 0; padding: 16px; max-width: 100%; }
    .export-bar, .btn, .btn-export, .btn-sm { display: none; }
    .help-box { break-inside: avoid; border: 1px solid #ccc; }
    .help-toggle { display: none; }
    .help-body.collapsed { display: block !important; }
    .card { break-inside: avoid; box-shadow: none; border: 1px solid #ddd; }
    .stat-grid { grid-template-columns: 1fr 1fr; gap: 0.5rem; }
    .stat-card { box-shadow: none; border: 1px solid #ddd; }
    table { font-size: 0.8rem; width: 100%; }
    th, td { padding: 0.25rem 0.5rem; }
    .persistence-warning, .dismiss-btn { display: none; }
    .flag-controls { display: none !important; }
    .flag-checkbox { display: none; }
    th:first-child:has(.flag-checkbox), td:first-child:has(.flag-checkbox) { display: none; }
    .alert { border: 1px solid #ccc; background: #f9f9f9 !important; }
    .page-header { margin-bottom: 0.5rem; }
    .summary-print-header { display: block !important; text-align: center; margin-bottom: 1rem; }
    a { color: inherit; text-decoration: none; }
    @page { margin: 0.75in; }
    .site-footer { display: none; }
}

.site-footer {
    margin-top: 3rem;
    padding: 1.25rem 0;
    border-top: 1px solid var(--gray-200, #e2e8f0);
    text-align: center;
    font-size: 0.8rem;
    color: var(--gray-500, #718096);
}
.site-footer a {
    color: var(--primary);
    text-decoration: none;
}
.site-footer a:hover {
    text-decoration: underline;
}

.demo-banner {
    background: #fef3c7;
    border: 2px solid #f59e0b;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin-bottom: 1.25rem;
    font-size: 0.9rem;
    color: #92400e;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.demo-badge {
    background: #f59e0b;
    color: #fff;
    font-weight: 700;
    font-size: 0.7rem;
    letter-spacing: 0.05em;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    flex-shrink: 0;
}
.demo-banner a {
    color: #92400e;
    font-weight: 600;
    text-decoration: underline;
}
