@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
    --bg:        #0d0f14;
    --bg-card:   #161b25;
    --bg-side:   #111520;
    --border:    #242a38;
    --accent:    #3ecfcf;
    --accent2:   #7c6af7;
    --text:      #e2e8f0;
    --muted:     #64748b;
    --success:   #34d399;
    --warning:   #fbbf24;
    --danger:    #f87171;
    --sidebar-w: 300px;
}

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

html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
}

/* ═══════════════════ SIDEBAR ═══════════════════ */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--bg-side);
    border-right: 1px solid var(--border);
    padding: 28px 20px;
    overflow-y: auto;
    z-index: 200;
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.sidebar.sidebar-hidden {
    transform: translateX(calc(-1 * var(--sidebar-w)));
}

.sidebar h2 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: 0.3px;
}

.sidebar-close {
    position: absolute;
    top: 16px; right: 16px;
    background: none;
    border: none;
    color: var(--muted);
    font-size: 18px;
    cursor: pointer;
    transition: color 0.2s;
}
.sidebar-close:hover { color: var(--text); }

.control-group { display: flex; flex-direction: column; gap: 8px; }

.control-group label {
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    justify-content: space-between;
}
.control-group label span {
    color: var(--accent);
    font-weight: 700;
}

select {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 9px 12px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 13px;
    outline: none;
    width: 100%;
}

input[type=range] {
    width: 100%;
    accent-color: var(--accent);
    cursor: pointer;
}

.btn {
    background: var(--accent);
    color: #0d0f14;
    border: none;
    padding: 11px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    font-family: inherit;
    transition: opacity 0.2s;
    width: 100%;
}
.btn:hover { opacity: 0.85; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.sidebar-note {
    font-size: 12px;
    color: var(--muted);
    line-height: 1.6;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
}

/* ═══════════════════ MAIN PAGE ═══════════════════ */
.page {
    margin-left: var(--sidebar-w);
    flex: 1;
    transition: margin-left 0.3s ease;
    min-height: 100vh;
    overflow-y: auto;
}

.page.sidebar-collapsed {
    margin-left: 0;
}

/* Header */
.page-header {
    position: sticky;
    top: 0; z-index: 100;
    background: rgba(13, 15, 20, 0.9);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 16px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.header-left h1 {
    font-size: 20px;
    font-weight: 800;
    color: #fff;
}

.header-left p {
    font-size: 12px;
    color: var(--muted);
}

.sidebar-toggle {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px 14px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}
.sidebar-toggle:hover { background: var(--border); }

.shift-badge {
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    color: #fff;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 700;
}

/* Sections */
.section {
    padding: 40px 40px 0;
}
.section:last-of-type { padding-bottom: 40px; }

.section-title {
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.badge {
    font-size: 12px;
    font-weight: 600;
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 4px 12px;
    border-radius: 20px;
    color: var(--muted);
}

.section-desc {
    font-size: 14px;
    color: var(--muted);
    margin-bottom: 20px;
    line-height: 1.6;
}

/* Metrics */
.metrics-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.metric-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
}
.metric-card.accent {
    border-color: var(--accent);
    background: linear-gradient(135deg, rgba(62,207,207,0.08), rgba(124,106,247,0.08));
}

.metric-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.metric-val {
    font-size: 26px;
    font-weight: 800;
    color: #fff;
    margin-bottom: 4px;
}

.metric-sub {
    font-size: 12px;
    color: var(--muted);
}
.metric-sub.delta { color: var(--success); font-weight: 600; }

/* Loading Stepper */
.stepper {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin-bottom: 24px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px 24px;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.stepper-step {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    opacity: 0.3;
    transition: opacity 0.3s ease;
    font-size: 13px;
    color: var(--muted);
}
.stepper-step:last-child { border-bottom: none; }

.stepper-step.active {
    opacity: 1;
    color: var(--text);
}
.stepper-step.done {
    opacity: 0.6;
    color: var(--success);
}

.step-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--border);
    flex-shrink: 0;
    transition: background 0.3s ease;
}

.stepper-step.active .step-dot {
    background: var(--accent);
    box-shadow: 0 0 0 3px rgba(62, 207, 207, 0.2);
    animation: pulse 1.2s infinite ease-in-out;
}

.stepper-step.done .step-dot {
    background: var(--success);
    box-shadow: none;
    animation: none;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 3px rgba(62, 207, 207, 0.2); }
    50%       { box-shadow: 0 0 0 6px rgba(62, 207, 207, 0.08); }
}

/* Alerts */

.alert {
    padding: 14px 18px;
    border-radius: 10px;
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 20px;
}
.alert.warning { background: rgba(251,191,36,0.08); color: var(--warning); border: 1px solid rgba(251,191,36,0.25); }
.alert.error   { background: rgba(248,113,113,0.08); color: var(--danger);  border: 1px solid rgba(248,113,113,0.25); }
.hidden { display: none !important; }

/* Map */
.map-wrapper {
    position: relative;
    height: 520px;
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid var(--border);
    margin-bottom: 40px;
}
#map-container {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}
/* MapLibre fills the container */
#map-container .maplibregl-map {
    width: 100%;
    height: 100%;
}
/* deck.gl overlay canvas sits on top */
#map-container .deck-canvas {
    position: absolute;
    inset: 0;
    pointer-events: none;
}
.map-legend {
    position: absolute;
    bottom: 16px; right: 16px;
    background: rgba(13,15,20,0.85);
    backdrop-filter: blur(6px);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 12px;
    color: var(--text);
    display: flex;
    gap: 16px;
    align-items: center;
}
.dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 5px;
    vertical-align: middle;
}
.dot.orange { background: #ff8c00; }
.dot.blue   { background: #1e90ff; }
.line-sample {
    display: inline-block;
    width: 18px;
    height: 3px;
    background: var(--accent);
    border-radius: 2px;
    margin-right: 5px;
    vertical-align: middle;
}

/* Info Grid */
.info-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 40px;
}
.info-grid.two-col { grid-template-columns: repeat(2, 1fr); }

/* ═══════════════════ METHODOLOGY BLOCKS ═══════════════════ */
.method-block {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 28px 32px;
    margin-bottom: 20px;
    position: relative;
}

.method-step-badge {
    display: inline-block;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 1px;
    text-transform: uppercase;
    padding: 4px 12px;
    border-radius: 20px;
    margin-bottom: 12px;
}

.method-title {
    font-size: 17px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 10px;
    line-height: 1.4;
}

.method-desc {
    font-size: 14px;
    color: #a0aec0;
    line-height: 1.75;
    margin-bottom: 20px;
}

.method-note {
    background: rgba(62, 207, 207, 0.06);
    border: 1px solid rgba(62, 207, 207, 0.2);
    border-left: 3px solid var(--accent);
    border-radius: 8px;
    padding: 14px 18px;
    font-size: 13px;
    color: #94a3b8;
    line-height: 1.7;
    margin-top: 16px;
}

/* Method detail grid (4-col cards inside a block) */
.method-detail-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-top: 4px;
}
@media (max-width: 1100px) { .method-detail-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 700px)  { .method-detail-grid { grid-template-columns: 1fr; } }

.method-detail-card {
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    font-size: 13px;
    color: #94a3b8;
    line-height: 1.6;
    display: flex;
    gap: 12px;
    align-items: flex-start;
}
.method-detail-card b { color: var(--text); }

.method-detail-icon {
    font-size: 20px;
    flex-shrink: 0;
    margin-top: 2px;
}

/* Math formula bar */
.method-formula {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    background: rgba(124, 106, 247, 0.08);
    border: 1px solid rgba(124, 106, 247, 0.25);
    border-radius: 10px;
    padding: 16px 20px;
    margin-top: 20px;
}
.formula-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--accent2);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}
.formula-text {
    font-size: 18px;
    font-family: 'Georgia', serif;
    color: #fff;
    font-style: italic;
}
.formula-note {
    font-size: 12px;
    color: var(--muted);
    font-style: italic;
}

/* Constraints grid */
.constraints-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 4px;
}
.constraint-card {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 18px 20px;
}
.constraint-num {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    color: #fff;
    font-weight: 800;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.constraint-body {
    flex: 1;
    font-size: 13px;
    color: #94a3b8;
    line-height: 1.7;
}
.constraint-body b { color: var(--text); font-size: 14px; display: block; margin-bottom: 6px; }
.constraint-body code {
    background: rgba(255,255,255,0.08);
    border-radius: 4px;
    padding: 1px 6px;
    font-size: 12px;
    color: var(--accent);
    font-family: monospace;
}

/* Solver phases */
.solver-phases {
    display: flex;
    gap: 0;
    align-items: stretch;
    margin-top: 8px;
}
.solver-phase {
    flex: 1;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    font-size: 13px;
    color: #94a3b8;
    line-height: 1.7;
}
.solver-phase-num {
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--accent);
    margin-bottom: 6px;
}
.solver-phase-title {
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 10px;
    line-height: 1.4;
}
.solver-phase-arrow {
    display: flex;
    align-items: center;
    padding: 0 16px;
    font-size: 24px;
    color: var(--accent);
    flex-shrink: 0;
}
@media (max-width: 700px) {
    .solver-phases { flex-direction: column; }
    .solver-phase-arrow { transform: rotate(90deg); align-self: center; }
}

/* Shift timeline */
.shift-timeline {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-top: 8px;
}
@media (max-width: 900px) { .shift-timeline { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 500px)  { .shift-timeline { grid-template-columns: 1fr; } }

.shift-event {
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    border: 1px solid var(--border);
}
.shift-event.collect {
    background: linear-gradient(135deg, rgba(62,207,207,0.08), rgba(62,207,207,0.03));
    border-color: rgba(62,207,207,0.25);
}
.shift-event.drop {
    background: linear-gradient(135deg, rgba(124,106,247,0.08), rgba(124,106,247,0.03));
    border-color: rgba(124,106,247,0.25);
}
.shift-time {
    font-size: 20px;
    font-weight: 800;
    color: #fff;
    margin-bottom: 6px;
}
.shift-dir {
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 1px;
    margin-bottom: 10px;
}
.shift-event.collect .shift-dir { color: var(--accent); }
.shift-event.drop    .shift-dir { color: var(--accent2); }
.shift-desc {
    font-size: 12px;
    color: var(--muted);
    line-height: 1.6;
}


.info-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 22px;
}
.info-tag {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 4px;
    padding: 2px 8px;
    margin-bottom: 12px;
}
.info-card h3 {
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 10px;
}
.info-card p {
    font-size: 13px;
    color: var(--muted);
    line-height: 1.7;
}

/* Table */
.table-wrapper {
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    overflow-x: auto;
    margin-bottom: 40px;
}
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
thead { position: sticky; top: 0; z-index: 5; }
th {
    background: var(--bg-side);
    color: var(--muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.4px;
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.02); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.num.muted { color: var(--muted); }
.total { color: var(--accent); font-weight: 700; }
th.muted-col { color: #3d4f60; }

.loading-msg {
    text-align: center;
    padding: 40px;
    color: var(--muted);
    font-size: 14px;
}

/* Footer */
.page-footer {
    padding: 24px 40px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--muted);
    text-align: center;
}

/* Tooltip */
#tooltip {
    position: fixed;
    z-index: 9999;
    pointer-events: none;
    background: rgba(13,15,20,0.97);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.6;
    white-space: pre-wrap;
    display: none;
    box-shadow: 0 10px 25px rgba(0,0,0,0.6);
}

/* Radius Control */
.radius-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.radius-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.radius-display {
    display: flex;
    align-items: baseline;
    gap: 8px;
}
.radius-display span:first-child {
    font-size: 36px;
    font-weight: 800;
    color: var(--accent);
    line-height: 1;
}
.radius-unit {
    font-size: 13px;
    color: var(--muted);
}
.radius-hint,
.hint {
    font-size: 11px;
    color: var(--muted);
    line-height: 1.5;
    margin-top: 4px;
}


/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }

/* Responsive */
@media (max-width: 1100px) {
    .metrics-row { grid-template-columns: repeat(2, 1fr); }
    .info-grid    { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 700px) {
    .metrics-row { grid-template-columns: 1fr; }
    .info-grid    { grid-template-columns: 1fr; }
    .info-grid.two-col { grid-template-columns: 1fr; }
    .section { padding: 24px 16px 0; }
    .page-header { padding: 14px 16px; }
}
