/* ════════════════════════════════════
   layout.css — Mobile views, dock, active jobs sheet,
                sidebar, hamburger, and responsive rules
   ════════════════════════════════════ */

/* ── Mobile views ── */
.mobile-view {
    display: none;
    padding-bottom: 80px;
}

.mobile-active {
    display: block !important;
}

/* ── Bottom dock ── */
#mobileDockContainer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    /* Expand height to cover iPhone home indicator */
    height: calc(75px + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    z-index: 3000;
    display: none;
    background: rgba(15, 23, 42, 0.95);
}

#bottomDock {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 75px;
    background: var(--glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    justify-content: space-around;
    align-items: center;
    /* Items stay in main 75px zone; container handles safe area above */
    padding-bottom: 4px;
    border-top: 1px solid var(--border);
}

.dock-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    color: var(--dim);
    font-size: 0.7rem;
    transition: all 0.2s;
    cursor: pointer;
    text-decoration: none;
    font-weight: 500;
}

.dock-item.active {
    color: var(--primary);
}

.dock-icon {
    font-size: 1.5rem;
    margin-bottom: 4px;
}

#dockHome {
    position: absolute;
    bottom: 25px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2100;
    width: 70px;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: none;
    border: none;
    cursor: pointer;
}

#dockHome .dock-icon {
    width: 58px;
    height: 58px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    box-shadow: 0 8px 20px rgba(56, 189, 248, 0.4);
    border: 4px solid var(--bg);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    margin-bottom: 0;
}

#dockHome:active .dock-icon {
    transform: scale(0.9) translateY(4px);
}

#dockHome span:not(.dock-icon) {
    display: none;
}

/* ── Active Jobs Sheet ── */
#activeJobsSheet {
    position: fixed;
    bottom: 0px;
    left: 0;
    right: 0;
    background: var(--sheet-bg);
    border-top-left-radius: 1.5rem;
    border-top-right-radius: 1.5rem;
    border-top: 1px solid var(--border);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform: translateY(100%);
    z-index: 2500;
    max-height: 85vh;
    display: none;
    flex-direction: column;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

#activeJobsSheet.open {
    transform: translateY(0);
}

#activeJobsMiniBar {
    height: 50px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
}

#miniBarSummary {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 4px;
}

#activeJobsSheet.open #activeJobsMiniBar {
    border-bottom: none;
}

.sheet-handle {
    width: 40px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 12px auto;
    flex-shrink: 0;
}

.sheet-header {
    padding: 0 1.5rem 1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sheet-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.5rem 120px;
}

/* ── Job list items ── */
.job-list-item {
    background: rgba(30, 41, 59, 0.7);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1.25rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.job-list-item:active {
    transform: scale(0.98);
    background: rgba(30, 41, 59, 0.9);
}

.job-list-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.job-list-info {
    flex: 1;
}

.job-list-label {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 2px;
}

.job-list-sub {
    font-size: 0.8rem;
    color: var(--dim);
}

#activeJobsToggle {
    position: fixed;
    bottom: 85px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: var(--primary);
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: 0 4px 20px rgba(56, 189, 248, 0.4);
    border: none;
    cursor: pointer;
    z-index: 850;
    transition: transform 0.2s;
}

#activeJobsToggle:active {
    transform: scale(0.9);
}

.badge-count {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    border: 2px solid var(--bg);
}

/* ── Hamburger & Sidebar ── */
#hamburgerMenu {
    position: fixed;
    top: 20px;
    left: 20px;
    width: 50px;
    height: 50px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text);
    font-size: 1.5rem;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 3500;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

#hamburgerMenu:hover {
    border-color: var(--primary);
    color: var(--primary);
}

#sidebarOverlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 3900;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#sidebarOverlay.active {
    display: block;
    opacity: 1;
}

#desktopSidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 280px;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border-right: 1px solid var(--border);
    z-index: 4000;
    transform: translateX(-100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    padding: 2rem 1.5rem;
}

#desktopSidebar.open {
    transform: translateX(0);
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3rem;
}

.sidebar-header h2 {
    font-size: 1.5rem;
    background: linear-gradient(135deg, var(--primary), #a855f7);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.close-sidebar {
    background: none;
    border: none;
    color: var(--dim);
    font-size: 1.2rem;
    cursor: pointer;
    transition: color 0.2s;
}

.close-sidebar:hover {
    color: var(--text);
}

.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border-radius: 12px;
    cursor: pointer;
    color: var(--dim);
    transition: all 0.2s;
    font-weight: 500;
}

.nav-item:hover {
    background: rgba(56, 189, 248, 0.1);
    color: var(--primary);
}

.nav-item.active {
    background: rgba(56, 189, 248, 0.15);
    color: var(--primary);
    border-left: 3px solid var(--primary);
}

.nav-icon {
    font-size: 1.2rem;
}

.sidebar-footer {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

/* ── Responsive rules ── */
@media (min-width: 601px) {
    #hamburgerMenu {
        display: flex;
    }

    #mobileDockContainer {
        display: none !important;
    }

    body {
        padding-top: 80px;
    }
}

@media (max-width: 600px) {
    #activeJobsSheet {
        bottom: 70px;
        transform: translateY(calc(100% - 50px));
        z-index: 1500;
    }

    #activeJobsSheet.open {
        transform: translateY(0);
    }
}

@media (max-width: 650px) {

    /* Body does NOT scroll — each .mobile-view is the scroll container.
       This keeps position:fixed elements (dock, overlays) rock-solid in
       mobile Safari which otherwise jumps them when the address bar hides. */
    body {
        padding: 1.25rem !important;
        padding-bottom: 0 !important;
        padding-right: 1.25rem !important;
        overflow: hidden !important;
        height: 100svh;
        /* svh = stable viewport height, excludes browser chrome */
    }

    h1 {
        font-size: 1.8rem;
    }

    .container {
        max-width: 100%;
        margin: 0;
    }

    header {
        margin-bottom: 1.5rem;
    }

    /* Active jobs sheet sits just above the dock */
    #activeJobsSheet {
        bottom: calc(75px + env(safe-area-inset-bottom));
        transform: translateY(calc(100% - 50px));
        z-index: 2500;
    }

    #activeJobsSheet.open {
        transform: translateY(0);
    }

    /* Each view fills the space above the fixed dock and scrolls on its own */
    .mobile-view {
        height: calc(100svh - 75px - env(safe-area-inset-bottom)) !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch;
        padding: 1.25rem 1rem 1.5rem !important;
    }

    /* Job detail is a full-screen overlay */
    #jobDetailView {
        height: 100svh !important;
        padding-bottom: calc(2rem + env(safe-area-inset-bottom)) !important;
        background: var(--bg);
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 4000;
        overflow-y: auto !important;
    }

    .action-row {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }

    .tabs {
        gap: 0.5rem;
        flex-wrap: nowrap;
        justify-content: flex-start;
        border-bottom: none;
        padding-bottom: 0.5rem;
        overflow-x: auto;
        -ms-overflow-style: none;
        scrollbar-width: none;
    }

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

    .tab {
        padding: 0.5rem 0.8rem;
        font-size: 0.85rem;
        flex: 0 0 auto;
        white-space: nowrap;
        border: 1px solid transparent;
    }

    .tab.active {
        border-bottom: 3px solid var(--primary);
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .checkbox-group {
        grid-template-columns: 1fr;
    }
}