/* ===== CSS Variables – Light Theme ===== */
:root {
    --bg: #f0f2f5;
    --card-bg: #ffffff;
    --card-shadow: 0 2px 12px rgba(0,0,0,0.08);
    --text: #333333;
    --text-secondary: #666666;
    --text-muted: #999999;
    --text-label: #555555;
    --border: #e0e0e0;
    --chip-bg: #f0f2f5;
    --section-border: #f0f2f5;
    --row-alt: #f9f9fb;
    --row-border: #efefef;
    --drop-hover-bg: #e8f0fe;
    --drop-hover-border: #0d47a1;
    --status-info-bg: #e8f0fe;
    --status-info-color: #1a73e8;
    --status-error-bg: #fdecea;
    --status-error-color: #c62828;
    --status-success-bg: #e6f4ea;
    --status-success-color: #2e7d32;
    --feature-tag-bg: #e8f0fe;
    --feature-tag-color: #1a73e8;
    --feature-summary-bg: #f8f9ff;
    --feature-summary-border: #1a73e8;
    --gap-header-color: #444444;
    --gap-item-bg: #fff8f8;
    --ok-item-bg: #f6fef6;
    --scenarios-bg: #fff3f3;
    --scenarios-text: #555555;
    --scenarios-border: #e57373;
    --gap-feature-bg: #f0f2f5;
    --gap-feature-label: #555555;
    --no-gaps-color: #2e7d32;
    --accent: #1a73e8;
    --accent-hover: #1558b0;
}

/* ===== CSS Variables – Dark Theme ===== */
[data-theme="dark"] {
    --bg: #0f1117;
    --card-bg: #1e2130;
    --card-shadow: 0 2px 16px rgba(0,0,0,0.45);
    --text: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-label: #94a3b8;
    --border: #2d3748;
    --chip-bg: #252d3d;
    --section-border: #252d3d;
    --row-alt: #1a2035;
    --row-border: #2d3748;
    --drop-hover-bg: #1e2a3a;
    --drop-hover-border: #4a9eff;
    --status-info-bg: #172237;
    --status-info-color: #60a5fa;
    --status-error-bg: #2d1b1b;
    --status-error-color: #fc8181;
    --status-success-bg: #1a2e1a;
    --status-success-color: #68d391;
    --feature-tag-bg: #1e3a5f;
    --feature-tag-color: #60a5fa;
    --feature-summary-bg: #172237;
    --feature-summary-border: #4a9eff;
    --gap-header-color: #94a3b8;
    --gap-item-bg: #2d1b1b;
    --ok-item-bg: #1a2e1a;
    --scenarios-bg: #2d1b1b;
    --scenarios-text: #94a3b8;
    --scenarios-border: #b45454;
    --gap-feature-bg: #252d3d;
    --gap-feature-label: #94a3b8;
    --no-gaps-color: #68d391;
    --accent: #4a9eff;
    --accent-hover: #2980e8;
}

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    transition: background 0.25s, color 0.25s;
}

/* ===== Header ===== */
header {
    background: linear-gradient(135deg, #1a73e8 0%, #0d47a1 100%);
    color: #fff;
    padding: 18px 32px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

header h1 { font-size: 1.5rem; font-weight: 600; }

.back-link {
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    font-size: 0.9rem;
    border: 1px solid rgba(255,255,255,0.4);
    padding: 4px 12px;
    border-radius: 20px;
    transition: background 0.2s;
}
.back-link:hover { background: rgba(255,255,255,0.15); }

/* ===== Main Layout ===== */
main { max-width: 1100px; margin: 32px auto; padding: 0 24px 60px; }

/* ===== Upload Card ===== */
.upload-card {
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    padding: 36px;
    text-align: center;
    margin-bottom: 32px;
    transition: background 0.25s, box-shadow 0.25s;
}

.upload-card h2 { font-size: 1.25rem; margin-bottom: 8px; color: var(--accent); }
.upload-card p  { color: var(--text-secondary); margin-bottom: 24px; font-size: 0.95rem; }

.drop-zone {
    border: 2px dashed var(--accent);
    border-radius: 10px;
    padding: 48px 24px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    position: relative;
}

.drop-zone:hover, .drop-zone.drag-over {
    background: var(--drop-hover-bg);
    border-color: var(--drop-hover-border);
}

.drop-zone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
}

.drop-zone .icon { font-size: 3rem; display: block; margin-bottom: 12px; }
.drop-zone .label { font-size: 1rem; color: var(--text-secondary); }
.drop-zone .hint  { font-size: 0.82rem; color: var(--text-muted); margin-top: 6px; }

.btn-analyze {
    margin-top: 24px;
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 12px 36px;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s, opacity 0.2s;
}
.btn-analyze:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-analyze:not(:disabled):hover { background: var(--accent-hover); }

/* ===== Status Bar ===== */
#status-bar {
    display: none;
    padding: 12px 20px;
    border-radius: 8px;
    margin-bottom: 24px;
    font-size: 0.95rem;
    transition: background 0.25s;
}
#status-bar.info    { background: var(--status-info-bg);    color: var(--status-info-color);    display: block; }
#status-bar.error   { background: var(--status-error-bg);   color: var(--status-error-color);   display: block; }
#status-bar.success { background: var(--status-success-bg); color: var(--status-success-color); display: block; }

/* ===== Section Cards ===== */
.section-card {
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    padding: 28px 32px;
    margin-bottom: 28px;
    display: none;
    transition: background 0.25s, box-shadow 0.25s;
}
.section-card.visible { display: block; }

.section-card h2 {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 18px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--section-border);
    color: var(--accent);
}

/* ===== Stats Row ===== */
.stats-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 6px;
}

.stat-chip {
    background: var(--chip-bg);
    border-radius: 8px;
    padding: 14px 22px;
    min-width: 130px;
    text-align: center;
    flex: 1;
    transition: background 0.25s;
}
.stat-chip .num { font-size: 2rem; font-weight: 700; color: var(--accent); line-height: 1; }
.stat-chip .lbl { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; }

/* Clickable gap-category chips */
.stat-chip--link {
    cursor: pointer;
    transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
}
.stat-chip--link:hover,
.stat-chip--link:focus-visible {
    background: var(--drop-hover-bg);
    transform: translateY(-2px);
    box-shadow: 0 4px 14px rgba(0,0,0,0.12);
    outline: none;
}
.stat-chip--link:active { transform: translateY(0); }

/* ===== Feature Tags ===== */
.feature-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.feature-tag {
    background: var(--feature-tag-bg);
    color: var(--feature-tag-color);
    border-radius: 20px;
    padding: 4px 14px;
    font-size: 0.82rem;
    font-weight: 500;
}

/* ===== Gap Lists ===== */
.gap-category { margin-bottom: 24px; }
.gap-category h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--gap-header-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

.badge {
    display: inline-block;
    border-radius: 12px;
    padding: 2px 10px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge.missing  { background: #fdecea; color: #c62828; }
.badge.covered  { background: #e6f4ea; color: #2e7d32; }
.badge.warning  { background: #fff8e1; color: #f57f17; }

[data-theme="dark"] .badge.missing  { background: #2d1b1b; color: #fc8181; }
[data-theme="dark"] .badge.covered  { background: #1a2e1a; color: #68d391; }
[data-theme="dark"] .badge.warning  { background: #2d2200; color: #fbbf24; }

.gap-list { list-style: none; }
.gap-list li {
    padding: 10px 14px;
    border-radius: 6px;
    margin-bottom: 6px;
    font-size: 0.9rem;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    line-height: 1.45;
}

.gap-list li.gap-item   { background: var(--gap-item-bg); border-left: 3px solid #e53935; }
.gap-list li.ok-item    { background: var(--ok-item-bg);  border-left: 3px solid #43a047; }

.gap-list li.expandable { cursor: pointer; flex-wrap: wrap; }
.gap-list li.expandable:hover { background: var(--drop-hover-bg); }

.gap-label { flex: 1; }

.expand-arrow {
    font-size: 0.7rem;
    color: #e53935;
    transition: transform 0.2s;
    flex-shrink: 0;
    margin-top: 3px;
}
.gap-list li.open .expand-arrow { transform: rotate(90deg); }

/* Scenarios panel – hidden by default, slides open */
.scenarios-panel {
    display: none;
    width: 100%;
    margin-top: 8px;
    padding: 10px 12px;
    background: var(--scenarios-bg);
    border-radius: 6px;
    border: 1px dashed var(--scenarios-border);
}
.gap-list li.open .scenarios-panel { display: block; }

.scenarios-panel ul {
    list-style: disc;
    padding-left: 18px;
    margin: 0;
}
.scenarios-panel ul li {
    display: list-item;
    background: transparent;
    border: none;
    padding: 3px 0;
    font-size: 0.82rem;
    color: var(--scenarios-text);
    line-height: 1.5;
}

.gap-list li .icon-mark { font-size: 1rem; flex-shrink: 0; margin-top: 1px; }

/* ===== Parsed Table ===== */
.table-wrapper {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid var(--border);
}

table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
thead th {
    background: var(--accent);
    color: #fff;
    padding: 10px 14px;
    text-align: left;
    white-space: nowrap;
}
tbody tr:nth-child(even) { background: var(--row-alt); }
tbody td {
    padding: 8px 14px;
    border-bottom: 1px solid var(--row-border);
    vertical-align: top;
    color: var(--text);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--drop-hover-bg); transition: background 0.15s; }

/* ===== Severity Badges ===== */
.severity-badge {
    display: inline-block;
    border-radius: 12px;
    padding: 2px 10px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: capitalize;
    flex-shrink: 0;
    letter-spacing: 0.02em;
}
.severity-showstopper { background: #3d0000; color: #fff; }
.severity-critical    { background: #b71c1c; color: #fff; }
.severity-major       { background: #e65100; color: #fff; }
.severity-minor       { background: #f9a825; color: #333; }

/* ===== Gap Feature Summary ===== */
.gap-feature-summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    background: var(--gap-feature-bg);
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 20px;
    transition: background 0.25s;
}
.gap-feature-summary-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--gap-feature-label);
    white-space: nowrap;
}

/* ===== Feature Summary ===== */
.feature-summary-text {
    font-size: 0.95rem;
    line-height: 1.75;
    color: var(--text);
    background: var(--feature-summary-bg);
    border-left: 4px solid var(--feature-summary-border);
    padding: 14px 18px;
    border-radius: 0 8px 8px 0;
    transition: background 0.25s;
}

/* ===== No-gaps Banner ===== */
.no-gaps-banner {
    text-align: center;
    padding: 24px;
    color: var(--no-gaps-color);
    font-weight: 500;
    font-size: 1rem;
}

/* ===== Responsive ===== */
@media (max-width: 640px) {
    main { padding: 0 12px 40px; }
    .section-card { padding: 20px 16px; }
    .upload-card  { padding: 24px 16px; }
    .stat-chip .num { font-size: 1.6rem; }
}

/* ===== Review Quality Section ===== */
.review-standard-note {
    font-size: .84rem;
    color: var(--text-muted, #666);
    margin: -6px 0 16px;
}
.review-grade-row {
    display: flex;
    align-items: center;
    gap: 18px;
    margin-bottom: 4px;
}
.review-grade-circle {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 76px;
    height: 76px;
    border-radius: 50%;
    flex-shrink: 0;
    font-weight: 700;
}
.review-grade-letter { font-size: 2rem; line-height: 1; }
.review-grade-score  { font-size: .72rem; letter-spacing: .02em; }
.review-grade-details { flex: 1; }

.review-field-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 18px;
}
@media (max-width: 640px) { .review-field-grid { grid-template-columns: 1fr; } }

.review-field-item {
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-rows: auto auto;
    column-gap: 8px;
    row-gap: 2px;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border, #ebebeb);
}
.review-field-label {
    grid-column: 1 / 3;
    font-size: .86rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}
.review-missing-badge {
    font-size: .72rem;
    background: #fce4e4;
    color: #b71c1c;
    border-radius: 4px;
    padding: 1px 6px;
    font-weight: 600;
}
[data-theme="dark"] .review-missing-badge { background: #4e1010; color: #ff7070; }
.review-field-bar-wrap {
    grid-column: 1 / 3;
    height: 6px;
    background: var(--border, #e0e0e0);
    border-radius: 3px;
    overflow: hidden;
}
.review-field-bar {
    height: 100%;
    border-radius: 3px;
    transition: width .4s ease;
}
.review-field-pct  { grid-row: 2; grid-column: 3; font-size: .82rem; font-weight: 700; }
.review-field-desc {
    grid-column: 1 / 4;
    font-size: .78rem;
    color: var(--text-muted, #666);
    line-height: 1.4;
}

.review-coverage-list {
    list-style: none;
    padding: 0;
    margin: 0 0 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.review-coverage-list li {
    font-size: .88rem;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}
.review-std-badge {
    font-size: .75rem;
    background: var(--card-bg, #f5f7fa);
    border: 1px solid var(--border, #dde2ea);
    border-radius: 4px;
    padding: 1px 7px;
    color: var(--text-muted, #666);
    font-style: italic;
}

.review-exp-quality {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin: 10px 0 4px;
    font-size: .88rem;
}
.review-exp-label { font-weight: 600; }

.review-recommendations summary::-webkit-details-marker { display: none; }
.review-recommendations ul li:last-child { border-bottom: none !important; }
