/* ═══════════════════════════════════════
   3. APP SHELL & TOPBAR (shell-3.css)
═══════════════════════════════════════ */
.app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    height: auto;
    overflow-x: hidden;
    width: 100%;
    /* RESERVE SPACE FOR FIXED FOOTER: Match desktop footer height */
    padding-bottom: 32px;
}

.topbar {
    display: flex;
    align-items: center;
    min-height: 4vh;
    padding: 0 20px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    gap: 20px;
}

.topbar-logo { display: flex; align-items: center; gap: 8px; text-decoration: none; }
.topbar-logo svg { color: var(--accent); }
.topbar-logo-text { font-family: var(--font-mono); font-size: 13px; font-weight: 500; color: var(--text-primary); letter-spacing: 0.1em; }
.topbar-divider { width: 1px; height: 20px; background: var(--border); flex-shrink: 0; }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.topbar-clock { font-family: var(--font-mono); font-size: 12px; color: var(--text-secondary); letter-spacing: 0.05em; }

.status-indicator { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-secondary); font-family: var(--font-mono); }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-muted); flex-shrink: 0; transition: background 0.3s; }
.status-dot.connected { background: var(--positive); box-shadow: 0 0 6px var(--positive); }
.status-dot.error { background: var(--negative); }


/* ═══════════════════════════════════════
   USER MENU & DROPDOWN (TOPBAR)
═══════════════════════════════════════ */
.topbar-user-menu {
    position: relative;
    margin-left: 8px;
}

.user-menu-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    outline: none;
}
.user-name { color: var(--text-primary); font-size: 13px; font-weight: 600; font-family: var(--font-ui); }
.user-avatar { width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--border); }

/* User Status Badges */
#header-status-badge { display: inline-flex; }
#header-status-badge span { font-family: var(--font-mono); display: flex; align-items: center; }

/* Dropdown Menu styling */
.user-dropdown {
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 12px;
    width: 220px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    overflow: hidden;
    font-family: var(--font-ui);
}

.user-dropdown-header { padding: 12px 16px; border-bottom: 1px solid var(--border); background: #0B1120; } /* Darker background for header */
.user-dropdown-name { margin: 0; font-size: 13px; font-weight: 600; color: var(--text-primary); }
.user-dropdown-email { margin: 4px 0 0 0; font-size: 11px; color: var(--text-muted); text-overflow: ellipsis; overflow: hidden; white-space: nowrap; }
.user-dropdown-body { padding: 6px 0; }

.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 12px;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.user-dropdown-item:hover { background: rgba(255, 255, 255, 0.05); color: var(--text-primary); }
.user-dropdown-item.logout { color: var(--negative); } /* Assuming --negative is your red color */
.user-dropdown-item.logout:hover { background: rgba(239, 68, 68, 0.1); }
.user-dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }


/* ═══════════════════════════════════════
   TAB BAR GROUPED
═══════════════════════════════════════ */

/* Wrapper enables fade overlays without touching the scrollable tabbar itself */
.tabbar-wrapper {
    position: relative;
    flex-shrink: 0;
    overflow: hidden;
}

/* Scroll-fade overlays — opacity toggled by JS via has-scroll-left/right */
.tabbar-wrapper::before,
.tabbar-wrapper::after {
    content: '';
    position: absolute;
    top: 0;
    height: 100%;
    width: 48px;
    pointer-events: none;
    z-index: 2;
    opacity: 0;
    transition: opacity 0.2s ease;
}
.tabbar-wrapper::before {
    left: 0;
    background: linear-gradient(to right, var(--bg-surface), transparent);
}
.tabbar-wrapper::after {
    right: 0;
    background: linear-gradient(to left, var(--bg-surface), transparent);
}
.tabbar-wrapper.has-scroll-left::before  { opacity: 1; }
.tabbar-wrapper.has-scroll-right::after  { opacity: 1; }

.tabbar {
    display: flex;
    align-items: flex-end;
    min-height: 3vh;
    padding: 0 16px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    overflow-x: auto;
    scrollbar-width: none;
}
.tabbar::-webkit-scrollbar { display: none; }

.tab-group { display: flex; align-items: flex-end; }
.tab-divider { width: 1px; height: 16px; background: var(--border); margin: 0 8px 10px 8px; }
.tab { position: relative; display: flex; align-items: center; gap: 7px; height: 38px; padding: 0 14px; font-size: 11px; font-weight: 600; color: var(--text-muted); cursor: pointer; border: none; background: none; font-family: var(--font-ui); transition: color 0.15s, background 0.15s; white-space: nowrap; letter-spacing: 0.05em; text-transform: uppercase; }
.tab:hover { color: var(--text-secondary); background: rgba(255, 255, 255, 0.02); }
.tab.active { color: var(--text-primary); background: rgba(255, 255, 255, 0.04); border-radius: 4px 4px 0 0; }
.tab-icon { opacity: 0.5; transition: opacity 0.2s, stroke 0.2s; }
.tab.active .tab-icon { opacity: 1; }
.tab.active::after { content: ""; position: absolute; bottom: 0; left: 0; right: 0; height: 2px; background: var(--text-primary); border-radius: 1px 1px 0 0; }

/* Tailwind icon color utilities */
.text-emerald-400 { stroke: #34D399; }
.text-blue-400 { stroke: #60A5FA; }
.text-purple-400 { stroke: #C084FC; }
.text-orange-400 { stroke: #FB923C; }

/* Apply group color to active tab's bottom highlight */
.tab.active:has(.text-emerald-400)::after { background: #34D399; box-shadow: 0 -2px 8px rgba(52, 211, 153, 0.4); }
.tab.active:has(.text-blue-400)::after { background: #60A5FA; box-shadow: 0 -2px 8px rgba(96, 165, 250, 0.4); }
.tab.active:has(.text-purple-400)::after { background: #C084FC; box-shadow: 0 -2px 8px rgba(192, 132, 252, 0.4); }
.tab.active:has(.text-orange-400)::after { background: #FB923C; box-shadow: 0 -2px 8px rgba(251, 146, 60, 0.4); }


/* ═══════════════════════════════════════
   TERMINAL FOOTER (STICKY BOTTOM)
═══════════════════════════════════════ */
.terminal-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 3vh;
    padding: 0 20px;
    background: var(--bg-surface);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    gap: 16px;
    box-sizing: border-box;
}
.footer-left, .footer-right { display: flex; align-items: center; gap: 10px; min-width: 0; }
.footer-right { margin-left: auto; }
.footer-logo { font-family: var(--font-mono); font-size: 10px; font-weight: 600; color: var(--text-muted); letter-spacing: 0.14em; text-transform: uppercase; }
.footer-meta { font-family: var(--font-mono); font-size: 10px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.footer-divider { width: 1px; height: 12px; background: var(--border); flex-shrink: 0; }


/* ═══════════════════════════════════════
   RESPONSIVE SHELL BREAKPOINTS
═══════════════════════════════════════ */

/* 1440px: Laptops */
@media (max-width: 1440px) {
    .topbar { gap: 14px; padding: 0 14px; }
    .topbar-right { gap: 12px; }
}

/* 1100px: Tablets / iPads */
@media (max-width: 1100px) {
    /* Reduce shell padding to match new tablet footer height */
    .app-shell { padding-bottom: 28px; }

    .topbar { gap: 10px; padding: 0 10px; height: 46px; }
    .topbar-logo-text { font-size: 12px; letter-spacing: 0.08em; }
    .topbar-clock { font-size: 11px; }
    
    .tabbar { height: 34px; padding: 0 8px; }
    .tab { height: 34px; padding: 0 10px; font-size: 10px; }
    
    .terminal-footer { height: 28px; padding: 0 10px; gap: 10px; }
    .footer-logo { font-size: 9px; }
    .footer-meta { font-size: 9px; }
}

/* 768px: Mobile / iPhones */
@media (max-width: 768px) {
    /* Reduce shell padding to match new mobile footer height */
    .app-shell { padding-bottom: 26px; }

    .topbar { height: 42px; padding: 0 8px; gap: 6px; }
    .topbar-logo-text { font-size: 10px; letter-spacing: 0.05em; }
    .topbar-clock { display: none; }
    .topbar-right { gap: 6px; }

    .status-indicator { font-size: 11px; gap: 4px; }
    .status-dot { width: 6px; height: 6px; }

    /* Make the dropdown menu play nice on mobile */
    .user-dropdown { width: 180px; margin-top: 8px; }

    /* Hide user name on mobile */
    .user-name { display: none !important; }

    .tabbar { display: none !important; }
    .tabbar-wrapper { display: none !important; }

    /* Mobile tab menu button */
    .mobile-tab-btn {
        display: flex !important;
        align-items: center;
        gap: 6px;
        height: 32px;
        margin-top: 8px;
        padding: 0 12px;
        background: var(--bg-raised);
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        color: var(--text-secondary);
        font-family: var(--font-ui);
        font-size: 11px;
        font-weight: 600;
        letter-spacing: 0.05em;
        text-transform: uppercase;
        cursor: pointer;
        white-space: nowrap;
    }
    .mobile-tab-btn svg { width: 14px; height: 14px; opacity: 0.6; }
    .mobile-tab-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

    /* Mobile tab dropdown */
    .mobile-tab-dropdown {
        display: none;
        position: fixed;
        top: 68px;
        left: 8px;
        right: 8px;
        background: var(--bg-surface);
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        padding: 6px 0;
        z-index: 500;
        max-height: calc(100vh - 140px);
        overflow-y: auto;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    }
    .mobile-tab-dropdown.show { display: block; }

    .mobile-tab-group-label {
        font-size: 9px;
        font-weight: 600;
        color: var(--text-muted);
        letter-spacing: 0.1em;
        text-transform: uppercase;
        padding: 8px 14px 4px;
    }
    .mobile-tab-dropdown .tab {
        height: 38px;
        padding: 0 14px;
        font-size: 12px;
        gap: 8px;
        border-radius: 0;
        width: 100%;
        text-align: left;
        justify-content: flex-start;
    }
    .mobile-tab-dropdown .tab-divider { display: none; }

    /* Footer responsive */
    .terminal-footer {
        height: auto !important;
        min-height: 26px;
        padding: 8px 10px !important;
        gap: 4px;
        flex-direction: column;
        align-items: center;
        justify-content: center;
    }
    .footer-left, .footer-right {
        width: 100%;
        justify-content: center;
    }
    .footer-right { margin-left: 0 !important; }
    .footer-divider { display: none; }
    .footer-logo { font-size: 9px; }
    .footer-meta { font-size: 8px; max-width: none; white-space: nowrap; }
}

/* 480px: Very Small Mobile */
@media (max-width: 480px) {
    /* Reduce shell padding to match new mini-mobile footer height */
    .app-shell { padding-bottom: 24px; }

    .topbar { height: 40px; padding: 0 6px; gap: 4px; }
    .topbar-logo-text { font-size: 9px; letter-spacing: 0.03em; }
    .topbar-right { gap: 4px; }

    /* Hide status indicator on very small screens */
    .status-indicator { display: none !important; }

    /* Hide user name on mobile */
    .user-name { display: none !important; }

    /* Push user avatar to the right */
    .topbar-user-menu { margin-left: auto !important; }

    .tabbar { height: 30px; padding: 0 2px; }
    .tab { height: 30px; padding: 0 5px; font-size: 8px; gap: 3px; }
    .tab-icon { width: 12px; height: 12px; }

    /* Footer tighter */
    .terminal-footer { padding: 6px 8px !important; }
    .footer-logo { font-size: 8px; }
    .footer-meta { font-size: 7px; }
}

/* Hide mobile tab button on desktop */
@media (min-width: 769px) {
    .mobile-tab-btn, .mobile-tab-dropdown { display: none !important; }
}