/* ====================================================================
   ALZAR LOGIC - SHELL LAYOUT (Strict)
   ==================================================================== */

:root {
    /* --- STRICT LAYOUT VARIABLES --- */
    --sidebar-w-exp: 260px;
    --sidebar-w-col: 72px;
    --header-h: 64px;
    --app-gap-strict: 20px; /* The 20px Edge Rule */
    
    /* --- FALLBACK COLORS (Guarantees Industrial Dark Mode) --- */
    --color-bg-base: #121212;       /* Charcoal Canvas */
    --color-bg-surface: #1A1B1E;    /* Industrial Gray */
    --color-bg-hover: #3A3B3E;      /* Royal Gray */
    --color-primary: #22c55e;       /* Alzar Green */
    --color-border: #3A3B3E;        /* Royal Gray */
    --color-text-main: #f8fafc;     /* Slate 50 */
    --color-text-muted: #94a3b8;    /* Slate 400 */
}

/* --- RESET --- */
body {
    margin: 0;
    padding: 0;
    background-color: var(--color-bg-base);
    color: var(--color-text-main);
    overflow: hidden; 
    font-family: 'Inter', system-ui, sans-serif;
}

/* --- APP SHELL --- */
#app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-w-exp) 1fr;
    height: 100vh;
    width: 100vw;
    transition: grid-template-columns 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#app-shell.shell-collapsed {
    grid-template-columns: var(--sidebar-w-col) 1fr;
}

/* --- SIDEBAR --- */
#app-sidebar {
    background-color: var(--color-bg-surface);
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    z-index: 100;
}

/* ============================================================
   🔒 LOCKED: ALZAR LOGO & SIDEBAR TOGGLE - DO NOT MODIFY
   Working implementation copied from Alzar Logic project
   ============================================================ */

/* Alzar Sidebar Header */
.alzar-sidebar-header {
    height: var(--header-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}

.alzar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    user-select: none;
}

.alzar-brand-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.alzar-brand-icon:hover {
    transform: scale(1.05);
}

.alzar-brand-icon i {
    font-size: 32px;
    color: #38bdf8;
    filter: drop-shadow(0 0 8px rgba(56, 189, 248, 0.4));
    transition: transform 0.3s ease, filter 0.3s ease;
}

.alzar-brand-icon:hover i {
    transform: rotate(20deg);
    filter: drop-shadow(0 0 12px rgba(56, 189, 248, 0.6));
}

#app-shell.shell-collapsed .alzar-brand-icon i {
    transform: rotate(180deg);
}

.alzar-brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.alzar-brand-name {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--color-text-main);
}

.alzar-brand-tagline {
    font-weight: 500;
    font-size: 0.75rem;
    color: #22c55e; /* Green - matches primary accent */
    letter-spacing: 0.05em;
}

/* Sidebar Toggle Button */
.action-icon {
    background: none;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.action-icon:hover {
    color: var(--color-text-main);
    background-color: rgba(255,255,255,0.05);
}
.action-icon i { font-size: 1.2rem; }

/* Hide text when collapsed */
#app-shell.shell-collapsed .alzar-brand-text,
#app-shell.shell-collapsed .nav-label,
#app-shell.shell-collapsed .user-info,
#app-shell.shell-collapsed .user-chevron {
    opacity: 0;
    pointer-events: none;
    display: none;
}

/* Navigation */
.sidebar-menu {
    flex: 1;
    padding: 16px 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    background: none;
    border: none;
    width: 100%;
    display: flex;
    align-items: center;
    padding: 12px 16px;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    font-size: 0.95rem;
    white-space: nowrap;
}

.nav-item:hover {
    background-color: var(--color-bg-hover);
    color: var(--color-text-main);
}

.nav-item.active {
    background-color: var(--color-active-dim);
    color: var(--color-active);
    border-right: 3px solid var(--color-active);
    filter: var(--glow-active);
}

.nav-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    margin-right: 12px;
}
.nav-icon i { font-size: 1.3rem; }

.nav-spacer { flex: 1; }

/* Quick Backup Button (Browser Mode Only) */
.nav-backup {
    border-top: 1px solid var(--color-border);
    border-bottom: 1px solid var(--color-border);
    margin: 4px 0;
    background: linear-gradient(135deg, rgba(251, 146, 60, 0.1), rgba(251, 146, 60, 0.05));
    position: relative;
}

.nav-backup:hover {
    background: linear-gradient(135deg, rgba(251, 146, 60, 0.15), rgba(251, 146, 60, 0.08));
    color: #fb923c !important;
}

.nav-backup::before {
    content: "TEST";
    position: absolute;
    top: 4px;
    right: 8px;
    font-size: 0.6rem;
    background: rgba(251, 146, 60, 0.9);
    color: white;
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

/* User Switcher */
.user-trigger {
    background: none;
    border: none;
    border-top: 1px solid var(--color-border);
    padding: 16px;
    display: flex;
    align-items: center;
    width: 100%;
    text-align: left;
    cursor: pointer;
    color: var(--color-text-main);
}
.user-trigger:hover {
    background-color: var(--color-bg-hover);
}

/* --- MAIN VIEWPORT --- */
#app-viewport {
    /* STRICT 20px PADDING */
    padding: var(--app-gap-strict);
    overflow-y: auto;
    position: relative;
    background-color: var(--color-bg-base);
}

.view-container {
    display: none;
    height: 100%;
    animation: fadeIn 0.3s ease-out;
}

.view-container.active-view {
    display: block;
}

/* Settings needs flex-column for scroll chain (min-height:0 cascade) */
#settingsPage.active-view {
    display: flex;
    flex-direction: column;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.spin {
    animation: spin 1s linear infinite;
    display: inline-block;
}

.view-header {
    margin-bottom: var(--app-gap-strict);
    border-bottom: 1px solid var(--color-border);
    padding-bottom: 10px;
}

.view-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

/* --- SETTINGS LAYOUT --- */
/* 🔧 REMOVED: Old 2-column grid layout for settings.
   settings.css now owns .settings-layout as flex-column.
   Keeping this block as a comment to prevent re-introduction. */

.settings-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-right: 1px solid var(--color-border);
    padding-right: var(--app-gap-strict);
}

.set-tab {
    background: none;
    border: none;
    text-align: left;
    padding: 10px 12px;
    color: var(--color-text-muted);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
}
.set-tab:hover {
    background-color: var(--color-bg-hover);
    color: var(--color-text-main);
}
.set-tab.active {
    background-color: var(--color-bg-hover);
    color: var(--color-text-main);
    font-weight: 600;
}

.set-panel { display: none; }
.set-panel.active-panel { display: block; }

/* --- PLACEHOLDERS --- */
.empty-state-panel {
    border: 1px dashed var(--color-border);
    background-color: rgba(30, 41, 59, 0.5);
    border-radius: 8px;
    padding: 40px;
    text-align: center;
    color: var(--color-text-muted);
}
.empty-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    color: var(--color-border);
}
.text-muted { color: var(--color-text-muted); }

/* ====================================================================
   MOBILE RESPONSIVE LAYOUT
   ==================================================================== */

@media (max-width: 768px) {
    /* Change shell to overlay mode */
    #app-shell {
        grid-template-columns: 1fr;
    }
    
    /* Sidebar becomes overlay */
    #app-sidebar {
        position: fixed;
        left: -280px; /* Hidden by default */
        top: 0;
        width: 260px;
        height: 100vh;
        z-index: 1000;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    /* Show sidebar when expanded */
    #app-shell.shell-expanded #app-sidebar {
        left: 0;
    }
    
    /* Add overlay backdrop */
    body.menu-open::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        animation: fadeIn 0.3s ease-out;
    }
    
    /* Viewport takes full width */
    #app-viewport {
        padding: 12px;
    }
    
    /* Adjust header for mobile */
    .view-header {
        margin-bottom: 12px;
    }
    
    .view-title {
        font-size: 1.25rem;
    }
}

/* ====================================================================
   PRINT STYLES
   ==================================================================== */

@media print {
    /* Hide navigation and controls */
    #app-sidebar,
    .view-header .btn,
    .view-header .actions,
    .sidebar-head,
    .sidebar-menu,
    .widget-controls,
    .drag-handle,
    .btn-icon,
    button {
        display: none !important;
    }
    
    /* Full width layout */
    #app-shell {
        grid-template-columns: 1fr !important;
        height: auto !important;
    }
    
    #app-viewport,
    .view-content {
        padding: 0 !important;
        overflow: visible !important;
        height: auto !important;
    }
    
    /* Ensure content flows properly */
    .page-wrapper {
        overflow: visible !important;
        height: auto !important;
    }
    
    /* Preserve colors for important elements */
    * {
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }
}
