/* ============================================================
   POCS FIR Filter Design — Premium Dark Theme
   ============================================================ */

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

/* ---------- CSS Variables ---------- */
:root {
    --bg-primary: #0b0e17;
    --bg-secondary: #111827;
    --bg-card: rgba(17, 24, 39, 0.7);
    --bg-sidebar: rgba(15, 20, 35, 0.85);
    --border-subtle: rgba(99, 128, 255, 0.15);
    --border-glow: rgba(99, 128, 255, 0.35);
    --accent-primary: #6366f1;
    --accent-secondary: #818cf8;
    --accent-tertiary: #a5b4fc;
    --accent-green: #34d399;
    --accent-amber: #fbbf24;
    --accent-red: #f87171;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --glass-blur: 16px;
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-card: 0 4px 24px rgba(0,0,0,0.4), 0 1px 4px rgba(0,0,0,0.2);
    --shadow-glow: 0 0 20px rgba(99,102,241,0.15);
    --transition-fast: 0.15s ease;
    --transition-med: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html { font-size: 14px; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    background-image:
        radial-gradient(ellipse at 20% 0%, rgba(99,102,241,0.08) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 100%, rgba(52,211,153,0.06) 0%, transparent 60%);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ---------- Header ---------- */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: var(--bg-sidebar);
    backdrop-filter: blur(var(--glass-blur));
    border-bottom: 1px solid var(--border-subtle);
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-header h1 {
    font-size: 1.15rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--accent-secondary), var(--accent-green));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}

.btn-back {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: rgba(99,102,241,0.1);
    color: var(--accent-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
}
.btn-back:hover {
    background: rgba(99,102,241,0.2);
    border-color: var(--border-glow);
}

/* ---------- Main Layout ---------- */
.app-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 0;
    height: calc(100vh - 49px);
}

/* ---------- Sidebar ---------- */
.sidebar {
    background: var(--bg-sidebar);
    backdrop-filter: blur(var(--glass-blur));
    border-right: 1px solid var(--border-subtle);
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border-subtle); border-radius: 2px; }

.control-section {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 14px;
}

.control-section h3 {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent-secondary);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.control-section h3 .icon {
    font-size: 0.9rem;
}

/* ---------- Slider Groups ---------- */
.param-group {
    margin-bottom: 10px;
}

.param-group:last-child { margin-bottom: 0; }

.param-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.param-label span {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.param-label .param-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.78rem;
    color: var(--accent-tertiary);
    background: rgba(99,102,241,0.1);
    padding: 1px 6px;
    border-radius: 4px;
}

.param-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.param-row input[type="range"] {
    flex: 1;
}

.param-row input[type="number"] {
    width: 60px;
    background: rgba(15, 20, 35, 0.8);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    padding: 4px 6px;
    text-align: center;
    transition: border-color var(--transition-fast);
}

.param-row input[type="number"]:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(99,102,241,0.15);
}

/* ---------- Range Slider Styling ---------- */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    background: var(--border-subtle);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent-primary);
    border: 2px solid var(--bg-primary);
    box-shadow: 0 0 6px rgba(99,102,241,0.4);
    cursor: grab;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 12px rgba(99,102,241,0.6);
}

input[type="range"]:active::-webkit-slider-thumb {
    cursor: grabbing;
}

/* ---------- Buttons ---------- */
.btn-group {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 7px 14px;
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
}

.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.1), transparent);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.btn:hover::after { opacity: 1; }

.btn:active { transform: scale(0.97); }

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), #4f46e5);
    color: white;
    box-shadow: 0 2px 8px rgba(99,102,241,0.3);
}
.btn-primary:hover { box-shadow: 0 4px 16px rgba(99,102,241,0.4); }

.btn-secondary {
    background: rgba(99,102,241,0.12);
    color: var(--accent-tertiary);
    border-color: var(--border-subtle);
}
.btn-secondary:hover {
    background: rgba(99,102,241,0.2);
    border-color: var(--border-glow);
}

.btn-success {
    background: linear-gradient(135deg, #059669, #10b981);
    color: white;
    box-shadow: 0 2px 8px rgba(16,185,129,0.3);
}

.btn-warning {
    background: linear-gradient(135deg, #d97706, #f59e0b);
    color: #1a1a2e;
    box-shadow: 0 2px 8px rgba(245,158,11,0.3);
}

.btn-danger {
    background: rgba(248,113,113,0.15);
    color: var(--accent-red);
    border-color: rgba(248,113,113,0.25);
}
.btn-danger:hover { background: rgba(248,113,113,0.25); }

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
}

.btn .icon { font-size: 1rem; }

/* ---------- Status Display ---------- */
.status-panel {
    background: rgba(99,102,241,0.06);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 12px 14px;
}

.status-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    margin-bottom: 4px;
}
.status-row:last-child { margin-bottom: 0; }

.status-row .label {
    color: var(--text-muted);
    font-weight: 500;
}

.status-row .value {
    font-family: 'JetBrains Mono', monospace;
    color: var(--accent-green);
    font-weight: 600;
}

.micro-step-indicator {
    display: flex;
    gap: 3px;
    margin-top: 8px;
}

.micro-dot {
    width: 100%;
    height: 4px;
    border-radius: 2px;
    background: var(--border-subtle);
    transition: background var(--transition-med);
}

.micro-dot.active {
    background: var(--accent-primary);
    box-shadow: 0 0 6px rgba(99,102,241,0.5);
}

.micro-dot.done {
    background: var(--accent-green);
}

/* ---------- Main Content ---------- */
.main-content {
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* ---------- Chart Cards ---------- */
.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 16px;
    box-shadow: var(--shadow-card);
    position: relative;
    transition: border-color var(--transition-med), box-shadow var(--transition-med);
}

.chart-card.active-panel {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-card), var(--shadow-glow);
}

.chart-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.chart-card-header h2 {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.chart-card-header .badge {
    font-size: 0.68rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    letter-spacing: 0.04em;
}

.badge-freq {
    background: rgba(99,102,241,0.15);
    color: var(--accent-secondary);
}

.badge-time {
    background: rgba(52,211,153,0.15);
    color: var(--accent-green);
}

.badge-conv {
    background: rgba(251,191,36,0.15);
    color: var(--accent-amber);
}

.chart-container {
    position: relative;
    width: 100%;
    height: 220px;
}

.chart-container canvas {
    width: 100% !important;
    height: 100% !important;
}

/* Convergence chart is smaller */
.chart-card.convergence-card .chart-container {
    height: 140px;
}

/* ---------- Arrow Overlays ---------- */
.arrow-overlay {
    position: fixed;
    z-index: 200;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.arrow-overlay.visible {
    opacity: 1;
    animation: arrowPulse 0.6s ease;
}

@keyframes arrowPulse {
    0% { opacity: 0; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1.05); }
    100% { opacity: 1; transform: scale(1); }
}

.arrow-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--accent-primary);
    color: white;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 12px;
    white-space: nowrap;
    box-shadow: 0 2px 12px rgba(99,102,241,0.4);
}

/* ---------- Micro-step Label ---------- */
.step-label-banner {
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(99,102,241,0.9);
    backdrop-filter: blur(8px);
    color: white;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 6px 20px;
    border-radius: 20px;
    z-index: 300;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
    box-shadow: 0 4px 20px rgba(99,102,241,0.4);
}

.step-label-banner.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    animation: bannerSlide 0.35s ease;
}

@keyframes bannerSlide {
    from { opacity: 0; transform: translateX(-50%) translateY(-10px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ---------- Speed Slider Section ---------- */
.speed-control {
    display: flex;
    align-items: center;
    gap: 8px;
}

.speed-control label {
    font-size: 0.78rem;
    color: var(--text-secondary);
    white-space: nowrap;
    font-weight: 500;
}

.speed-control input[type="range"] {
    flex: 1;
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .app-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }
    .sidebar {
        border-right: none;
        border-bottom: 1px solid var(--border-subtle);
        max-height: 280px;
    }
}

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

.chart-card {
    animation: fadeIn 0.4s ease both;
}

.chart-card:nth-child(2) { animation-delay: 0.08s; }
.chart-card:nth-child(3) { animation-delay: 0.16s; }

/* ---------- Tooltip ---------- */
.drag-hint {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-style: italic;
    margin-top: 4px;
}

/* ---------- Header Title / DOI ---------- */
.header-title {
    display: flex;
    align-items: baseline;
    gap: 12px;
}

.doi-link {
    font-size: 0.8rem;
    color: var(--accent-tertiary);
    text-decoration: none;
    font-family: 'JetBrains Mono', monospace;
    opacity: 0.8;
    transition: opacity var(--transition-fast);
}

.doi-link:hover {
    opacity: 1;
    text-decoration: underline;
}

/* ---------- Coefficients Panel ---------- */
.coeffs-panel {
    margin-top: 4px;
}

.coeffs-list {
    max-height: 200px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: var(--text-primary);
    padding-right: 4px;
}

.coeffs-list::-webkit-scrollbar { width: 4px; }
.coeffs-list::-webkit-scrollbar-track { background: transparent; }
.coeffs-list::-webkit-scrollbar-thumb { background: var(--border-subtle); border-radius: 2px; }

.coeff-item {
    display: flex;
    justify-content: space-between;
    padding: 3px 6px;
    background: rgba(99,102,241,0.05);
    border-radius: 4px;
}
.coeff-item:nth-child(even) {
    background: rgba(99,102,241,0.02);
}
.coeff-index {
    color: var(--text-muted);
}
.coeff-value {
    color: var(--accent-green);
}
