/* Data Science Lab – module CSS */
:root {
    --ds-primary: #0ea5e9;
    --ds-primary-dark: #0284c7;
    --ds-accent: #8b5cf6;
    --ds-bg: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    --ds-card: rgba(255,255,255,0.97);
    --ds-text: #1e293b;
    --ds-muted: #64748b;
    --ds-border: #e2e8f0;
    --ds-radius: 14px;
}

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

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--ds-bg);
    min-height: 100vh;
    color: var(--ds-text);
}

/* Page wrapper */
.ds-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
}

/* ── Header / navbar ───────────────────────────────────────────────────── */
.ds-header {
    width: 100%;
    max-width: 1280px;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 50%, #0ea5e9 100%);
    border-radius: var(--ds-radius);
    padding: 18px 24px;
    margin-bottom: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.25);
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.ds-header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.ds-title {
    color: #fff;
    font-size: 1.7rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.ds-title-icon {
    font-size: 1.5rem;
}

.ds-home-btn {
    color: #cbd5e1;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.2);
    transition: all 0.2s ease;
}

.ds-home-btn:hover {
    background: rgba(255,255,255,0.15);
    color: #fff;
}

/* Hamburger toggle – hidden on desktop, visible on small phones */
.ds-menu-toggle {
    display: none;
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.25);
    color: #e2e8f0;
    font-size: 1.4rem;
    padding: 4px 10px;
    border-radius: 8px;
    cursor: pointer;
    line-height: 1;
}

/* Category nav bar */
.ds-categories {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.ds-cat-btn {
    padding: 8px 18px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.25);
    background: rgba(255,255,255,0.08);
    color: #e2e8f0;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
    backdrop-filter: blur(6px);
    position: relative;
    overflow: hidden;
}

.ds-cat-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--ds-primary), var(--ds-accent));
    opacity: 0;
    transition: opacity 0.25s ease;
    z-index: -1;
}

.ds-cat-btn:hover,
.ds-cat-btn.active {
    color: #fff;
    border-color: rgba(255,255,255,0.5);
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(14, 165, 233, 0.4);
}

.ds-cat-btn:hover::before,
.ds-cat-btn.active::before {
    opacity: 1;
}

/* ── Main content card ─────────────────────────────────────────────────── */
.ds-main {
    width: 100%;
    max-width: 1280px;
    background: var(--ds-card);
    border-radius: var(--ds-radius);
    box-shadow: 0 8px 32px rgba(0,0,0,0.12);
    min-height: 500px;
    overflow: hidden;
}

/* Section panels */
.ds-section {
    display: none;
    padding: 28px;
    animation: dsFadeIn 0.3s ease;
}

.ds-section.active {
    display: block;
}

@keyframes dsFadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Feature buttons inside a section */
.ds-feature-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
}

.ds-feature-btn {
    padding: 8px 18px;
    border-radius: 8px;
    border: 1px solid var(--ds-border);
    background: #f8fafc;
    color: var(--ds-text);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ds-feature-btn:hover {
    background: var(--ds-primary);
    color: #fff;
    border-color: var(--ds-primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3);
}

.ds-feature-btn.active {
    background: var(--ds-primary);
    color: #fff;
    border-color: var(--ds-primary-dark);
}

/* Controls row */
.ds-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: flex-end;
    margin-bottom: 18px;
    padding: 18px 22px;
    background: #f1f5f9;
    border-radius: 10px;
}

.ds-controls label {
    display: flex;
    flex-direction: column;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--ds-muted);
    gap: 5px;
}

.ds-controls input[type="number"],
.ds-controls input[type="text"],
.ds-controls select {
    padding: 9px 12px;
    border-radius: 6px;
    border: 1px solid var(--ds-border);
    font-size: 0.95rem;
    width: 110px;
    transition: border-color 0.2s;
}

.ds-controls input:focus,
.ds-controls select:focus {
    border-color: var(--ds-primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(14,165,233,0.15);
}

.ds-run-btn {
    padding: 10px 26px;
    border-radius: 8px;
    border: none;
    background: linear-gradient(135deg, var(--ds-primary), var(--ds-accent));
    color: #fff;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3);
}

.ds-run-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(14, 165, 233, 0.5);
}

.ds-run-btn:active {
    transform: translateY(0);
}

/* Plot container */
.ds-plot {
    width: 100%;
    min-height: 400px;
    border-radius: 10px;
    overflow: hidden;
}

.ds-plot-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.ds-plot-row .ds-plot {
    flex: 1 1 400px;
}

/* Stats results table */
.ds-stats-table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    font-size: 0.9rem;
}

.ds-stats-table th,
.ds-stats-table td {
    padding: 8px 14px;
    text-align: left;
    border-bottom: 1px solid var(--ds-border);
}

.ds-stats-table th {
    background: #f1f5f9;
    font-weight: 700;
    color: var(--ds-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ds-stats-table td {
    font-variant-numeric: tabular-nums;
}

/* Info / status */
.ds-info {
    padding: 10px 16px;
    background: #eff6ff;
    border-left: 4px solid var(--ds-primary);
    border-radius: 0 8px 8px 0;
    margin: 12px 0;
    font-size: 0.85rem;
    color: #1e40af;
}

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

/* Wide inputs (frequencies, data) */
.ds-input-wide {
    width: 180px;
}

/* ── Responsive ────────────────────────────────────────────────────────── */

/* Tablet & small laptop */
@media (max-width: 900px) {
    .ds-plot-row { flex-direction: column; }
    .ds-plot-row .ds-plot { flex: 1 1 auto; }
    .ds-controls { flex-wrap: wrap; }
}

/* Mobile – portrait phones */
@media (max-width: 768px) {
    .ds-page { padding: 8px; }

    .ds-header {
        padding: 12px 14px;
        border-radius: 10px;
        gap: 10px;
    }

    .ds-title { font-size: 1.2rem; gap: 6px; }
    .ds-title-icon { font-size: 1.2rem; }

    .ds-home-btn {
        font-size: 0.75rem;
        padding: 5px 10px;
    }

    /* Category nav – horizontal scroll on medium mobile */
    .ds-categories {
        gap: 6px;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 4px;
    }
    .ds-categories::-webkit-scrollbar { display: none; }

    .ds-cat-btn {
        padding: 8px 14px;
        font-size: 0.78rem;
        min-height: 40px;
        white-space: nowrap;
        flex-shrink: 0;
    }

    /* Main content */
    .ds-main { border-radius: 10px; min-height: auto; }

    .ds-section { padding: 14px 12px; }

    /* Feature buttons – scrollable row */
    .ds-feature-grid {
        gap: 8px;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 4px;
    }
    .ds-feature-grid::-webkit-scrollbar { display: none; }

    .ds-feature-btn {
        padding: 8px 14px;
        font-size: 0.82rem;
        min-height: 40px;
        white-space: nowrap;
        flex-shrink: 0;
    }

    /* Controls – stack vertically */
    .ds-controls {
        flex-direction: column;
        gap: 10px;
        padding: 12px;
        border-radius: 8px;
    }

    .ds-controls label {
        width: 100%;
        font-size: 0.8rem;
    }

    .ds-controls input[type="number"],
    .ds-controls input[type="text"],
    .ds-controls select {
        width: 100%;
        min-height: 44px;
        padding: 10px 12px;
        font-size: 1rem;
        border-radius: 8px;
        -webkit-appearance: none;
        appearance: none;
    }

    .ds-input-wide { width: 100%; }

    .ds-run-btn {
        width: 100%;
        min-height: 48px;
        font-size: 1rem;
        padding: 12px 20px;
        border-radius: 10px;
        -webkit-tap-highlight-color: transparent;
    }

    /* Plots – full width, reduced height */
    .ds-plot {
        min-height: 280px;
        border-radius: 8px;
    }

    .ds-plot-row {
        flex-direction: column;
        gap: 12px;
    }

    .ds-plot-row .ds-plot {
        flex: 1 1 auto;
        min-height: 260px;
    }

    /* Stats table */
    .ds-stats-table { font-size: 0.82rem; }
    .ds-stats-table th,
    .ds-stats-table td { padding: 8px 10px; }

    /* Info box */
    .ds-info { font-size: 0.82rem; padding: 10px 12px; }
}

/* Small phones (≤480px) – toggle menu layout */
@media (max-width: 480px) {
    .ds-page { padding: 4px; }

    .ds-header {
        padding: 10px 12px;
        border-radius: 8px;
        margin-bottom: 10px;
    }

    .ds-header-top {
        flex-wrap: wrap;
        gap: 6px;
    }

    .ds-title { font-size: 1.05rem; }

    .ds-home-btn {
        font-size: 0.7rem;
        padding: 4px 8px;
        order: 2;
    }

    /* Menu toggle visible */
    .ds-menu-toggle {
        display: block;
        order: 3;
    }

    /* Category nav becomes a toggleable column */
    .ds-categories {
        display: none;
        flex-direction: column;
        flex-wrap: wrap;
        overflow-x: visible;
    }

    .ds-categories.open {
        display: flex;
    }

    .ds-cat-btn {
        width: 100%;
        text-align: center;
        min-height: 44px;
        padding: 10px 14px;
        font-size: 0.85rem;
    }

    /* Feature buttons – wrap instead of scroll */
    .ds-feature-grid {
        flex-wrap: wrap;
        overflow-x: visible;
    }

    .ds-feature-btn {
        flex: 1 1 calc(50% - 4px);
        min-width: 0;
        white-space: normal;
        text-align: center;
        min-height: 44px;
    }

    /* Section padding tight */
    .ds-section { padding: 10px 8px; }

    .ds-main { border-radius: 8px; }

    /* Plots */
    .ds-plot { min-height: 240px; }
    .ds-plot-row .ds-plot { min-height: 220px; }
    .ds-plot-row { gap: 8px; }

    /* Controls */
    .ds-controls { padding: 10px; }

    .ds-run-btn {
        min-height: 50px;
        font-size: 1.05rem;
    }

    /* Stats table scroll */
    .ds-stats-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* Landscape phone */
@media (max-width: 900px) and (orientation: landscape) {
    .ds-page { padding: 6px; }
    .ds-header { padding: 10px 14px; margin-bottom: 10px; }
    .ds-section { padding: 12px; }

    /* Allow side-by-side plots again in landscape */
    .ds-plot-row {
        flex-direction: row;
        gap: 10px;
    }
    .ds-plot-row .ds-plot {
        flex: 1 1 45%;
        min-height: 220px;
    }

    .ds-controls {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .ds-controls label { width: auto; }
    .ds-controls input[type="number"],
    .ds-controls input[type="text"],
    .ds-controls select { width: 120px; }

    .ds-run-btn { width: auto; }
}

/* ── NEW FEATURE STYLES ───────────────────────────────────────────────── */

/* Secondary/ghost run button */
.ds-run-btn--secondary {
    background: #f1f5f9;
    color: var(--ds-primary-dark);
    border: 1.5px solid var(--ds-primary);
    box-shadow: none;
}
.ds-run-btn--secondary:hover {
    background: var(--ds-primary);
    color: #fff;
}
.ds-run-btn--secondary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Result card (hypothesis test, bootstrap, outlier) */
.ds-result-card {
    border-radius: 12px;
    border-left: 5px solid var(--ds-primary);
    background: #f8faff;
    padding: 16px 20px;
    margin: 14px 0;
    font-size: 0.88rem;
}

.ds-result-card--reject {
    border-left-color: #10b981;
    background: #f0fdf4;
}
.ds-result-card--fail {
    border-left-color: #f59e0b;
    background: #fffbeb;
}
.ds-result-card--info {
    border-left-color: var(--ds-primary);
    background: #f0f9ff;
}

.ds-result-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    font-size: 0.95rem;
}

.ds-result-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.3px;
}
.ds-result-badge--reject { background: #10b981; color: #fff; }
.ds-result-badge--fail   { background: #f59e0b; color: #fff; }
.ds-result-badge--info   { background: var(--ds-primary); color: #fff; }

.ds-result-body {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 20px;
    color: var(--ds-muted);
    font-variant-numeric: tabular-nums;
    margin-bottom: 10px;
}

.ds-result-body strong { color: var(--ds-text); }

.ds-result-interp {
    font-size: 0.85rem;
    color: #334155;
    padding-top: 8px;
    border-top: 1px solid #e2e8f0;
    font-weight: 500;
}

/* Canvas wrapper (Fourier/Mandelbrot) */
.ds-canvas-wrap {
    overflow: hidden;
    border-radius: 12px;
    background: #0f172a;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px 0;
}

.ds-canvas-wrap canvas {
    max-width: 100%;
    height: auto;
}

/* Hint text */
.ds-hint {
    font-size: 0.8rem;
    color: var(--ds-muted);
    margin: 6px 0 10px;
    padding: 0;
}

/* ── Filter view toggles ── */
.ds-filter-toggles {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 0 12px;
    flex-wrap: wrap;
}

.ds-toggle-btn {
    padding: 6px 14px;
    border-radius: 8px;
    border: 1.5px solid var(--ds-border);
    background: var(--ds-card);
    color: var(--ds-text);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    min-height: 38px;
}

.ds-toggle-btn:hover {
    border-color: var(--ds-primary);
    background: rgba(14, 165, 233, 0.08);
}

.ds-toggle-btn.active {
    background: var(--ds-primary);
    color: #fff;
    border-color: var(--ds-primary);
    box-shadow: 0 2px 8px rgba(14, 165, 233, 0.25);
}

.ds-toggle-separator {
    width: 1px;
    height: 24px;
    background: var(--ds-border);
    margin: 0 4px;
    flex-shrink: 0;
}

#filter-stack-view {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#filter-stack-view .ds-plot {
    min-height: 280px;
}

#filter-fft-stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#filter-fft-stack .ds-plot {
    min-height: 280px;
}

/* Responsive canvas */
@media (max-width: 768px) {
    .ds-canvas-wrap { padding: 6px 0; border-radius: 8px; }
    .ds-result-body { flex-direction: column; gap: 4px; }
    .ds-result-card { padding: 12px 14px; }
    
    .ds-filter-toggles {
        gap: 4px;
        padding: 6px 0 8px;
    }
    .ds-toggle-btn {
        padding: 6px 10px;
        font-size: 0.78rem;
        min-height: 44px;
    }
    .ds-toggle-separator {
        height: 20px;
        margin: 0 2px;
    }
    #filter-stack-view .ds-plot {
        min-height: 220px;
    }
    #filter-fft-stack .ds-plot {
        min-height: 220px;
    }
}


