:root {
    --bg-main: #0B0E14;
    --bg-sidebar: rgba(15, 20, 25, 0.8);
    --bg-card: rgba(22, 27, 34, 0.6);
    --border-subtle: rgba(255, 255, 255, 0.08);
    
    --accent-neon: #64ffda;
    --accent-neon-dim: rgba(100, 255, 218, 0.15);
    --accent-primary: #3b82f6;
    
    --text-main: #F8FAFC;
    --text-muted: #94A3B8;
    
    --font-primary: 'Inter', -apple-system, sans-serif;
    --blur-heavy: blur(20px);
}

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

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: var(--font-primary);
    background-image: radial-gradient(circle at top right, rgba(59,130,246,0.1), transparent 40%);
    min-height: 100vh;
}

/* Layout */
.portal-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--bg-sidebar);
    backdrop-filter: var(--blur-heavy);
    border-right: 1px solid var(--border-subtle);
    padding: 30px 20px;
    display: flex;
    flex-direction: column;
}

.logo {
    font-size: 1.5rem;
    font-weight: 900;
    letter-spacing: -0.5px;
    margin-bottom: 50px;
    padding-left: 10px;
}
.neon-dot { color: var(--accent-neon); }

.nav-links {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    padding: 12px 14px;
    border-radius: 10px;
    font-weight: 500;
    font-size: 0.95rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 12px;
}
.nav-links a:hover {
    background: rgba(255,255,255,0.05);
    color: #fff;
}
.nav-links a.active {
    background: var(--accent-neon-dim);
    color: var(--accent-neon);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
}
.avatar {
    width: 40px; height: 40px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-neon));
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; color: var(--bg-main);
}
.user-info h4 { font-size: 0.9rem; }
.user-info .status { font-size: 0.75rem; color: var(--accent-neon); }

/* Main Dashboard */
.dashboard {
    flex: 1;
    padding: 40px;
    overflow-y: auto;
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 40px;
}

.dashboard-header h1 {
    font-size: 2.5rem;
    font-weight: 900;
    letter-spacing: -1px;
    margin-bottom: 8px;
}
.dashboard-header p { color: var(--text-muted); }
.neon-text { color: var(--accent-neon); text-shadow: 0 0 10px var(--accent-neon-dim); }

.primary-btn {
    background: var(--accent-neon);
    color: var(--bg-main);
    border: none;
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 15px var(--accent-neon-dim);
    transition: transform 0.2s;
}
.primary-btn:hover { transform: translateY(-2px); }

/* Bento Grid */
.bento-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-gap: 24px;
    grid-auto-rows: minmax(200px, auto);
}

.bento-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 24px;
    padding: 24px;
    backdrop-filter: var(--blur-heavy);
    display: flex;
    flex-direction: column;
}

.tall { grid-row: span 2; }
.wide { grid-column: span 2; }

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 20px;
}
.card-header h3 { font-size: 1.1rem; font-weight: 700; }
.muted { color: var(--text-muted); font-size: 0.85rem; }
.badge { 
    background: var(--accent-neon-dim); color: var(--accent-neon); 
    padding: 4px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 700; text-transform: uppercase;
}
.badge.warning { background: rgba(255, 215, 0, 0.15); color: #ffd700; }

/* Mock Heatmap */
.heatmap-visual { flex: 1; display: flex; flex-direction: column; gap: 20px; }
.mock-3d-model {
    flex: 1;
    background: rgba(0,0,0,0.3);
    border-radius: 16px;
    border: 1px dashed rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
}
.model-core { display: none; }
.zone { position: absolute; border-radius: 50%; opacity: 0.8; pointer-events: none; transition: opacity 0.5s ease; z-index: 2; }
.zone.chest { top: 18%; left: 25%; width: 50%; height: 25%; background: radial-gradient(circle, rgba(100, 255, 218, 0.8) 0%, rgba(100, 255, 218, 0) 70%); }
.zone.arms { top: 30%; left: 10%; width: 80%; height: 35%; background: radial-gradient(circle, rgba(100, 255, 218, 0.8) 0%, rgba(100, 255, 218, 0) 70%); -webkit-clip-path: polygon(0 0, 25% 0, 25% 100%, 0 100%, 75% 100%, 100% 100%, 100% 0, 75% 0, 75% 100%, 25% 100%); clip-path: polygon(0 0, 25% 0, 25% 100%, 0 100%, 75% 100%, 100% 100%, 100% 0, 75% 0, 75% 100%, 25% 100%); }
.zone.legs { top: 55%; left: 25%; width: 50%; height: 40%; background: radial-gradient(circle, rgba(100, 255, 218, 0.8) 0%, rgba(100, 255, 218, 0) 70%); }
.zone.glow { opacity: 1; }

.stat-row { display: flex; justify-content: space-between; font-size: 0.9rem; padding: 8px 0; border-bottom: 1px solid var(--border-subtle); }
.heatmap-caption { font-size: 0.8rem; color: var(--text-muted); line-height: 1.5; margin-top: 10px;}

/* Mock Chart */
.chart-visual { flex: 1; display: flex; align-items: flex-end; }
.bar-chart {
    display: flex; justify-content: space-between; align-items: flex-end;
    width: 100%; height: 100%; padding-top: 20px; gap: 10px;
}
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 10px;  height: 200px; justify-content: flex-end;}
.bar {
    width: 100%;
    background: rgba(255,255,255,0.1);
    border-radius: 6px 6px 0 0;
    transition: height 0.5s ease;
}
.neon-bar { background: var(--accent-neon); box-shadow: 0 0 15px var(--accent-neon-dim); }
.bar-col span { font-size: 0.8rem; color: var(--text-muted); font-weight: 500;}

/* PR List */
.pr-list { display: flex; flex-direction: column; gap: 16px; }
.pr-item {
    display: flex; gap: 16px; align-items: center;
    background: rgba(255,255,255,0.03); padding: 12px; border-radius: 12px; border: 1px solid var(--border-subtle);
}
.pr-icon { font-size: 1.5rem; }
.pr-details h4 { font-size: 0.95rem; margin-bottom: 4px; }
.pr-details span { font-size: 0.8rem; color: var(--accent-neon); }

/* Alerts */
.alert-content { display: flex; flex-direction: column; justify-content: space-between; flex: 1; }
.alert-text { line-height: 1.6; font-size: 0.9rem; color: var(--text-muted); }
.ghost-btn { background: transparent; border: 1px solid var(--border-subtle); color: #fff; padding: 10px; border-radius: 8px; cursor: pointer; transition: all 0.2s;}
.ghost-btn:hover { background: rgba(255,255,255,0.05); }

/* --- Vault Styles --- */
.vault-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
.vault-card { padding: 16px; border-radius: 16px; gap: 16px; justify-content: flex-start; }
.video-preview { 
    height: 140px; background: #000; border-radius: 12px; display: flex; align-items: center; justify-content: center; 
    border: 1px solid var(--border-subtle); color: var(--text-muted); cursor: pointer; transition: all 0.2s;
}
.video-preview:hover { border-color: var(--accent-neon); color: var(--accent-neon); box-shadow: 0 0 15px var(--accent-neon-dim); }
.vault-info h4 { margin-bottom: 8px; font-size: 1.05rem; }
.tags { display: flex; gap: 8px; flex-wrap: wrap; }
.aio-badge { border: 1px solid rgba(255, 215, 0, 0.3); }

/* --- Builder Styles --- */
.builder-container { display: flex; gap: 24px; min-height: 500px; align-items: flex-start; }
.exercise-pool { width: 300px; flex-shrink: 0; position: sticky; top: 24px; height: calc(100vh - 120px); }
.day-columns { flex: 1; display: flex; flex-direction: row; flex-wrap: nowrap; overflow-x: auto; gap: 24px; padding-bottom: 24px; }
.day-col { flex: 0 0 320px; }
.draggable-item { 
    background: rgba(255,255,255,0.03); padding: 12px 16px; border-radius: 8px; 
    border: 1px solid var(--border-subtle); margin-bottom: 10px; cursor: grab;
    display: flex; justify-content: space-between; align-items: center; font-size: 0.9rem;
    transition: transform 0.1s;
}
.draggable-item:active { cursor: grabbing; transform: scale(0.98); }
.drop-zone { flex: 1; border: 2px dashed var(--border-subtle); border-radius: 12px; padding: 16px; }
.drop-zone.empty { display: flex; align-items: center; justify-content: center; color: var(--text-muted); font-size: 0.9rem; }
.drop-zone.populated { border-style: solid; background: rgba(255,255,255,0.01); }

/* --- Touch Targets & Action Buttons --- */
.action-btn {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-subtle);
    color: var(--text-main);
    transition: all 0.2s;
    font-size: 1.1rem;
    padding: 0;
}
.action-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}
.action-btn.danger {
    color: rgba(255, 100, 100, 0.9);
    background: transparent;
    border-color: transparent;
}
.action-btn.danger:hover {
    background: rgba(255, 100, 100, 0.15);
}
.action-btn.neon {
    background: var(--accent-neon);
    color: var(--bg-main);
    border: none;
    font-weight: 900;
}
.action-btn.neon:hover {
    box-shadow: 0 0 15px var(--accent-neon-dim);
}

.day-title-input {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 1.1rem;
    font-weight: 700;
    font-family: var(--font-primary);
    width: 100%;
    outline: none;
    border-bottom: 1px dashed var(--border-subtle);
    padding-bottom: 4px;
}
.day-title-input:focus { border-bottom-color: var(--accent-neon); }

/* --- Settings Styles --- */
.settings-list { display: flex; flex-direction: column; gap: 24px; }
.setting-item { display: flex; justify-content: space-between; align-items: center; padding-bottom: 24px; border-bottom: 1px solid var(--border-subtle); }
.setting-item:last-child { border-bottom: none; padding-bottom: 0; }
.setting-item h4 { margin-bottom: 4px; }
.toggle { width: 50px; height: 26px; background: rgba(255,255,255,0.1); border-radius: 15px; position: relative; cursor: pointer; transition: all 0.3s; }
.toggle::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; background: #fff; border-radius: 50%; transition: all 0.3s; }
.toggle.active { background: var(--accent-neon); box-shadow: 0 0 10px var(--accent-neon-dim); }
.toggle.active::after { left: 27px; background: var(--bg-main); }
.settings-form { display: flex; flex-direction: column; }
.settings-form label { margin-bottom: 8px; font-size: 0.85rem; font-weight: 600; margin-top: 16px; }
.settings-form label:first-child { margin-top: 0; }
.form-input { 
    background: rgba(255,255,255,0.05); border: 1px solid var(--border-subtle); 
    border-radius: 10px; padding: 14px; color: #fff; font-size: 0.95rem; font-family: var(--font-primary);
}
.form-input:disabled { opacity: 0.5; cursor: not-allowed; }

/* --- Quick Stat Cards --- */
.stat-card {
    transition: transform 0.2s, box-shadow 0.2s;
}
.stat-card:hover {
    transform: translateY(-2px);
    border-color: rgba(100, 255, 218, 0.2);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
}

/* --- CMD+K Palette Styles --- */
.cmd-k-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    z-index: 999;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 15vh;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}
.cmd-k-overlay.active {
    opacity: 1;
    pointer-events: auto;
}
.cmd-k-palette {
    width: 100%;
    max-width: 600px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 16px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5), 0 0 0 1px rgba(100,255,218,0.1);
    transform: translateY(-20px) scale(0.98);
    transition: all 0.2s cubic-bezier(0.25, 1, 0.5, 1);
    overflow: hidden;
}
.cmd-k-overlay.active .cmd-k-palette {
    transform: translateY(0) scale(1);
}
.cmd-k-search {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-subtle);
    gap: 12px;
}
.cmd-k-search input {
    flex: 1;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 1.2rem;
    font-family: var(--font-primary);
    outline: none;
}
.cmd-k-search .search-icon { font-size: 1.2rem; }
.cmd-k-hint {
    background: rgba(255,255,255,0.1);
    color: var(--text-muted);
    font-size: 0.7rem;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 700;
}
.cmd-k-results {
    padding: 12px;
}
.cmd-k-category {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    padding: 8px 12px;
    letter-spacing: 0.5px;
}
.cmd-k-item {
    display: flex;
    align-items: center;
    padding: 12px;
    gap: 12px;
    color: var(--text-main);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    transition: background 0.1s;
}
.cmd-k-item:hover {
    background: var(--accent-neon-dim);
    color: var(--accent-neon);
}

/* --- Tablet Responsiveness --- */
@media (max-width: 1200px) {
    .bento-grid, .vault-grid, .day-columns {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    
    .builder-container {
        flex-direction: column;
        height: calc(100vh - 150px);
        gap: 16px;
    }
    
    .exercise-pool {
        width: 100%;
        height: 35vh; /* Take up top portion */
        flex-shrink: 0;
        margin-bottom: 0;
    }

    .day-columns {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        overflow-x: auto;
        overflow-y: hidden;
        scroll-snap-type: x mandatory;
        gap: 16px;
        padding-bottom: 20px;
        /* Custom scrollbar for mobile sliding */
        scrollbar-width: none; 
    }
    .day-columns::-webkit-scrollbar {
        display: none;
    }

    .day-col {
        flex: 0 0 85vw;
        scroll-snap-align: center;
        height: 100%;
        overflow-y: auto;
    }
}

/* --- Mobile Responsiveness --- */
/* --- Mobile Menu Styles --- */
.mobile-menu-toggle {
    display: none;
    background: transparent;
    border: none;
    color: var(--accent-neon);
    font-size: 1.8rem;
    cursor: pointer;
    padding: 0 10px;
    transition: 0.3s;
}

@media (max-width: 768px) {
    .portal-layout {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        padding: 16px 20px;
        border-right: none;
        border-bottom: 1px solid var(--border-subtle);
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: space-between;
        align-items: center;
        background: rgba(13, 17, 23, 0.95);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        position: relative;
        z-index: 2000;
    }
    
    .logo {
        margin-bottom: 0;
        display: flex;
        align-items: center;
    }
    
    .mobile-menu-toggle {
        display: block;
    }
    
    .user-profile {
        display: none; /* Hide bulky profile block on mobile to reclaim height */
    }
    
    .nav-links {
        display: none; /* Hidden by default behind toggle */
        width: 100%;
        flex-direction: column;
        margin-top: 16px;
        padding: 0;
        gap: 0;
        background: rgba(22, 27, 34, 0.95);
        border-radius: 12px;
        border: 1px solid var(--border-subtle);
        overflow: hidden;
        animation: slideDown 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    }
    
    @keyframes slideDown {
        from { opacity: 0; transform: translateY(-10px); }
        to { opacity: 1; transform: translateY(0); }
    }
    
    .nav-links.active {
        display: flex;
    }
    
    .nav-links > div, .nav-links > a {
        padding: 16px 20px !important;
        margin: 0 !important;
        border-radius: 0;
        border-bottom: 1px solid var(--border-subtle) !important;
        justify-content: flex-start;
        width: 100%;
        box-sizing: border-box;
    }
    
    .nav-links > a:last-child {
        border-bottom: none !important;
    }
    
    /* Hide the "Overwatch Command" spacer text on mobile entirely */
    .nav-links > div[style*="Overwatch Command"] {
        display: none !important;
    }
    
    .dashboard {
        padding: 20px;
    }
    
    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
    
    .dashboard-header h1 {
        font-size: 1.6rem;
        margin-bottom: 0;
    }
    
    .dashboard-header p {
        display: none;
    }
    
    .primary-btn, .secondary-btn, .danger-btn {
        width: 100%;
        text-align: center;
        justify-content: center;
    }
    
    .bento-card {
        padding: 16px;
    }
    
    .bento-grid, .vault-grid, .admin-metrics {
        grid-template-columns: 1fr;
        display: flex;
        flex-direction: column;
    }
    
    .day-columns {
        display: flex !important;
        flex-direction: column !important;
        overflow: visible;
        gap: 24px;
    }
    
    .day-col {
        flex: auto !important;
        width: 100% !important;
        height: auto !important;
        overflow: visible !important;
    }
    
    .tall, .wide {
        grid-row: auto;
        grid-column: auto;
    }
    
    .admin-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    
    .health-grid {
        grid-template-columns: 1fr;
        display: flex;
        flex-direction: column;
    }
    
    .profile-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    
    .data-table-container {
        padding: 12px;
        width: 100%;
        overflow-x: auto;
    }
    
    table th, table td {
        white-space: nowrap;
    }
    
    .cmd-k-palette {
        width: 95%;
    }
    
    .mobile-stack {
        flex-direction: column !important;
        align-items: stretch !important;
    }
    
    .mobile-stack > * {
        width: 100% !important;
    }

    /* iOS Safari Backdrop-Filter Flickering Fix */
    .bento-card, .stat-card {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        background: rgba(22, 27, 34, 0.95) !important;
    }
}
