/* ============================================================
   AE4RIA SDG Tracker v2 -- modern UI
   ============================================================ */
:root {
    --navy: #0a1f44;
    --navy-2: #12305f;
    --blue: #1D76B6;          /* exact AE4RIA logo blue */
    --blue-light: #4a90e2;
    --ink: #1a2438;
    --muted: #5b6b85;
    --line: #e3e8f0;
    --bg: #f5f7fb;
    --card: #ffffff;
    --strong: #1a7a4c;
    --moderate: #2e8bc0;
    --weak: #d98a2b;
    --negligible: #9aa6b8;
    --radius: 14px;
    --shadow: 0 4px 20px rgba(10,31,68,0.08);
    --shadow-lg: 0 10px 40px rgba(10,31,68,0.12);
    --font: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
body {
    margin: 0; font-family: var(--font); color: var(--ink);
    background: var(--bg); display: flex; flex-direction: column;
    min-height: 100vh; line-height: 1.55;
}

/* ---------- Header: light, so the dark logo reads well ---------- */
.site-header {
    background: #ffffff;
    border-bottom: 3px solid var(--blue);
    padding: 14px 30px;
    display: flex; align-items: center; gap: 16px;
    box-shadow: var(--shadow);
}
.logo { height: 46px; width: auto; display: block; }
.brand-sub {
    font-size: 14px; font-weight: 600; color: var(--muted);
    text-transform: uppercase; letter-spacing: 2px;
    border-left: 2px solid var(--line); padding-left: 16px;
}

/* ---------- Main ---------- */
.main { flex: 1; width: 100%; max-width: 900px; margin: 0 auto; padding: 42px 24px 60px; }

/* ---------- Hero ---------- */
.hero { text-align: center; margin-bottom: 32px; }
.hero h1 { font-size: 34px; font-weight: 800; color: var(--navy); margin: 0 0 12px; letter-spacing: -0.5px; }
.lead { font-size: 17px; color: var(--muted); max-width: 560px; margin: 0 auto; }

/* ---------- Upload card ---------- */
.upload-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 32px; max-width: 560px; margin: 0 auto; }
.file-drop {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 10px; border: 2px dashed #c4d0e4; border-radius: var(--radius);
    padding: 38px 20px; cursor: pointer; transition: all 0.18s ease;
    background: #fafbfe; text-align: center; user-select: none;
}
.file-drop:hover { border-color: var(--blue); background: #f2f7ff; }
.file-drop.dragover { border-color: var(--blue); background: #e8f1fe; transform: scale(1.01); }
.file-drop.has-file { border-color: var(--strong); background: #f0f9f4; }
.file-icon { font-size: 40px; pointer-events: none; }
.file-text { font-size: 15px; color: var(--muted); font-weight: 500; word-break: break-all; pointer-events: none; }
.file-browse { font-size: 13px; font-weight: 700; color: var(--blue); pointer-events: none; }

.btn-analyze {
    width: 100%; margin-top: 18px; padding: 15px; font-size: 16px; font-weight: 700;
    color: #fff; background: linear-gradient(120deg, var(--blue) 0%, var(--blue-light) 100%);
    border: none; border-radius: 10px; cursor: pointer; transition: all 0.18s ease; letter-spacing: 0.3px;
}
.btn-analyze:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(29,118,182,0.35); }
.btn-analyze:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-analyze.loading { opacity: 0.75; cursor: wait; }

.hint { text-align: center; font-size: 13px; color: var(--muted); margin: 16px 0 0; }
.alert { background: #fdecec; color: #b32020; border: 1px solid #f5c2c2; border-radius: 10px; padding: 12px 14px; margin-bottom: 18px; font-size: 14px; }

/* ---------- Legend ---------- */
.sdg-legend { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: center; margin-top: 28px; }
.sdg-legend.inline { margin-top: 0; }
.legend-title { font-size: 13px; color: var(--muted); font-weight: 600; margin-right: 4px; }
.chip { font-size: 12px; font-weight: 700; padding: 5px 11px; border-radius: 20px; color: #fff; }
.chip-strong { background: var(--strong); }
.chip-moderate { background: var(--moderate); }
.chip-weak { background: var(--weak); }
.chip-negligible { background: var(--negligible); }

/* ---------- Results head ---------- */
.results-head { text-align: center; margin-bottom: 24px; }
.results-head h1 { font-size: 30px; font-weight: 800; color: var(--navy); margin: 0 0 8px; }
.analyzed-file { color: var(--muted); font-size: 15px; margin: 0 0 16px; }
.analyzed-file strong { color: var(--ink); }
.meta-dot { margin: 0 8px; color: #c4d0e4; }
.head-actions { display: flex; align-items: center; justify-content: center; gap: 20px; flex-wrap: wrap; }

.btn-download {
    padding: 10px 18px; font-size: 14px; font-weight: 700; color: #fff;
    background: var(--navy); border: none; border-radius: 9px; cursor: pointer;
    transition: all 0.18s ease;
}
.btn-download:hover { background: var(--navy-2); transform: translateY(-1px); box-shadow: var(--shadow); }
.dl-form { margin: 0; }

/* ---------- Ranking ---------- */
.ranking { display: flex; flex-direction: column; gap: 12px; }
.sdg-row {
    display: flex; gap: 16px; align-items: flex-start; background: var(--card);
    border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow);
    border-left: 5px solid var(--negligible); transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.sdg-row:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.sdg-row.band-strong { border-left-color: var(--strong); }
.sdg-row.band-moderate { border-left-color: var(--moderate); }
.sdg-row.band-weak { border-left-color: var(--weak); }
.sdg-row.band-negligible { border-left-color: var(--negligible); opacity: 0.82; }

.sdg-badge {
    flex-shrink: 0; width: 46px; height: 46px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; font-weight: 800; color: #fff; background: var(--navy);
    position: relative; cursor: help;
}
.sdg-body { flex: 1; min-width: 0; }
.sdg-toprow { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 8px; }
.sdg-title { font-size: 16px; font-weight: 700; color: var(--ink); position: relative; cursor: help; }
.info-dot {
    display: inline-flex; align-items: center; justify-content: center;
    width: 15px; height: 15px; font-size: 10px; font-style: italic; font-weight: 700;
    color: #fff; background: var(--blue); border-radius: 50%; margin-left: 5px; vertical-align: middle;
}
.sdg-score { font-size: 18px; font-weight: 800; color: var(--navy); flex-shrink: 0; }

.bar-track { width: 100%; height: 9px; background: #eef2f8; border-radius: 6px; overflow: hidden; margin-bottom: 8px; }
.bar-fill { height: 100%; border-radius: 6px; transition: width 0.7s cubic-bezier(0.22,1,0.36,1); background: var(--negligible); }
.band-fill-strong { background: linear-gradient(90deg, #1a7a4c, #22a866); }
.band-fill-moderate { background: linear-gradient(90deg, #2e8bc0, #4aa8dd); }
.band-fill-weak { background: linear-gradient(90deg, #d98a2b, #eaa845); }
.band-fill-negligible { background: #b9c2d0; }

.sdg-desc { font-size: 13px; color: var(--muted); }
.legacy-tag { margin-left: 10px; padding: 2px 8px; background: #eef2f8; border-radius: 10px; font-weight: 600; color: var(--navy); font-size: 12px; }

/* ---------- Tooltips ---------- */
[data-tooltip] { position: relative; }
[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute; left: 0; top: calc(100% + 8px); z-index: 30;
    background: var(--navy); color: #fff; padding: 8px 12px; border-radius: 8px;
    font-size: 12px; font-weight: 500; line-height: 1.4; width: max-content; max-width: 320px;
    box-shadow: var(--shadow-lg); white-space: normal;
}
[data-tooltip]:hover::before {
    content: ""; position: absolute; left: 14px; top: calc(100% + 2px); z-index: 31;
    border: 6px solid transparent; border-bottom-color: var(--navy);
}
.sdg-badge[data-tooltip]:hover::after { left: 0; }

/* ---------- Chart ---------- */
.chart-section { margin-top: 40px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 26px; }
.chart-section h2 { font-size: 20px; color: var(--navy); margin: 0 0 6px; }
.chart-note { font-size: 14px; color: var(--muted); margin: 0 0 18px; }
.barplot { width: 100%; height: auto; display: block; }

/* ---------- Actions ---------- */
.actions { text-align: center; margin-top: 34px; }
.btn-back {
    display: inline-block; padding: 13px 26px; font-size: 15px; font-weight: 700;
    color: var(--navy); background: #fff; border: 2px solid var(--navy);
    border-radius: 10px; text-decoration: none; transition: all 0.18s ease;
}
.btn-back:hover { background: var(--navy); color: #fff; }

/* ---------- Footer ---------- */
.footer { background: #eef1f7; padding: 22px 24px; text-align: center; font-size: 12px; color: var(--muted); margin-top: auto; }
.footer p { max-width: 900px; margin: 0 auto 6px; }
.copyright { font-weight: 700; color: var(--navy); }

/* ---------- Responsive ---------- */
@media (max-width: 600px) {
    .hero h1 { font-size: 27px; }
    .sdg-row { padding: 14px; gap: 12px; }
    .sdg-badge { width: 40px; height: 40px; font-size: 17px; }
    .main { padding: 28px 16px 44px; }
    .site-header { padding: 12px 18px; }
    .logo { height: 38px; }
}

/* ---------- Footer link ---------- */
.footer-link { color: var(--blue); text-decoration: none; font-weight: 700; }
.footer-link:hover { text-decoration: underline; }
