/* ============================================
   EZ VIRTUAL TOOLS - 2026 PREMIUM MOBILE UI
   Modern, fluid, impressive design
   ============================================ */

/* ========================================
   CSS VARIABLES - REFINED PALETTE
   ======================================== */
:root {
    /* Layout */
    --mobile-header-height: 60px;
    --mobile-bottom-nav-height: 68px;
    --mobile-safe-bottom: env(safe-area-inset-bottom, 0px);
    --touch-target: 48px;

    /* Spacing - 8pt grid */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;

    /* Radius - Modern rounded */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-2xl: 24px;
    --radius-full: 9999px;

    /* Colors - Refined dark */
    --glass-bg: rgba(18, 18, 26, 0.85);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-highlight: rgba(255, 255, 255, 0.05);
    --surface-1: rgba(255, 255, 255, 0.03);
    --surface-2: rgba(255, 255, 255, 0.06);
    --surface-3: rgba(255, 255, 255, 0.09);

    /* Accent glow */
    --accent-glow: rgba(255, 107, 0, 0.15);
    --accent-glow-strong: rgba(255, 107, 0, 0.25);

    /* Shadows - Layered depth */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px var(--accent-glow);

    /* Animation */
    --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-out-back: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-spring: cubic-bezier(0.175, 0.885, 0.32, 1.1);
}

/* ========================================
   DESKTOP - Ensure mobile elements stay hidden
   ======================================== */
@media (min-width: 769px) {
    /* Hide mobile-specific elements on desktop */
    .bottom-nav,
    .mobile-fab,
    .mobile-action-bar {
        display: none !important;
    }

    /* Keep menu off-screen on desktop */
    .mobile-menu {
        right: -320px !important;
        display: none !important;
    }

    .mobile-menu-overlay {
        display: none !important;
    }

    /* Ensure body scroll is never locked on desktop */
    body {
        overflow: auto !important;
    }

    body.menu-open {
        overflow: auto !important;
    }
}

/* ========================================
   GLOBAL MOBILE ENHANCEMENTS
   ======================================== */
@media (max-width: 768px) {
    /* Smooth scrolling */
    html {
        scroll-behavior: smooth;
    }

    /* Better text rendering */
    body {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
        text-rendering: optimizeLegibility;
        padding-top: var(--mobile-header-height);
        /* Account for bottom nav + action bar */
        padding-bottom: calc(var(--mobile-bottom-nav-height) + var(--mobile-safe-bottom) + 72px);
    }

    /* Selection color */
    ::selection {
        background: var(--accent-glow-strong);
        color: white;
    }
}

/* ========================================
   HEADER - GLASSMORPHISM PREMIUM
   ======================================== */
@media (max-width: 768px) {
    .header {
        position: fixed !important;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1000;
        height: var(--mobile-header-height);
        padding: 0 var(--space-4) !important;
        background: var(--glass-bg) !important;
        backdrop-filter: blur(20px) saturate(180%);
        -webkit-backdrop-filter: blur(20px) saturate(180%);
        border-bottom: 1px solid var(--glass-border) !important;
        display: flex !important;
        align-items: center;
        justify-content: space-between;
        transition: transform 0.3s var(--ease-out-expo),
                    background 0.3s ease;
    }

    .header.scrolled {
        background: rgba(10, 10, 15, 0.95) !important;
        box-shadow: var(--shadow-md);
    }

    /* Hide desktop nav */
    .nav-links,
    .nav,
    .header nav:not(.mobile-nav) {
        display: none !important;
    }

    /* Logo styling */
    .logo {
        font-size: 1.1rem !important;
        font-weight: 700;
        letter-spacing: -0.02em;
    }

    .logo span {
        background: linear-gradient(135deg, #ff6b00, #ff8533);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        background-clip: text;
    }
}

/* ========================================
   BACK BUTTON - MODERN PILL STYLE
   ======================================== */
.back-btn {
    display: none;
}

@media (max-width: 768px) {
    .back-btn {
        display: inline-flex !important;
        align-items: center;
        gap: var(--space-2);
        padding: var(--space-2) var(--space-4);
        background: var(--surface-2);
        border: 1px solid var(--glass-border);
        border-radius: var(--radius-full);
        color: rgba(255, 255, 255, 0.8);
        font-size: 13px;
        font-weight: 500;
        text-decoration: none;
        cursor: pointer;
        transition: all 0.2s var(--ease-out-expo);
        -webkit-tap-highlight-color: transparent;
    }

    .back-btn:active {
        transform: scale(0.95);
        background: var(--surface-3);
    }

    .back-btn::before {
        content: '←';
        font-size: 14px;
        transition: transform 0.2s var(--ease-out-expo);
    }

    .back-btn:active::before {
        transform: translateX(-2px);
    }
}

/* ========================================
   BOTTOM NAVIGATION - FLOATING DOCK
   ======================================== */
.bottom-nav {
    display: none;
}

@media (max-width: 768px) {
    .bottom-nav {
        display: flex !important;
        position: fixed;
        bottom: var(--space-4);
        left: var(--space-4);
        right: var(--space-4);
        height: var(--mobile-bottom-nav-height);
        padding-bottom: var(--mobile-safe-bottom);
        background: var(--glass-bg);
        backdrop-filter: blur(20px) saturate(180%);
        -webkit-backdrop-filter: blur(20px) saturate(180%);
        border: 1px solid var(--glass-border);
        border-radius: var(--radius-2xl);
        box-shadow: var(--shadow-lg),
                    0 0 0 1px rgba(255, 255, 255, 0.05) inset;
        z-index: 900;
        justify-content: space-around;
        align-items: center;
        animation: slideUp 0.5s var(--ease-out-expo);
    }

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

    .bottom-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        padding: var(--space-2) var(--space-4);
        color: rgba(255, 255, 255, 0.5);
        text-decoration: none;
        font-size: 10px;
        font-weight: 600;
        letter-spacing: 0.02em;
        min-width: 56px;
        min-height: var(--touch-target);
        border-radius: var(--radius-lg);
        transition: all 0.25s var(--ease-out-expo);
        -webkit-tap-highlight-color: transparent;
        background: transparent;
        border: none;
        cursor: pointer;
        font-family: inherit;
        position: relative;
    }

    .bottom-nav-item::before {
        content: '';
        position: absolute;
        inset: 4px;
        border-radius: var(--radius-md);
        background: var(--accent);
        opacity: 0;
        transform: scale(0.8);
        transition: all 0.25s var(--ease-out-expo);
        z-index: -1;
    }

    .bottom-nav-item.active {
        color: white;
    }

    .bottom-nav-item.active::before {
        opacity: 1;
        transform: scale(1);
    }

    .bottom-nav-item:active {
        transform: scale(0.9);
    }

    .bottom-nav-icon {
        width: 24px;
        height: 24px;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: transform 0.25s var(--ease-spring);
    }

    .bottom-nav-item.active .bottom-nav-icon {
        transform: scale(1.1);
    }

    .bottom-nav-icon svg {
        width: 22px;
        height: 22px;
        stroke: currentColor;
        fill: none;
        stroke-width: 1.75;
    }

    .bottom-nav-label {
        text-transform: uppercase;
        letter-spacing: 0.05em;
        opacity: 0.9;
    }
}

/* ========================================
   SLIDE-OUT MENU - PREMIUM DRAWER
   ======================================== */
.mobile-menu-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 9998;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-menu-overlay.active {
    display: block;
    opacity: 1;
}

.mobile-menu {
    position: fixed;
    top: 0;
    right: -320px;
    width: 300px;
    max-width: 85vw;
    height: 100%;
    background: linear-gradient(180deg, #0d0d12 0%, #0a0a0f 100%);
    border-left: 1px solid var(--glass-border);
    z-index: 9999;
    transition: right 0.4s var(--ease-out-expo);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.mobile-menu.active {
    right: 0;
    box-shadow: -20px 0 60px rgba(0, 0, 0, 0.5);
}

.mobile-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-5);
    border-bottom: 1px solid var(--glass-border);
    position: sticky;
    top: 0;
    background: linear-gradient(180deg, #0d0d12 0%, rgba(13, 13, 18, 0.95) 100%);
    backdrop-filter: blur(10px);
    z-index: 1;
}

.mobile-menu-title {
    font-size: 15px;
    font-weight: 700;
    color: white;
    letter-spacing: -0.01em;
}

.mobile-menu-close {
    background: var(--surface-2);
    border: 1px solid var(--glass-border);
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}

.mobile-menu-close:active {
    transform: scale(0.9);
    background: var(--surface-3);
}

.mobile-menu-close svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

.mobile-menu-nav {
    padding: var(--space-3) 0 120px;
}

.mobile-menu-section {
    padding: var(--space-6) var(--space-5) var(--space-2);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--accent);
}

.mobile-menu-section:first-child {
    padding-top: var(--space-4);
}

.mobile-menu-link {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    color: rgba(255, 255, 255, 0.75);
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    margin: 0 var(--space-2);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.mobile-menu-link:active {
    background: var(--accent-glow);
    border-left-color: var(--accent);
}

.mobile-menu-link.active {
    background: var(--accent-glow);
    border-left-color: var(--accent);
    color: var(--accent);
}

/* ========================================
   FLOATING ACTION BUTTON - MODERN
   ======================================== */
.mobile-fab {
    display: none;
}

@media (max-width: 768px) {
    .mobile-fab {
        display: flex;
        position: fixed;
        bottom: calc(var(--mobile-bottom-nav-height) + var(--mobile-safe-bottom) + 24px);
        right: var(--space-5);
        width: 56px;
        height: 56px;
        background: linear-gradient(135deg, #ff6b00, #ff8533);
        border: none;
        border-radius: var(--radius-xl);
        color: white;
        cursor: pointer;
        z-index: 800;
        box-shadow: var(--shadow-md), var(--shadow-glow);
        transition: all 0.25s var(--ease-out-expo);
        align-items: center;
        justify-content: center;
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-fab:active {
        transform: scale(0.9);
        box-shadow: var(--shadow-sm);
    }

    .mobile-fab svg {
        width: 24px;
        height: 24px;
        stroke: white;
        fill: none;
        stroke-width: 2.5;
    }
}

/* ========================================
   CONTAINER & SPACING
   ======================================== */
@media (max-width: 768px) {
    .container,
    .calc-container,
    .main-container {
        padding: var(--space-4) !important;
    }

    /* Better content spacing */
    .main {
        padding: var(--space-4) 0;
    }
}

/* ========================================
   TYPOGRAPHY - REFINED HIERARCHY
   ======================================== */
@media (max-width: 768px) {
    h1, .page-title {
        font-size: 1.75rem !important;
        font-weight: 800 !important;
        letter-spacing: -0.03em;
        line-height: 1.2;
        margin-bottom: var(--space-2) !important;
    }

    h2 {
        font-size: 1.25rem !important;
        font-weight: 700;
        letter-spacing: -0.02em;
    }

    h3, .card-title, .calc-title {
        font-size: 1rem !important;
        font-weight: 600;
    }

    .subtitle, .page-subtitle {
        font-size: 14px !important;
        color: rgba(255, 255, 255, 0.6);
        line-height: 1.5;
    }

    p {
        font-size: 14px;
        line-height: 1.6;
    }
}

/* ========================================
   CARDS - SIMPLE CLEAN STYLE
   ======================================== */
@media (max-width: 768px) {
    .card,
    .calc-card,
    .tool-card {
        background: linear-gradient(135deg, var(--surface-2), var(--surface-1)) !important;
        border: 1px solid var(--glass-border) !important;
        border-radius: var(--radius-lg) !important;
        padding: var(--space-4) !important;
        margin-bottom: var(--space-4);
        box-shadow: var(--shadow-sm);
    }

    .result-box {
        background: var(--surface-1) !important;
        border: 1px solid var(--glass-border) !important;
        border-radius: var(--radius-md) !important;
        padding: var(--space-3) !important;
    }

    .card-title,
    .calc-title,
    .card > h3:first-child {
        margin-bottom: var(--space-3) !important;
        padding-bottom: var(--space-3) !important;
        border-bottom: 1px solid var(--glass-border);
    }

    .card-header,
    .calc-header {
        padding-bottom: var(--space-3);
        margin-bottom: var(--space-3);
        border-bottom: 1px solid var(--glass-border);
    }
}

/* ========================================
   FORMS - MODERN INPUT STYLE
   ======================================== */
@media (max-width: 768px) {
    /* Form layout */
    .form-row,
    .form-row-3,
    .input-grid,
    .input-row,
    .grid-2,
    .grid-3,
    .grid-4 {
        display: flex !important;
        flex-direction: column !important;
        gap: var(--space-3) !important;
    }

    .form-group,
    .input-group {
        margin-bottom: 0 !important;
    }

    /* Labels */
    label,
    .form-label {
        display: block;
        font-size: 12px !important;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: rgba(255, 255, 255, 0.5);
        margin-bottom: var(--space-2) !important;
    }

    /* Inputs - Premium style */
    input[type="text"],
    input[type="number"],
    input[type="email"],
    input[type="password"],
    input[type="search"],
    select,
    textarea {
        width: 100%;
        font-size: 16px !important; /* Prevents iOS zoom */
        padding: var(--space-4) !important;
        background: var(--surface-1) !important;
        border: 1px solid var(--glass-border) !important;
        border-radius: var(--radius-md) !important;
        color: white !important;
        font-weight: 500;
        transition: all 0.2s ease;
        -webkit-appearance: none;
        appearance: none;
    }

    input:focus,
    select:focus,
    textarea:focus {
        outline: none !important;
        border-color: var(--accent) !important;
        box-shadow: 0 0 0 3px var(--accent-glow) !important;
        background: var(--surface-2) !important;
    }

    input::placeholder {
        color: rgba(255, 255, 255, 0.3);
    }

    /* Select arrow */
    select {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23ffffff' fill-opacity='0.5' d='M6 8L1 3h10z'/%3E%3C/svg%3E") !important;
        background-repeat: no-repeat !important;
        background-position: right var(--space-4) center !important;
        padding-right: var(--space-10) !important;
    }
}

/* ========================================
   BUTTONS - REFINED INTERACTIVE
   ======================================== */
@media (max-width: 768px) {
    .btn,
    button[type="submit"],
    .btn-primary,
    .btn-calculate {
        width: 100%;
        padding: var(--space-4) var(--space-5) !important;
        font-size: 15px !important;
        font-weight: 600;
        border-radius: var(--radius-md) !important;
        border: none;
        cursor: pointer;
        transition: all 0.2s var(--ease-out-expo);
        -webkit-tap-highlight-color: transparent;
        position: relative;
        overflow: hidden;
    }

    .btn-primary,
    .btn-calculate,
    button[type="submit"] {
        background: linear-gradient(135deg, #ff6b00, #ff8533) !important;
        color: white !important;
        box-shadow: var(--shadow-sm), 0 4px 12px var(--accent-glow);
    }

    .btn-primary:active,
    .btn-calculate:active,
    button[type="submit"]:active {
        transform: scale(0.98);
        box-shadow: none;
    }

    .btn-secondary {
        background: var(--surface-2) !important;
        color: white !important;
        border: 1px solid var(--glass-border) !important;
    }

    .btn-secondary:active {
        background: var(--surface-3) !important;
        transform: scale(0.98);
    }

    /* Button row */
    .btn-row,
    .button-row {
        display: flex;
        flex-direction: column;
        gap: var(--space-3);
    }
}

/* ========================================
   TABS - PILL STYLE HORIZONTAL SCROLL
   ======================================== */
@media (max-width: 768px) {
    .tabs,
    .section-tabs,
    .tab-container {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto;
        scrollbar-width: none;
        gap: var(--space-2);
        padding: var(--space-3) var(--space-4);
        margin: 0 calc(-1 * var(--space-4)) var(--space-4);
        -webkit-overflow-scrolling: touch;
    }

    .tabs::-webkit-scrollbar,
    .section-tabs::-webkit-scrollbar {
        display: none;
    }

    .tab,
    .section-tab {
        flex-shrink: 0;
        padding: var(--space-3) var(--space-5) !important;
        font-size: 13px !important;
        font-weight: 600;
        white-space: nowrap;
        border-radius: var(--radius-full) !important;
        background: var(--surface-2) !important;
        border: 1px solid var(--glass-border) !important;
        color: rgba(255, 255, 255, 0.7) !important;
        transition: all 0.2s var(--ease-out-expo);
        cursor: pointer;
    }

    .tab.active,
    .section-tab.active {
        background: linear-gradient(135deg, #ff6b00, #ff8533) !important;
        border-color: transparent !important;
        color: white !important;
        box-shadow: 0 4px 12px var(--accent-glow);
    }

    .tab:active,
    .section-tab:active {
        transform: scale(0.95);
    }
}

/* ========================================
   RESULTS - MODERN DATA DISPLAY
   ======================================== */
@media (max-width: 768px) {
    .results-grid,
    .result-grid {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: var(--space-3) !important;
    }

    .result-item,
    .result-box > div {
        background: var(--surface-1);
        padding: var(--space-4);
        border-radius: var(--radius-md);
        border: 1px solid var(--glass-border);
        text-align: center;
    }

    .result-value {
        font-size: 1.5rem !important;
        font-weight: 800;
        color: var(--accent) !important;
        letter-spacing: -0.02em;
        line-height: 1.2;
    }

    .result-label {
        font-size: 10px !important;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: rgba(255, 255, 255, 0.5);
        margin-top: var(--space-1);
    }

    .result-unit {
        font-size: 12px;
        color: rgba(255, 255, 255, 0.4);
        font-weight: 500;
    }
}

/* ========================================
   TABLES - CLEAN SCROLLABLE
   ======================================== */
@media (max-width: 768px) {
    .table-wrapper,
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 calc(-1 * var(--space-4));
        padding: 0 var(--space-4);
        scrollbar-width: none;
    }

    .table-wrapper::-webkit-scrollbar {
        display: none;
    }

    table {
        min-width: 500px;
        font-size: 13px;
        border-collapse: separate;
        border-spacing: 0;
    }

    th {
        background: var(--surface-2);
        font-weight: 600;
        text-transform: uppercase;
        font-size: 11px;
        letter-spacing: 0.05em;
        padding: var(--space-3) var(--space-4);
        border-bottom: 1px solid var(--glass-border);
        position: sticky;
        top: 0;
    }

    td {
        padding: var(--space-3) var(--space-4);
        border-bottom: 1px solid var(--glass-border);
    }

    tr:last-child td {
        border-bottom: none;
    }
}

/* ========================================
   HERO SECTIONS
   ======================================== */
@media (max-width: 768px) {
    .hero,
    .calc-header,
    .page-header {
        text-align: center;
        padding: var(--space-6) var(--space-4) !important;
        margin: calc(-1 * var(--space-4));
        margin-bottom: var(--space-5);
        border-radius: 0 0 var(--radius-xl) var(--radius-xl);
    }

    .hero-title {
        font-size: 1.75rem !important;
        line-height: 1.2;
    }

    .hero-stats,
    .stats-grid {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: var(--space-2) !important;
        margin-top: var(--space-4);
    }

    .stat-card,
    .stat-item {
        background: rgba(0, 0, 0, 0.3);
        padding: var(--space-3);
        border-radius: var(--radius-md);
        text-align: center;
    }

    .stat-value,
    .stat-number {
        font-size: 1.25rem !important;
        font-weight: 800;
        color: white;
    }

    .stat-label {
        font-size: 9px;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: rgba(255, 255, 255, 0.6);
        margin-top: 2px;
    }
}

/* ========================================
   TOOL GRID - MODERN CARDS
   ======================================== */
@media (max-width: 768px) {
    .tool-grid,
    .calc-grid {
        display: flex !important;
        flex-direction: column !important;
        gap: var(--space-3) !important;
    }

    .tool-card,
    .calc-card {
        display: flex;
        align-items: flex-start;
        gap: var(--space-4);
        padding: var(--space-4) !important;
    }

    .tool-icon {
        width: 44px;
        height: 44px;
        flex-shrink: 0;
        background: var(--accent-glow);
        border-radius: var(--radius-md);
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.25rem;
    }

    .tool-content {
        flex: 1;
        min-width: 0;
    }

    .tool-title,
    .calc-name {
        font-size: 15px !important;
        font-weight: 600;
        margin-bottom: var(--space-1);
    }

    .tool-desc,
    .calc-formula {
        font-size: 13px !important;
        color: rgba(255, 255, 255, 0.5);
        line-height: 1.4;
    }
}

/* ========================================
   SIDEBAR HIDDEN
   ======================================== */
@media (max-width: 768px) {
    .sidebar {
        display: none !important;
    }

    .content,
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
    }
}

/* ========================================
   ALERTS & NOTIFICATIONS
   ======================================== */
@media (max-width: 768px) {
    .info-box,
    .warning-box,
    .danger-box,
    .success-box,
    .alert {
        padding: var(--space-4) !important;
        border-radius: var(--radius-md) !important;
        font-size: 14px;
        line-height: 1.5;
        border-left: 4px solid;
    }

    .info-box { border-color: #3b82f6; background: rgba(59, 130, 246, 0.1); }
    .warning-box { border-color: #f59e0b; background: rgba(245, 158, 11, 0.1); }
    .danger-box { border-color: #ef4444; background: rgba(239, 68, 68, 0.1); }
    .success-box { border-color: #22c55e; background: rgba(34, 197, 94, 0.1); }
}

/* ========================================
   FORMULA DISPLAY
   ======================================== */
@media (max-width: 768px) {
    .formula-box,
    .formula,
    code {
        display: block;
        padding: var(--space-3);
        background: rgba(0, 0, 0, 0.4);
        border-radius: var(--radius-sm);
        font-size: 12px;
        font-family: 'JetBrains Mono', 'SF Mono', monospace;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }
}

/* ========================================
   PLOTS & CHARTS
   ======================================== */
@media (max-width: 768px) {
    .plot-container,
    .chart-container,
    .pressure-plot {
        height: 280px !important;
        border-radius: var(--radius-md);
        overflow: hidden;
    }
}

/* ========================================
   FOOTER
   ======================================== */
@media (max-width: 768px) {
    footer {
        padding: var(--space-6) var(--space-4);
        text-align: center;
        border-top: 1px solid var(--glass-border);
        margin-top: var(--space-6);
    }

    footer p {
        font-size: 12px;
        color: rgba(255, 255, 255, 0.4);
    }
}

/* ========================================
   SMALL PHONES (< 375px)
   ======================================== */
@media (max-width: 375px) {
    :root {
        --space-4: 12px;
    }

    .bottom-nav {
        left: var(--space-2);
        right: var(--space-2);
        bottom: var(--space-2);
    }

    .bottom-nav-item {
        min-width: 48px;
        padding: var(--space-2);
    }

    .bottom-nav-label {
        font-size: 9px;
    }

    h1, .page-title {
        font-size: 1.5rem !important;
    }

    .results-grid,
    .result-grid {
        grid-template-columns: 1fr !important;
    }

    .hero-stats,
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* ========================================
   LANDSCAPE MODE
   ======================================== */
@media (max-width: 900px) and (orientation: landscape) {
    :root {
        --mobile-bottom-nav-height: 56px;
    }

    .bottom-nav {
        bottom: var(--space-2);
        left: var(--space-6);
        right: var(--space-6);
    }

    .bottom-nav-item {
        flex-direction: row;
        gap: var(--space-2);
        padding: var(--space-2) var(--space-3);
    }

    .mobile-fab {
        bottom: calc(56px + var(--mobile-safe-bottom) + 16px);
    }
}

/* ========================================
   TOUCH OPTIMIZATIONS
   ======================================== */
@media (pointer: coarse) {
    .tab,
    .btn,
    .mobile-menu-link,
    .bottom-nav-item,
    .back-btn,
    .tool-card,
    .calc-card {
        min-height: var(--touch-target);
    }

    input,
    select,
    textarea {
        min-height: var(--touch-target);
    }
}

/* ========================================
   ACCESSIBILITY
   ======================================== */
@media (max-width: 768px) {
    .mobile-menu-close:focus-visible,
    .mobile-menu-link:focus-visible,
    .bottom-nav-item:focus-visible,
    .back-btn:focus-visible,
    .mobile-fab:focus-visible,
    .btn:focus-visible,
    input:focus-visible,
    select:focus-visible {
        outline: 2px solid var(--accent);
        outline-offset: 2px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ========================================
   LOADING STATES - SKELETON
   ======================================== */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.skeleton {
    background: linear-gradient(
        90deg,
        var(--surface-1) 25%,
        var(--surface-2) 50%,
        var(--surface-1) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

/* ========================================
   PORTRAIT MODE - CLEAN SIMPLE LAYOUT
   No overlapping, no clutter, just works
   ======================================== */
@media (max-width: 768px) and (orientation: portrait) {

    /* === FIXED ELEMENTS === */
    /* Compact header - only fixed element at top */
    .header {
        height: 50px !important;
        padding: 0 12px !important;
    }

    /* Bottom nav - only fixed element at bottom */
    .bottom-nav {
        height: 60px !important;
        padding: 6px 8px !important;
    }

    /* === BODY SPACING === */
    /* Simple padding: header height + nav height + safe areas */
    body {
        padding-top: 50px !important;
        padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px) + 16px) !important;
    }

    /* === HIDE ALL FLOATING ELEMENTS === */
    .mobile-fab,
    .mobile-action-bar,
    #shareButtons,
    .calc-history-toggle,
    .calc-history-panel,
    .pipeline-trigger,
    .pipeline-container,
    .session-panel,
    .chain-banner,
    .feedback-btn {
        display: none !important;
    }

    /* === PAGE HEADER === */
    h1, .page-title {
        font-size: 1.25rem !important;
        margin-bottom: 4px !important;
        line-height: 1.3;
    }

    .subtitle, .page-subtitle {
        font-size: 12px !important;
        margin-bottom: 12px !important;
        opacity: 0.7;
    }

    /* === CONTAINER === */
    .container,
    .calc-container,
    .main-container {
        padding: 12px !important;
        max-width: 100% !important;
    }

    /* === CARDS - Simple stacking === */
    .card,
    .calc-card,
    .tool-card {
        padding: 12px !important;
        margin-bottom: 12px !important;
        border-radius: 12px !important;
    }

    .card-title,
    .calc-title,
    .card > h3:first-child {
        font-size: 14px !important;
        margin-bottom: 12px !important;
        padding-bottom: 8px !important;
        border-bottom: 1px solid rgba(255,255,255,0.1);
    }

    /* Remove collapsible behavior in portrait - keep it simple */
    .card-title::after,
    .calc-title::after,
    .card > h3:first-child::after {
        display: none !important;
    }

    .card.collapsed > * {
        display: block !important;
    }

    /* === FORMS - Compact but usable === */
    .form-group {
        margin-bottom: 10px !important;
    }

    label, .form-label {
        font-size: 11px !important;
        margin-bottom: 4px !important;
        display: block;
    }

    input[type="text"],
    input[type="number"],
    input[type="email"],
    select,
    textarea {
        width: 100% !important;
        padding: 10px 12px !important;
        font-size: 16px !important; /* Prevents iOS zoom */
        border-radius: 8px !important;
        min-height: 44px !important;
    }

    /* Form rows - stack vertically */
    .form-row,
    .form-row-3,
    .input-row {
        display: block !important;
    }

    .form-row > *,
    .form-row-3 > *,
    .input-row > * {
        margin-bottom: 10px !important;
    }

    /* Section dividers */
    .section-divider {
        margin: 16px 0 !important;
        padding-top: 16px !important;
    }

    .section-label {
        font-size: 12px !important;
        font-weight: 600;
        margin-bottom: 10px !important;
        color: #ff6b00;
    }

    /* Nozzle grid - 4 columns, compact */
    .nozzle-grid {
        display: grid !important;
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 8px !important;
    }

    .nozzle-input {
        text-align: center;
    }

    .nozzle-input label {
        font-size: 10px !important;
    }

    .nozzle-input input {
        padding: 8px !important;
        text-align: center;
    }

    /* === BUTTONS === */
    .btn,
    button[type="submit"],
    .btn-primary,
    .btn-calculate {
        width: 100% !important;
        padding: 12px 16px !important;
        font-size: 15px !important;
        min-height: 48px !important;
        border-radius: 10px !important;
        margin-top: 8px !important;
    }

    /* === RESULTS === */
    .results-grid,
    .result-grid {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }

    .result-box {
        padding: 10px !important;
        border-radius: 8px !important;
        text-align: center;
    }

    .result-value {
        font-size: 1.1rem !important;
        font-weight: 700;
    }

    .result-label {
        font-size: 9px !important;
        text-transform: uppercase;
    }

    .result-unit {
        font-size: 10px !important;
    }

    /* === TABLES - Horizontal scroll === */
    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    th, td {
        padding: 8px !important;
        font-size: 12px !important;
        white-space: nowrap;
    }

    /* === CHARTS === */
    .chart-container {
        height: 200px !important;
        margin-bottom: 12px;
    }

    /* === TABS === */
    .tabs {
        display: flex !important;
        overflow-x: auto !important;
        gap: 6px !important;
        padding-bottom: 8px;
        -webkit-overflow-scrolling: touch;
    }

    .tab {
        flex-shrink: 0;
        padding: 8px 14px !important;
        font-size: 12px !important;
        border-radius: 20px !important;
    }

    /* === PRESSURE BARS === */
    .pressure-bar-label {
        width: 80px !important;
        font-size: 10px !important;
    }

    .pressure-bar-value {
        font-size: 10px !important;
    }

    /* === FOOTER === */
    footer {
        padding: 16px 12px !important;
        margin-top: 24px;
    }

    footer p {
        font-size: 10px !important;
        line-height: 1.6;
    }
}

/* ========================================
   PRINT
   ======================================== */
@media print {
    .mobile-menu,
    .mobile-menu-overlay,
    .bottom-nav,
    .back-btn,
    .mobile-fab {
        display: none !important;
    }

    body {
        padding: 0 !important;
    }
}
