/* ============================================
   QuickBite POS - Application Shell
   Compact navigation rail expands on hover.
   ============================================ */

#loginScreen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    width: 100vw;
}

#appScreen {
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    background: var(--bg-primary);
}

/* ---- Hover navigation rail ---- */
#sidebar {
    position: relative;
    width: var(--sidebar-width);
    height: 100vh;
    background: rgba(16, 19, 31, 0.98);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: calc(var(--z-sticky) + 5);
    box-shadow: 10px 0 30px transparent;
    transition:
        width 240ms cubic-bezier(.2,.8,.2,1),
        box-shadow 240ms ease,
        border-color 240ms ease;
}

#sidebar:hover,
#sidebar:focus-within {
    width: var(--sidebar-expanded);
    border-color: var(--border-hover);
    box-shadow: 18px 0 45px rgba(0, 0, 0, 0.36);
}

.sidebar-brand {
    height: var(--topbar-height);
    min-height: var(--topbar-height);
    padding: 0 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 14px;
}

.sidebar-brand .logo {
    width: 44px;
    height: 44px;
    min-width: 44px;
    border-radius: 14px;
    background: linear-gradient(145deg, #ff8056, var(--accent));
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 19px;
    box-shadow: 0 10px 25px var(--accent-glow);
}

.sidebar-brand h2,
.nav-item span,
.sidebar-user .info,
#logoutBtn span {
    opacity: 0;
    transform: translateX(-8px);
    transition: opacity 150ms ease, transform 180ms ease;
    pointer-events: none;
    white-space: nowrap;
}

#sidebar:hover .sidebar-brand h2,
#sidebar:focus-within .sidebar-brand h2,
#sidebar:hover .nav-item span,
#sidebar:focus-within .nav-item span,
#sidebar:hover .sidebar-user .info,
#sidebar:focus-within .sidebar-user .info,
#sidebar:hover #logoutBtn span,
#sidebar:focus-within #logoutBtn span {
    opacity: 1;
    transform: translateX(0);
}

.sidebar-brand h2 {
    color: var(--text-primary);
    font-size: 20px;
    letter-spacing: -0.03em;
}

.sidebar-brand h2::first-letter { color: var(--accent); }

.sidebar-nav {
    flex: 1;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 12px 8px 18px;
}

.nav-section {
    height: 24px;
    margin: 8px 9px 4px;
    padding: 0;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .13em;
    line-height: 24px;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-indent: -999px;
}

#sidebar:hover .nav-section,
#sidebar:focus-within .nav-section {
    height: 28px;
    border-top-color: transparent;
    text-indent: 10px;
}

.nav-item {
    width: 60px;
    height: 48px;
    padding: 0 17px;
    margin: 3px 0;
    border-radius: 13px;
    display: flex;
    align-items: center;
    gap: 15px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: width 220ms ease, color 140ms ease, background 140ms ease, transform 140ms ease;
}

#sidebar:hover .nav-item,
#sidebar:focus-within .nav-item {
    width: 255px;
}

.nav-item:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
    transform: translateX(2px);
}

.nav-item.active {
    color: #fff;
    background: linear-gradient(90deg, rgba(255,107,61,.2), rgba(255,107,61,.07));
    box-shadow: inset 3px 0 0 var(--accent);
}

.nav-item i {
    width: 25px;
    min-width: 25px;
    text-align: center;
    font-size: 16px;
}

.nav-item.active i { color: var(--accent); }

.sidebar-footer {
    padding: 12px 8px;
    border-top: 1px solid var(--border);
    background: rgba(9, 11, 19, 0.42);
}

.sidebar-user {
    width: 60px;
    min-height: 48px;
    padding: 6px 9px;
    border-radius: 13px;
    display: flex;
    align-items: center;
    gap: 12px;
    overflow: hidden;
    transition: width 220ms ease, background 140ms ease;
}

#sidebar:hover .sidebar-user,
#sidebar:focus-within .sidebar-user {
    width: 255px;
    background: var(--bg-hover);
}

.sidebar-user .avatar {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 11px;
    display: grid;
    place-items: center;
    background: var(--accent-subtle);
    color: var(--accent);
    font-weight: 800;
}

.sidebar-user .info { min-width: 150px; }
.sidebar-user .name {
    overflow: hidden;
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 700;
    text-overflow: ellipsis;
}
.sidebar-user .role {
    margin-top: 1px;
    color: var(--text-secondary);
    font-size: 11px;
}

#logoutBtn {
    width: 60px;
    height: 42px;
    margin-top: 7px;
    padding: 0 18px;
    justify-content: flex-start;
    gap: 16px;
    overflow: hidden;
    border-radius: 12px;
    transition: width 220ms ease;
}

#sidebar:hover #logoutBtn,
#sidebar:focus-within #logoutBtn { width: 255px; }

/* ---- Main workspace ---- */
#mainContent {
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#topBar {
    height: var(--topbar-height);
    min-height: var(--topbar-height);
    padding: 0 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(9, 11, 19, 0.88);
    backdrop-filter: blur(16px);
    flex-shrink: 0;
}

#topBar h2 {
    font-size: 19px;
    letter-spacing: -0.025em;
    white-space: nowrap;
}

.topbar-leading {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 14px;
}

#topBar .actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.topbar-quick-actions {
    display: flex;
    align-items: center;
    gap: 7px;
}

.topbar-action-btn {
    min-height: 36px;
    padding: 0 11px;
    border: 1px solid var(--border);
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.025);
    font: inherit;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    transition: color 160ms ease, border-color 160ms ease, background 160ms ease;
}

.topbar-action-btn:hover {
    color: var(--text-primary);
    border-color: var(--border-hover);
    background: var(--bg-hover);
}

.topbar-action-btn:disabled {
    opacity: .55;
    cursor: wait;
}

.topbar-action-btn.is-loading i {
    animation: spin .8s linear infinite;
}

.topbar-action-primary {
    color: var(--accent);
    border-color: rgba(255, 107, 53, .28);
    background: var(--accent-subtle);
}

.topbar-location {
    min-width: 150px;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--accent);
    background: var(--accent-subtle);
}

.topbar-location > i { font-size: 13px; }
.topbar-location div { min-width: 0; }
.topbar-location strong,
.topbar-location small {
    max-width: 180px;
    display: block;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.topbar-location strong { color: var(--text-primary); font-size: 12px; }
.topbar-location small { margin-top: 1px; color: var(--text-secondary); font-size: 9px; }

.topbar-status {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
}

.topbar-status .online-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 0 4px var(--success-subtle);
}

.topbar-status.is-offline .online-dot,
.topbar-status.is-error .online-dot { background: var(--danger); box-shadow: 0 0 0 4px var(--danger-subtle); }
.topbar-status.is-warning .online-dot { background: var(--warning); box-shadow: 0 0 0 4px var(--warning-subtle); }
.topbar-status.is-syncing .online-dot { background: var(--info); box-shadow: 0 0 0 4px var(--info-subtle); animation: sync-pulse 1s infinite alternate; }
.topbar-status.is-error { color: var(--danger); border-color: rgba(244, 67, 54, .35); }
.topbar-status.is-warning { color: var(--warning); border-color: rgba(255, 167, 38, .35); }
@keyframes sync-pulse { to { opacity: .35; } }

#pageContent {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 24px;
}

#pageContent.pos-page {
    padding: 0;
    overflow: hidden;
}

#appScreen.mobile-sales-shell {
    grid-template-columns: 1fr;
}

#appScreen.mobile-sales-shell #sidebar,
#appScreen.mobile-sales-shell #topBar {
    display: none;
}

#appScreen.mobile-sales-shell #mainContent {
    height: 100vh;
}

#pageContent.mobile-sales-content {
    padding: 0;
    overflow: hidden;
    background: var(--bg-primary);
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 22px;
}
.page-header h3 { font-size: 17px; }

.mobile-menu-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin-right: 10px;
    border-radius: 11px;
    color: var(--text-secondary);
    font-size: 18px;
}
.mobile-menu-btn:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: calc(var(--z-modal) - 1);
    background: rgba(0,0,0,.62);
    backdrop-filter: blur(3px);
}
.sidebar-overlay.active { display: block; }

@media (max-width: 900px) {
    #appScreen { grid-template-columns: 1fr; }
    #sidebar,
    #sidebar:hover,
    #sidebar:focus-within {
        position: fixed;
        top: 0;
        bottom: 0;
        left: calc(-1 * var(--sidebar-expanded));
        width: var(--sidebar-expanded);
        z-index: var(--z-modal);
        box-shadow: var(--shadow-lg);
        transition: left 240ms ease;
    }
    #sidebar.open { left: 0; }
    #sidebar .sidebar-brand h2,
    #sidebar .nav-item span,
    #sidebar .sidebar-user .info,
    #sidebar #logoutBtn span {
        opacity: 1;
        transform: none;
    }
    #sidebar .nav-item,
    #sidebar .sidebar-user,
    #sidebar #logoutBtn { width: 255px; }
    #sidebar .nav-section {
        height: 28px;
        border-top-color: transparent;
        text-indent: 10px;
    }
    .mobile-menu-btn { display: inline-flex; }
    #topBar { padding: 0 14px; }
    .topbar-leading { gap: 7px; }
    .topbar-status { display: none; }
    .topbar-location { min-width: 0; padding: 7px 9px; }
    .topbar-location strong { max-width: 120px; }
    .topbar-location small { display: none; }
    .topbar-action-btn {
        width: 36px;
        min-width: 36px;
        padding: 0;
    }
    .topbar-action-btn span { display: none; }
    #topBar h2 { font-size: 16px; }
    #pageContent { padding: 16px; }
    #pageContent.pos-page {
        padding: 0;
        overflow-y: auto;
    }
}
