/* ==========================================================================
   FabricLab — Digital Material Studio Design System
   Aesthetic: High-End Computational Material Laboratory & Creative Studio
   Layout: Responsive Natural Full-Width Web Composition (min(92vw, 1560px))
   ========================================================================== */

:root {
    /* Warm Obsidian & Deep Graphite Surfaces */
    --bg-base: #09090b;
    --bg-surface: #101014;
    --bg-panel: rgba(16, 16, 20, 0.92);
    --bg-card: #14141a;
    --bg-card-hover: #1c1c24;
    --bg-elevated: #22222c;

    /* Subtle Neutral Hairline Borders */
    --border-subtle: rgba(255, 255, 255, 0.07);
    --border-medium: rgba(255, 255, 255, 0.14);
    --border-strong: rgba(255, 255, 255, 0.28);
    --border-accent: #e07a5f;

    /* Editorial Typography Hierarchy */
    --text-primary: #f4f4f7;
    --text-secondary: #9a9aa6;
    --text-muted: #626270;
    --text-dim: #3e3e48;

    /* Restrained Studio Accents */
    --accent-primary: #e07a5f;
    --accent-warm: #e29578;
    --accent-amber: #d97706;
    --accent-cyan: #38bdf8;
    --accent-emerald: #10b981;

    /* Typography */
    --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

    /* Spacing & Geometry */
    --topbar-height: 54px;
    --controlbar-height: 44px;
    --radius-xs: 3px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
}

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

html, body {
    width: 100%;
    min-height: 100%;
    background-color: var(--bg-base);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 13px;
    letter-spacing: -0.01em;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* Only lock scrolling in the interactive 3D Laboratory */
html.in-laboratory, body.in-laboratory {
    height: 100vh;
    overflow: hidden;
}

#app-root {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: 100vh;
    position: relative;
    background-color: var(--bg-base);
}

.app-content-container {
    flex: 1;
    position: relative;
    width: 100%;
    display: flex;
    flex-direction: column;
}

/* ==========================================================================
   MINIMAL HAIRLINE SCROLLBARS
   ========================================================================== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-xs);
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.12) transparent;
}

/* ==========================================================================
   TOP BAR (Desktop + Mobile Responsive)
   ========================================================================== */
.top-bar {
    height: var(--topbar-height);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 clamp(16px, 4vw, 56px);
    z-index: 100;
    flex-shrink: 0;
    position: sticky;
    top: 0;
}

.brand-section {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-logo {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--text-primary);
    text-transform: uppercase;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

.brand-badge {
    font-size: 9px;
    font-family: var(--font-mono);
    color: var(--text-muted);
    letter-spacing: 0.06em;
    border: 1px solid var(--border-subtle);
    padding: 1px 6px;
    border-radius: var(--radius-xs);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 4px;
}

.nav-item {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.02em;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: color 0.15s ease, background 0.15s ease;
    white-space: nowrap;
}

.nav-item:hover {
    color: var(--text-primary);
}

.nav-item.active {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.06);
    font-weight: 600;
}

.status-section {
    display: flex;
    align-items: center;
    gap: 8px;
}

.webgpu-status-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent-emerald);
}

/* ==========================================================================
   BUTTONS & TACTILE CONTROLS
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 18px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    border: 1px solid transparent;
    text-decoration: none;
    touch-action: manipulation;
}

.btn-primary {
    background: #f4f4f7;
    color: #09090b;
    font-weight: 600;
}
.btn-primary:hover {
    background: #ffffff;
    transform: translateY(-1px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
}
.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border-color: var(--border-medium);
}

.btn-sm {
    padding: 6px 10px;
    font-size: 11px;
}

/* ==========================================================================
   NATURAL RESPONSIVE FULL-WIDTH PAGE CONTAINER
   ========================================================================== */
.page-screen {
    width: min(92vw, 1560px);
    margin: 0 auto;
    padding: clamp(24px, 4vw, 64px) 0 88px 0;
    display: flex;
    flex-direction: column;
    gap: 36px;
    flex: 1;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 20px;
    width: 100%;
    flex-wrap: wrap;
    gap: 16px;
}

.page-title {
    font-size: clamp(22px, 3.5vw, 28px);
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--text-primary);
}

.page-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 6px;
    line-height: 1.5;
}

/* ==========================================================================
   LABORATORY WORKSTATION (Dedicated Full Viewport Workspace)
   ========================================================================== */
.main-view-container {
    width: 100%;
    height: calc(100vh - var(--topbar-height));
    position: relative;
    overflow: hidden;
    background: #09090b;
}

.lab-viewport-container {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    touch-action: none;
}

canvas#simulation-canvas {
    touch-action: none;
}

.dock-panel {
    position: absolute;
    top: 24px;
    bottom: 74px;
    width: 290px;
    background: var(--bg-panel);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    z-index: 20;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(20px);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.dock-left {
    left: 24px;
}

.dock-right {
    right: 24px;
}

.dock-header {
    height: 42px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-subtle);
}

.dock-title {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.dock-tabs {
    display: flex;
    gap: 4px;
}

.dock-tab-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 11px;
    padding: 4px 8px;
    border-radius: var(--radius-xs);
    cursor: pointer;
    font-weight: 500;
}

.dock-tab-btn.active {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

.dock-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.dock-close-btn {
    display: none;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 16px;
    cursor: pointer;
    padding: 2px 6px;
}

/* MOBILE TOGGLE PILLS FOR LAB */
.mobile-dock-toggles {
    display: none;
    position: absolute;
    top: 14px;
    left: 14px;
    right: 14px;
    justify-content: space-between;
    z-index: 25;
    pointer-events: none;
}

.mobile-dock-toggles button {
    pointer-events: auto;
    background: var(--bg-panel);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-subtle);
    box-shadow: 0 8px 24px rgba(0,0,0,0.6);
}

.dock-backdrop {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 18;
}

/* CONTROL GROUPS */
.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.group-header {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 6px;
}

.control-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.control-label {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-secondary);
}

.control-value {
    font-family: var(--font-mono);
    color: var(--text-primary);
    font-size: 11px;
}

/* SLIDERS */
.slider-input {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-xs);
    outline: none;
    cursor: pointer;
}

.slider-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: #f4f4f7;
    border-radius: 50%;
    cursor: pointer;
}

/* MATERIAL SELECTOR CARDS */
.material-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
}

.material-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.02);
    cursor: pointer;
    transition: all 0.12s ease;
}

.material-card:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--border-medium);
}

.material-card.active {
    background: rgba(224, 122, 95, 0.1);
    border-color: var(--accent-primary);
}

.material-color-chip {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.material-card-title {
    font-weight: 600;
    font-size: 12px;
    color: var(--text-primary);
}

.material-card-meta {
    font-size: 10px;
    color: var(--text-muted);
}

/* METRICS */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
}

.metric-tile {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.metric-name {
    font-size: 10px;
    color: var(--text-muted);
}

.metric-val {
    font-size: 15px;
    font-weight: 600;
    font-family: var(--font-mono);
    color: var(--text-primary);
}

/* SPARKLINE */
.sparkline-canvas {
    width: 100%;
    height: 50px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xs);
    display: block;
}

/* FLOATING BOTTOM CONTROL BAR */
.bottom-control-bar {
    position: absolute;
    bottom: 18px;
    left: 50%;
    transform: translateX(-50%);
    height: var(--controlbar-height);
    background: var(--bg-panel);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-subtle);
    border-radius: 30px;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 14px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6);
    max-width: calc(100vw - 24px);
}

.control-separator {
    width: 1px;
    height: 16px;
    background: var(--border-subtle);
    margin: 0 4px;
    flex-shrink: 0;
}

/* VIEWPORT OVERLAY CONTROLS */
.viewport-overlay {
    position: absolute;
    top: 18px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 6px;
    background: var(--bg-panel);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-subtle);
    border-radius: 20px;
    padding: 4px 6px;
    z-index: 10;
    max-width: calc(100vw - 24px);
    overflow-x: auto;
    scrollbar-width: none;
}
.viewport-overlay::-webkit-scrollbar {
    display: none;
}

.overlay-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 5px 10px;
    border-radius: 14px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.12s ease;
    white-space: nowrap;
}

.overlay-btn:hover {
    color: var(--text-primary);
}

.overlay-btn.active {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

/* DATA TABLES & SCROLLABLE WRAPPER */
.table-responsive-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    text-align: left;
    min-width: 280px;
}

.data-table th {
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-subtle);
    white-space: nowrap;
}

.data-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    white-space: nowrap;
}

.data-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
    color: var(--text-primary);
}

/* MODALS */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(12px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal-card {
    width: 520px;
    max-width: 100%;
    max-height: 90vh;
    background: var(--bg-surface);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.9);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    overflow-y: auto;
}

.modal-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    background: rgba(0, 0, 0, 0.2);
}

.text-input {
    width: 100%;
    background: #09090b;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 8px 12px;
    font-size: 12px;
    outline: none;
}

.text-input:focus {
    border-color: var(--accent-primary);
}

/* ONBOARDING */
.onboarding-card {
    position: fixed;
    bottom: 24px;
    left: 24px;
    width: min(320px, calc(100vw - 48px));
    background: var(--bg-panel);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    padding: 16px 18px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.8);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    backdrop-filter: blur(20px);
}

/* ==========================================================================
   COMPREHENSIVE RESPONSIVE MEDIA QUERIES
   ========================================================================== */

/* TABLETS & SMALL DESKTOPS (<= 992px) */
@media (max-width: 992px) {
    .page-screen {
        width: calc(100vw - 40px);
        padding-top: 28px;
    }
}

/* PHONES & TABLETS (<= 768px) */
@media (max-width: 768px) {
    :root {
        --topbar-height: 54px;
    }

    .top-bar {
        height: 54px;
        padding: 0 16px;
    }

    .desktop-nav, .desktop-only {
        display: none !important;
    }

    .mobile-hamburger-btn {
        display: inline-flex !important;
    }

    .page-screen {
        width: calc(100vw - 28px);
        padding-top: 20px;
        gap: 28px;
    }

    /* HOME HERO STACKING */
    .hero-split-grid {
        grid-template-columns: 1fr !important;
        gap: 32px !important;
    }

    /* COMPARISON PAGE STACKING */
    .comparison-grid {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }

    /* LABORATORY RESPONSIVE DRAWER */
    .mobile-dock-toggles {
        display: flex;
    }

    .dock-close-btn {
        display: block;
    }

    .dock-panel {
        top: 60px;
        bottom: 80px;
        width: min(320px, calc(100vw - 32px));
        z-index: 50;
        box-shadow: 0 24px 64px rgba(0,0,0,0.9);
    }

    .dock-left {
        left: 16px;
        transform: translateX(calc(-100% - 30px));
    }

    .dock-right {
        right: 16px;
        transform: translateX(calc(100% + 30px));
    }

    .dock-panel.dock-mobile-open {
        transform: translateX(0) !important;
    }

    .dock-backdrop.dock-backdrop-active {
        display: block;
    }

    .viewport-overlay {
        top: 56px;
        padding: 3px 4px;
    }

    .bottom-control-bar {
        bottom: 12px;
        height: 40px;
        gap: 4px;
        padding: 0 10px;
    }
    .bottom-control-bar .speed-btn {
        padding: 4px 6px;
        font-size: 10px;
    }
}

/* COMPACT PHONES (<= 480px) */
@media (max-width: 480px) {
    .page-screen {
        width: calc(100vw - 24px);
    }
    .page-title {
        font-size: 22px;
    }
    .btn {
        padding: 8px 14px;
    }
}

/* ==========================================================================
   MOBILE HAMBURGER DRAWER
   ========================================================================== */
.mobile-hamburger-btn {
    display: none;
    font-size: 16px;
    padding: 4px 10px;
    align-items: center;
    justify-content: center;
}

.mobile-nav-drawer {
    display: none;
    position: fixed;
    top: 54px;
    left: 0;
    width: 100vw;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-medium);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.9);
    flex-direction: column;
    padding: 14px 16px;
    gap: 8px;
    z-index: 150;
    backdrop-filter: blur(24px);
}

.mobile-nav-drawer.open {
    display: flex;
}

.mobile-nav-item {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    text-align: left;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.mobile-nav-item:hover, .mobile-nav-item.active {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--border-subtle);
    color: var(--text-primary);
    font-weight: 600;
}

