/* ================================================================
   Saintsburg Tracker — Premium Dark Theme
   ================================================================ */

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

:root {
    --bg: #0a0a14;
    --surface: rgba(255,255,255,0.04);
    --glass: rgba(255,255,255,0.06);
    --glass-border: rgba(255,255,255,0.10);
    --text: #e4e4ef;
    --text-dim: #8888a4;
    --accent-1: #7c3aed;
    --accent-2: #2563eb;
    --accent-grad: linear-gradient(135deg, var(--accent-1), var(--accent-2));
    --danger: #ef4444;
    --success: #22c55e;
    --warning: #f59e0b;
    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 8px 32px rgba(0,0,0,0.45);
    --transition: 0.3s cubic-bezier(.4,0,.2,1);
}

html { font-size: 16px; }
body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Animated background blobs ------------------------------------------ */
.bg-blobs {
    position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden;
}
.blob {
    position: absolute; border-radius: 50%; filter: blur(120px); opacity: .25;
}
.blob-1 {
    width: 500px; height: 500px; background: var(--accent-1);
    top: -10%; left: -8%;
    animation: drift1 18s ease-in-out infinite alternate;
}
.blob-2 {
    width: 400px; height: 400px; background: var(--accent-2);
    bottom: -5%; right: -6%;
    animation: drift2 22s ease-in-out infinite alternate;
}
.blob-3 {
    width: 300px; height: 300px; background: #06b6d4;
    top: 40%; left: 55%;
    animation: drift3 20s ease-in-out infinite alternate;
}
@keyframes drift1 { to { transform: translate(80px, 60px) scale(1.15); } }
@keyframes drift2 { to { transform: translate(-60px, -80px) scale(1.1); } }
@keyframes drift3 { to { transform: translate(-40px, 50px) scale(0.9); } }

/* --- App container ------------------------------------------------------ */
.app-container {
    position: relative; z-index: 1;
    max-width: 760px;
    margin: 0 auto;
    padding: 2rem 1.25rem 4rem;
}

/* --- Header ------------------------------------------------------------- */
.app-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 2rem;
    animation: fadeInDown .6s ease both;
}
.logo-group { display: flex; align-items: center; gap: .75rem; }
.logo-icon svg { width: 42px; height: 42px; }
.logo-text {
    font-size: 1.35rem; font-weight: 700;
    background: var(--accent-grad); -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text;
}
.logo-sub { font-size: .75rem; color: var(--text-dim); margin-top: 1px; }
.header-user { display: flex; align-items: center; gap: .5rem; }
.user-avatar { width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--glass-border); }
.user-name { font-size: .85rem; font-weight: 500; color: var(--text-dim); }

/* --- Stepper ------------------------------------------------------------ */
.stepper {
    display: flex; align-items: center; justify-content: center;
    gap: 0; margin-bottom: 2.5rem;
    animation: fadeInDown .6s .15s ease both;
}
.step {
    display: flex; flex-direction: column; align-items: center; gap: .35rem;
    opacity: .35; transition: opacity var(--transition);
}
.step.active { opacity: 1; }
.step.done { opacity: .7; }
.step-circle {
    width: 36px; height: 36px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: .82rem; font-weight: 700;
    background: var(--surface); border: 2px solid var(--glass-border);
    transition: all var(--transition);
}
.step.active .step-circle {
    background: var(--accent-grad); border-color: transparent; color: #fff;
    box-shadow: 0 0 20px rgba(124,58,237,.4);
}
.step.done .step-circle {
    background: var(--success); border-color: transparent; color: #fff;
}
.step-label { font-size: .7rem; font-weight: 500; color: var(--text-dim); text-transform: uppercase; letter-spacing: .06em; }
.step-line {
    flex: 0 0 60px; height: 2px; background: var(--glass-border); margin: 0 .5rem;
    margin-bottom: 1.2rem;
}

/* --- Glass Panel -------------------------------------------------------- */
.glass-panel {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
    box-shadow: var(--shadow);
}

.panel {
    padding: 2.5rem 2rem;
    display: none; flex-direction: column; align-items: center;
    text-align: center;
    animation: fadeInUp .45s ease both;
}
.panel.active { display: flex; }

.panel-icon { margin-bottom: 1.25rem; }
.panel-icon svg { width: 56px; height: 56px; }
.panel-title { font-size: 1.4rem; font-weight: 700; margin-bottom: .5rem; }
.panel-desc { font-size: .88rem; color: var(--text-dim); max-width: 460px; line-height: 1.55; margin-bottom: 1.75rem; }

/* --- Inputs ------------------------------------------------------------- */
.input-group { width: 100%; max-width: 420px; text-align: left; margin-bottom: 1.25rem; }
.input-group.compact { flex: 1; }
.input-label { display: block; font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-dim); margin-bottom: .4rem; }
.input-wrapper { position: relative; }
.input-field {
    width: 100%; padding: .75rem 1rem;
    background: var(--surface); border: 1.5px solid var(--glass-border);
    border-radius: var(--radius-sm);
    color: var(--text); font-size: .92rem; font-family: inherit;
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}
.input-field:focus {
    border-color: var(--accent-1);
    box-shadow: 0 0 0 3px rgba(124,58,237,.18);
}
.input-field::placeholder { color: var(--text-dim); opacity: .6; }
input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(.7); }
.input-btn-icon {
    position: absolute; right: .65rem; top: 50%; transform: translateY(-50%);
    background: none; border: none; color: var(--text-dim); cursor: pointer; padding: 4px;
}
.input-btn-icon svg { width: 18px; height: 18px; }
.input-error { font-size: .78rem; color: var(--danger); margin-top: .35rem; min-height: 1.1em; }

.date-row { display: flex; gap: 1rem; width: 100%; max-width: 420px; margin-bottom: 1.25rem; }

/* --- Buttons ------------------------------------------------------------ */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
    padding: .72rem 1.75rem;
    border: none; border-radius: var(--radius-sm);
    font-family: inherit; font-size: .88rem; font-weight: 600;
    cursor: pointer; transition: all var(--transition);
    outline: none;
}
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary {
    background: var(--accent-grad); color: #fff;
    box-shadow: 0 4px 16px rgba(124,58,237,.3);
}
.btn-primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 6px 24px rgba(124,58,237,.45); }
.btn-outline {
    background: transparent; color: var(--text);
    border: 1.5px solid var(--glass-border);
}
.btn-outline:hover:not(:disabled) { border-color: var(--accent-1); color: var(--accent-1); }
.btn-ghost {
    background: transparent; color: var(--text-dim);
}
.btn-ghost:hover { color: var(--text); }
.btn-sm { padding: .45rem 1rem; font-size: .78rem; }

.panel-actions { display: flex; gap: .75rem; margin-top: .5rem; }

/* --- Loader spinner ----------------------------------------------------- */
.btn-loader {
    display: inline-block; width: 18px; height: 18px;
    border: 2.5px solid rgba(255,255,255,.25); border-top-color: #fff;
    border-radius: 50%;
    animation: spin .65s linear infinite;
}
.btn-loader.inline { width: 16px; height: 16px; border-top-color: var(--accent-1); border-color: var(--glass-border); border-top-color: var(--accent-1); }
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Courses grid ------------------------------------------------------- */
.courses-controls { display: flex; gap: .5rem; margin-bottom: 1rem; }
.courses-grid {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: .65rem; width: 100%; max-width: 520px; margin-bottom: 1.5rem;
    max-height: 320px; overflow-y: auto; padding-right: 4px;
}
.courses-grid::-webkit-scrollbar { width: 5px; }
.courses-grid::-webkit-scrollbar-thumb { background: var(--glass-border); border-radius: 4px; }

.course-chip {
    display: flex; align-items: center; gap: .55rem;
    padding: .65rem .85rem;
    background: var(--surface); border: 1.5px solid var(--glass-border);
    border-radius: var(--radius-sm);
    cursor: pointer; transition: all var(--transition);
    text-align: left;
}
.course-chip:hover { border-color: var(--accent-2); }
.course-chip.selected { border-color: var(--accent-1); background: rgba(124,58,237,.12); }
.course-chip input { display: none; }
.chip-check {
    width: 20px; height: 20px; border-radius: 5px; flex-shrink: 0;
    border: 2px solid var(--glass-border);
    display: flex; align-items: center; justify-content: center;
    transition: all var(--transition);
}
.course-chip.selected .chip-check {
    background: var(--accent-grad); border-color: transparent;
}
.chip-check svg { width: 12px; height: 12px; stroke: #fff; opacity: 0; transition: opacity .2s; }
.course-chip.selected .chip-check svg { opacity: 1; }
.chip-label { font-size: .82rem; font-weight: 500; line-height: 1.3; }
.chip-code { display: block; font-size: .68rem; color: var(--text-dim); font-weight: 400; }

/* --- Results ------------------------------------------------------------ */
.results-header { display: flex; justify-content: space-between; align-items: center; width: 100%; margin-bottom: 1.5rem; }
.results-header .panel-title { margin-bottom: 0; }

.overall-card {
    display: flex; align-items: center; gap: 1.5rem;
    padding: 1.5rem 2rem; width: 100%; margin-bottom: 1.75rem;
    border: 1px solid rgba(124,58,237,.25);
    background: rgba(124,58,237,.06);
}
.ring-wrap { position: relative; width: 100px; height: 100px; flex-shrink: 0; }
.progress-ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--glass-border); stroke-width: 8; }
.ring-fg { fill: none; stroke: url(#ringGrad); stroke-width: 8; stroke-linecap: round; transition: stroke-dashoffset 1.2s cubic-bezier(.4,0,.2,1); }
.ring-value {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    font-size: 1.35rem; font-weight: 800;
}
.overall-info { text-align: left; }
.overall-info h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: .25rem; }
.overall-info p { font-size: .82rem; color: var(--text-dim); }

.courses-results {
    display: grid; grid-template-columns: 1fr; gap: 1rem; width: 100%;
}

.course-result-card {
    padding: 1.25rem 1.5rem; text-align: left;
    animation: fadeInUp .4s ease both;
}
.course-result-card .cr-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: .75rem; }
.cr-name { font-size: .95rem; font-weight: 600; }
.cr-avg {
    font-size: 1.1rem; font-weight: 800; padding: .25rem .7rem;
    border-radius: 8px; background: var(--surface);
}
.cr-avg.high { color: var(--success); }
.cr-avg.mid { color: var(--warning); }
.cr-avg.low { color: var(--danger); }

.cr-bar-wrap { height: 6px; border-radius: 3px; background: var(--surface); overflow: hidden; margin-bottom: .65rem; }
.cr-bar {
    height: 100%; border-radius: 3px;
    background: var(--accent-grad);
    width: 0; transition: width 1s cubic-bezier(.4,0,.2,1);
}

.cr-details-toggle {
    font-size: .75rem; color: var(--text-dim); background: none; border: none;
    cursor: pointer; font-family: inherit; padding: 0; text-decoration: underline;
    transition: color .2s;
}
.cr-details-toggle:hover { color: var(--text); }

.cr-assignments {
    display: none; margin-top: .75rem; border-top: 1px solid var(--glass-border); padding-top: .6rem;
}
.cr-assignments.open { display: block; }
.cr-assignment-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: .35rem 0; font-size: .78rem; color: var(--text-dim);
    border-bottom: 1px solid rgba(255,255,255,.03);
}
.cr-assignment-row:last-child { border-bottom: none; }
.cr-assignment-name { flex: 1; margin-right: 1rem; }
.cr-assignment-score { font-weight: 600; color: var(--text); }

/* --- Queue toast -------------------------------------------------------- */
.queue-toast {
    position: fixed; bottom: 1.5rem; left: 0; right: 0;
    display: flex; justify-content: center; pointer-events: none;
    z-index: 100; animation: fadeInUp .35s ease both;
}
.queue-toast-inner {
    pointer-events: auto;
    min-width: 280px; max-width: 90vw;
    display: flex; flex-direction: column; align-items: stretch; gap: .65rem;
    background: rgba(20,20,36,.92); border: 1px solid var(--glass-border);
    backdrop-filter: blur(16px);
    padding: .85rem 1.25rem; border-radius: 12px;
    font-size: .82rem; color: var(--text-dim);
    box-shadow: 0 8px 32px rgba(0,0,0,.5);
}
.queue-header {
    display: flex; align-items: center; gap: .65rem;
}
.queue-progress-bg {
    height: 4px; border-radius: 2px; background: rgba(255,255,255,0.1); overflow: hidden; width: 100%;
    margin-top: .15rem;
}
.queue-progress-fill {
    height: 100%; background: var(--accent-grad); width: 0%; transition: width 0.3s cubic-bezier(.4,0,.2,1);
}

/* --- Animations --------------------------------------------------------- */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(18px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-18px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Responsive --------------------------------------------------------- */
@media (max-width: 560px) {
    .app-container { padding: 1.25rem .85rem 3rem; }
    .panel { padding: 1.75rem 1.25rem; }
    .courses-grid { grid-template-columns: 1fr; }
    .overall-card { flex-direction: column; text-align: center; padding: 1.25rem; }
    .overall-info { text-align: center; }
    .results-header { flex-direction: column; align-items: flex-start; gap: .5rem; }
    .date-row { flex-direction: column; }
}

/* --- Footer ------------------------------------------------------------- */
.site-footer {
    text-align: center; margin-top: -1rem; padding-bottom: 2rem;
    font-size: 0.8rem; color: var(--text-dim); opacity: 0.7;
}

/* Hidden SVG for ring gradient */
.hidden-svg { position: absolute; width: 0; height: 0; overflow: hidden; }
