/* CuanBot — shared layout tokens, navbar, utilities (all pages) */
:root {
    --bg-primary: #0a0e17;
    --bg: #0a0e17;
    --bg-card: #111827;
    --bg-card-hover: #1a2235;
    --bg-input: rgba(30, 41, 59, 0.8);
    --border: rgba(255, 255, 255, 0.06);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #a3b4cc;
    --text-dim: #94a3b8;
    --text: #f1f5f9;
    --text2: #94a3b8;
    --muted: #a3b4cc;
    --green: #10b981;
    --green-bg: rgba(16, 185, 129, 0.12);
    --red: #ef4444;
    --red-bg: rgba(239, 68, 68, 0.12);
    --blue: #3b82f6;
    --blue-bg: rgba(59, 130, 246, 0.12);
    --yellow: #f59e0b;
    --yellow-bg: rgba(245, 158, 11, 0.12);
    --purple: #8b5cf6;
    --purple-bg: rgba(139, 92, 246, 0.12);
    --cyan: #06b6d4;
}

/* ── Navbar shell (tanpa backdrop-filter — agar drawer fixed tidak terpotong) ── */
.nav-shell,
.navbar {
    background: #111827;
    border-bottom: 1px solid var(--border);
    padding: 8px 16px;
    min-height: 56px;
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 8px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-shell {
    justify-content: flex-start;
    --nav-h: 56px;
}

.nav-shell.nav-open {
    z-index: 200;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 15px;
    white-space: nowrap;
    text-decoration: none;
    color: var(--text-primary);
    flex-shrink: 0;
}

.nav-brand-icon {
    width: 30px;
    height: 30px;
    background: linear-gradient(135deg, #f59e0b, #10b981);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 0 12px rgba(245, 158, 11, 0.3);
}

.nav-end {
    display: contents;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
    min-width: 0;
    margin-left: auto;
}

.nav-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    margin-left: auto;
}

.nav-ico {
    line-height: 1;
}

.nav-txt {
    line-height: 1.3;
}

/* Hamburger — desktop hidden */
.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 40px;
    height: 40px;
    padding: 8px;
    margin-left: 4px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    cursor: pointer;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}

.nav-toggle-bar {
    display: block;
    width: 100%;
    height: 2px;
    background: var(--text-secondary);
    border-radius: 2px;
    transition: transform 0.2s, opacity 0.2s;
}

.nav-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    top: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 150;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.nav-open ~ .nav-backdrop {
    display: block;
    opacity: 1;
    pointer-events: auto;
}

body.nav-menu-open {
    overflow: hidden;
}

@media (min-width: 769px) {
    .btn-nav .nav-ico {
        display: none;
    }
}

.nav-mode {
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 20px;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
}

.nav-mode--live {
    background: var(--red-bg);
    color: var(--red);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.nav-mode--demo {
    background: var(--yellow-bg);
    color: var(--yellow);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.nav-mode--sim {
    background: var(--purple-bg);
    color: #c4b5fd;
    border: 1px solid rgba(139, 92, 246, 0.3);
}

.nav-user {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    flex-shrink: 0;
}

.btn-nav {
    padding: 5px 11px;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    text-decoration: none;
    color: var(--text-secondary);
    background: transparent;
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    line-height: 1.3;
}

.btn-nav:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.btn-nav.active {
    background: rgba(59, 130, 246, 0.12);
    color: #93c5fd;
    border-color: rgba(59, 130, 246, 0.35);
}

.btn-nav--green { background: var(--green-bg); color: #6ee7b7; border-color: rgba(16, 185, 129, 0.3); }
.btn-nav--cyan { background: rgba(6, 182, 212, 0.12); color: #67e8f9; border-color: rgba(6, 182, 212, 0.3); }
.btn-nav--blue { background: var(--blue-bg); color: #93c5fd; border-color: rgba(59, 130, 246, 0.3); }
.btn-nav--purple { background: var(--purple-bg); color: #c4b5fd; border-color: rgba(139, 92, 246, 0.3); }
.btn-nav--amber { background: rgba(245, 158, 11, 0.12); color: #fcd34d; border-color: rgba(245, 158, 11, 0.3); }
.btn-nav--pink { background: rgba(236, 72, 153, 0.12); color: #f9a8d4; border-color: rgba(236, 72, 153, 0.35); }
.btn-nav--logout { background: var(--red-bg); color: #fca5a5; border-color: rgba(239, 68, 68, 0.3); }

#pwaPushBtn.active {
    background: rgba(16, 185, 129, 0.2);
    color: #6ee7b7;
    border-color: rgba(16, 185, 129, 0.45);
}

.pwa-update-banner {
    position: fixed;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    padding: 10px 18px;
    background: rgba(16, 185, 129, 0.92);
    color: #0a0e17;
    font-size: 13px;
    font-weight: 600;
    border-radius: 999px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    pointer-events: none;
    max-width: 92vw;
    text-align: center;
}

@media (max-width: 1023px) {
    body.tb-has-bottomnav .pwa-update-banner {
        bottom: calc(64px + env(safe-area-inset-bottom, 0px) + 16px);
    }
}

.conn-status {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

.conn-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-muted);
    flex-shrink: 0;
}

.conn-dot.connected {
    background: var(--green);
    box-shadow: 0 0 6px var(--green);
}

/* Page shell */
.page-container {
    max-width: 960px;
    margin: 0 auto;
    padding: 16px 20px 48px;
}

.page-container--wide {
    max-width: 1440px;
}

.page-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 16px;
}

.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-scroll:focus-visible,
.table-wrap:focus-visible,
.tb-table-wrap:focus-visible {
    outline: 2px solid var(--blue, #6366f1);
    outline-offset: 2px;
}

@media (max-width: 768px) {
    .nav-shell,
    .navbar {
        padding: 6px 12px;
        min-height: 48px;
        --nav-h: 48px;
    }

    .nav-brand { font-size: 13px; }
    .nav-brand span { display: inline; }

    .nav-meta {
        gap: 4px;
        margin-left: auto;
        margin-right: 0;
    }

    .nav-meta .conn-status,
    .nav-meta .nav-user {
        display: none;
    }

    .nav-mode {
        font-size: 10px;
        padding: 2px 8px;
    }

    .nav-toggle {
        display: flex;
        flex-shrink: 0;
        position: relative;
        z-index: 210;
    }

    .nav-open .nav-toggle-bar:nth-child(1) {
        transform: translateY(7px) rotate(45deg);
    }

    .nav-open .nav-toggle-bar:nth-child(2) {
        opacity: 0;
    }

    .nav-open .nav-toggle-bar:nth-child(3) {
        transform: translateY(-7px) rotate(-45deg);
    }

    .nav-right {
        position: fixed;
        top: var(--nav-h);
        right: 0;
        bottom: 0;
        width: min(280px, 88vw);
        margin-left: 0;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding: 8px 0 24px;
        background: #111827;
        border-left: 1px solid var(--border);
        box-shadow: -8px 0 32px rgba(0, 0, 0, 0.45);
        z-index: 160;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        transform: translateX(105%);
        visibility: hidden;
        pointer-events: none;
        transition: transform 0.22s ease, visibility 0.22s;
    }

    .nav-open .nav-right {
        transform: translateX(0);
        visibility: visible;
        pointer-events: auto;
    }

    .btn-nav {
        width: 100%;
        justify-content: flex-start;
        padding: 14px 18px;
        font-size: 14px;
        min-height: 48px;
        border-radius: 0;
        border: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.04);
        gap: 12px;
    }

    .btn-nav .nav-ico {
        width: 22px;
        text-align: center;
        font-size: 16px;
        flex-shrink: 0;
    }

    .btn-nav.active {
        background: rgba(59, 130, 246, 0.15);
        border-left: 3px solid var(--blue);
        padding-left: 15px;
    }

    .btn-nav--logout {
        margin-top: 8px;
        border-top: 1px solid var(--border);
    }

    .page-container { padding: 10px 10px 40px; }
}

@media (min-width: 769px) {
    .nav-toggle {
        display: none !important;
    }

    .nav-meta {
        margin-left: 0;
        margin-right: 8px;
    }

    .nav-right {
        margin-left: auto;
    }
}

@media (max-width: 480px) {
    .page-title { font-size: 17px; }
}

/* Visible keyboard focus (global) */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[role="switch"]:focus-visible,
.tb-bottomnav__item:focus-visible,
.tb-sidenav__item:focus-visible,
.tb-settings-chip:focus-visible {
    outline: 2px solid var(--blue, #6366f1);
    outline-offset: 2px;
}

.tb-topbar__brand:focus-visible {
    outline: 2px solid var(--blue, #6366f1);
    outline-offset: 2px;
    border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto !important;
    }
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
