/* ═══════════════════════════════════════════════════════════
   DASHBOARD TOP-BAR — Automated Worx
   Slim navbar for authenticated dashboard pages
   Works with sidebar-shared.css for full dashboard layout
   ═══════════════════════════════════════════════════════════ */

/* ══ ISOLATION: prevent page styles from leaking in ═════ */
.navbar-dashboard,
.navbar-dashboard *,
.navbar-dashboard *::before,
.navbar-dashboard *::after {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    line-height: 1.5;
    letter-spacing: normal;
    text-transform: none;
    font-style: normal;
    box-sizing: border-box;
}
.navbar-dashboard a         { text-decoration: none; outline: none; }
.navbar-dashboard button    { font-family: inherit; }

/* ── Top Bar ─────────────────────────────────────────── */
.navbar-dashboard {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1001;
    height: 56px;
    background: rgba(10, 15, 36, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(14, 242, 255, 0.1);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
}

.nd-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 100%;
}

/* ── Left: Toggle + Brand ────────────────────────────── */
.nd-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nd-sidebar-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: none;
    border: 1px solid rgba(14, 242, 255, 0.15);
    border-radius: 8px;
    cursor: pointer;
    color: #94a3b8;
    font-size: 1.1rem;
    transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.nd-sidebar-toggle:hover {
    color: #0ef;
    border-color: rgba(14, 242, 255, 0.3);
    background: rgba(14, 242, 255, 0.05);
}

.nd-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: #f8fafc;
    font-weight: 600;
    font-size: 1rem;
}

.nd-brand img {
    width: 28px;
    height: 28px;
    border-radius: 6px;
}

.nd-brand-text {
    background: linear-gradient(135deg, #0ef 0%, #3b82f6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 0.95rem;
}

/* ── Center: Page breadcrumb ─────────────────────────── */
.nd-breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #64748b;
    font-size: 0.85rem;
}

.nd-breadcrumb span {
    color: #94a3b8;
}

.nd-breadcrumb .nd-page-title {
    color: #e2e8f0;
    font-weight: 500;
}

.nd-breadcrumb .nd-crumb-link {
    color: #94a3b8;
}

.nd-breadcrumb .nd-crumb-link:hover {
    color: #0ef;
}

/* ── Right: User menu ────────────────────────────────── */
.nd-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* AI credit balance chip */
.nd-balance {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    height: 36px;
    padding: 0 0.75rem;
    border: 1px solid rgba(14, 242, 255, 0.25);
    border-radius: 8px;
    background: rgba(14, 242, 255, 0.06);
    color: #e2e8f0;
    font-size: 0.85rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    transition: border-color 0.2s, background 0.2s;
}
.nd-balance[hidden] { display: none; }
.nd-balance svg { color: #0ef; }
.nd-balance:hover { border-color: #0ef; background: rgba(14, 242, 255, 0.12); }
.nd-balance:focus-visible { outline: 2px solid #0ef; outline-offset: 2px; }
.nd-balance.low { border-color: rgba(245, 158, 11, 0.55); background: rgba(245, 158, 11, 0.1); }
.nd-balance.low svg { color: #f59e0b; }

.nd-notifications {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: none;
    border: 1px solid rgba(14, 242, 255, 0.1);
    border-radius: 8px;
    cursor: pointer;
    color: #94a3b8;
    font-size: 1rem;
    transition: color 0.2s, border-color 0.2s;
}

.nd-notifications:hover {
    color: #0ef;
    border-color: rgba(14, 242, 255, 0.25);
}

.nd-notifications .nd-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 8px;
    height: 8px;
    background: #ef4444;
    border-radius: 50%;
    border: 2px solid #0a0f24;
}

.nd-user-menu {
    position: relative;
}

.nd-user-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: none;
    border: 1px solid rgba(14, 242, 255, 0.1);
    border-radius: 8px;
    padding: 0.35rem 0.75rem 0.35rem 0.35rem;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.nd-user-btn:hover {
    border-color: rgba(14, 242, 255, 0.25);
    background: rgba(14, 242, 255, 0.03);
}

.nd-avatar {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    background: linear-gradient(135deg, #0ef 0%, #3b82f6 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #020617;
    font-size: 0.75rem;
    font-weight: 700;
}

.nd-user-name {
    color: #e2e8f0;
    font-size: 0.85rem;
    font-weight: 500;
}

.nd-user-arrow {
    color: #64748b;
    font-size: 0.6rem;
    transition: transform 0.2s;
}

/* User dropdown */
.nd-user-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: rgba(10, 15, 36, 0.98);
    border: 1px solid rgba(14, 242, 255, 0.15);
    border-radius: 10px;
    min-width: 200px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(15px);
    padding: 0.5rem;
    z-index: 1002;
    animation: ndSlideDown 0.15s ease;
}

@keyframes ndSlideDown {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.nd-user-dropdown.open {
    display: block;
}

.nd-user-dropdown a,
.nd-user-dropdown button {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    padding: 0.6rem 0.75rem;
    color: #cbd5e1;
    text-decoration: none;
    font-size: 0.85rem;
    border-radius: 6px;
    border: none;
    background: none;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s, color 0.15s;
}

.nd-user-dropdown a:hover,
.nd-user-dropdown button:hover {
    background: rgba(14, 242, 255, 0.08);
    color: #f8fafc;
}

.nd-user-dropdown .nd-divider {
    height: 1px;
    background: rgba(14, 242, 255, 0.1);
    margin: 0.35rem 0;
}

.nd-user-dropdown .nd-logout {
    color: #ef4444;
}

.nd-user-dropdown .nd-logout:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #f87171;
}

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 1024px) {
    .nd-sidebar-toggle {
        display: flex;
    }

    .nd-breadcrumb {
        display: none;
    }
}

@media (max-width: 640px) {
    .nd-brand-text {
        display: none;
    }

    .nd-user-name {
        display: none;
    }
}

/* ── Live pill + Autopilot menu (top bar) ───────────────────────────────── */
.nd-live { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border-radius: 999px;
  font-size: .74rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #6ee7b7;
  background: rgba(16,185,129,.08); border: 1px solid rgba(16,185,129,.25); }
.nd-live i { width: 7px; height: 7px; border-radius: 50%; background: #10b981; box-shadow: 0 0 0 0 rgba(16,185,129,.6); }
.nd-live.beat i { animation: ndBeat 1s ease-out; }
.nd-live.stale { color: #94a3b8; background: rgba(148,163,184,.08); border-color: rgba(148,163,184,.25); }
.nd-live.stale i { background: #94a3b8; }
@keyframes ndBeat { 0% { box-shadow: 0 0 0 0 rgba(16,185,129,.7); } 100% { box-shadow: 0 0 0 9px rgba(16,185,129,0); } }
.nd-auto { position: relative; }
.nd-auto-btn { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 .75rem; border-radius: 8px; cursor: pointer;
  font: inherit; font-size: .85rem; font-weight: 600; color: #e2e8f0; background: rgba(148,163,184,.06); border: 1px solid rgba(148,163,184,.25); }
.nd-auto-btn svg { width: 16px; height: 16px; color: #94a3b8; }
.nd-auto-btn.on { border-color: rgba(14,242,255,.45); background: rgba(14,242,255,.08); }
.nd-auto-btn.on svg { color: #0ef; }
.nd-auto-btn.attn { border-color: rgba(245,158,11,.55); }
.nd-auto-btn:focus-visible { outline: 2px solid #0ef; outline-offset: 2px; }
.nd-auto-count { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: #f59e0b; color: #1a1205; font-size: .72rem;
  font-weight: 800; display: inline-grid; place-items: center; }
.nd-auto-count[hidden] { display: none; }
.nd-auto-menu { position: absolute; top: calc(100% + 8px); right: 0; width: 300px; z-index: 1003; padding: 6px;
  background: rgba(10,15,36,.98); border: 1px solid rgba(14,242,255,.18); border-radius: 12px; box-shadow: 0 12px 40px rgba(0,0,0,.5); }
.nd-auto-menu[hidden] { display: none; }
.nd-auto-row { display: flex; gap: 10px; align-items: flex-start; padding: 10px; border-radius: 8px; color: #e2e8f0; font-size: .86rem;
  text-decoration: none; cursor: pointer; }
.nd-auto-row:hover { background: rgba(14,242,255,.06); }
.nd-auto-row input { margin-top: 3px; accent-color: #0ef; width: 16px; height: 16px; flex: none; }
.nd-auto-row small { display: block; color: #94a3b8; font-size: .76rem; font-weight: 400; margin-top: 2px; }
.nd-auto-row strong { color: #0ef; margin-right: 4px; }
.nd-auto-waiting strong { color: #f59e0b; }
@media (max-width: 760px) { .nd-live span, .nd-auto-label { display: none; } .nd-auto-menu { position: fixed; left: 12px; right: 12px; width: auto; top: 60px; } }

/* Ticker flash when a live number changes */
.aw-tick-up { animation: awTickUp 1.2s ease-out; }
.aw-tick-down { animation: awTickDown 1.2s ease-out; }
@keyframes awTickUp { 0% { color: #34d399; text-shadow: 0 0 12px rgba(52,211,153,.6); } 100% { text-shadow: none; } }
@keyframes awTickDown { 0% { color: #f87171; text-shadow: 0 0 12px rgba(248,113,113,.5); } 100% { text-shadow: none; } }
@media (prefers-reduced-motion: reduce) { .nd-live.beat i, .aw-tick-up, .aw-tick-down { animation: none; } }

/* Voice mode button (js/voice.js) */
.aw-voice-btn.on { background: rgba(239,68,68,.16); border-color: rgba(239,68,68,.5); color: #fecaca; animation: awVoicePulse 1.6s ease-in-out infinite; }
@keyframes awVoicePulse { 50% { box-shadow: 0 0 0 5px rgba(239,68,68,.15); } }
@media (prefers-reduced-motion: reduce) { .aw-voice-btn.on { animation: none; } }

/* ── Credits banner (js/navbar-dashboard.js creditBanner): hard at 0, soft under 100 ── */
.nd-credit-banner { position: fixed; top: 56px; left: 0; right: 0; z-index: 1000; display: flex; align-items: center; gap: 12px;
  padding: 9px 1.5rem; font-size: .88rem; line-height: 1.4; color: #fde68a; background: #2a1f05; border-bottom: 1px solid rgba(245,158,11,.5); }
.nd-credit-banner.empty { color: #fecaca; background: #3a0d12; border-bottom-color: rgba(248,113,113,.6); }
.nd-credit-banner strong { color: #fff; }
.nd-cb-text { flex: 1; min-width: 0; }
.nd-credit-banner .nd-cb-btn { flex: none; display: inline-flex; align-items: center; min-height: 36px; padding: 0 14px; border-radius: 8px; font-weight: 700;
  color: #00131b; background: linear-gradient(135deg, #0ef 0%, #3b82f6 100%); }
.nd-credit-banner a, .nd-credit-banner a:hover { text-decoration: none; }
.nd-credit-banner .nd-cb-btn:focus-visible, .nd-cb-x:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.nd-cb-x { flex: none; width: 36px; height: 36px; border: 0; border-radius: 8px; background: transparent; color: inherit; font-size: 1.4rem; cursor: pointer; }
body.nd-has-banner { padding-top: var(--nd-banner-h, 0px); }
body.nd-has-banner .dash-sidebar { top: calc(56px + var(--nd-banner-h, 0px)); }
@media (max-width: 640px) { .nd-credit-banner { padding: 8px 10px; gap: 8px; font-size: .82rem; } }

/* ── Phones: fit the whole top bar in 390px, 40px tap targets, roomier drawer links ── */
@media (max-width: 640px) {
    .navbar-dashboard { padding: 0 10px; }
    .nd-left { gap: .5rem; }
    .nd-right { gap: 6px; }
    .nd-sidebar-toggle, .nd-notifications { width: 44px; height: 44px; min-width: 44px; flex: none; }
    .nd-auto-btn, .nd-balance { height: 44px; min-width: 44px; justify-content: center; }
    .nd-balance { padding: 0 .6rem; font-size: .8rem; }
    .nd-user-arrow { display: none; }
    .nd-user-btn { padding: .2rem; min-height: 44px; min-width: 44px; }
    .nd-brand { padding: 0; margin: 0; min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
    .nd-left { gap: 2px; }
    .nd-right { gap: 4px; }
    .nd-live { height: 28px; padding: 0 8px; }
    /* Bell and avatar were clipped off the right edge: drop the word "credits" (the number and icon stay,
       the full balance is in the chip's label) and let the right group shrink instead of overflow. */
    .nd-balance-unit { display: none; }
    .nd-right { min-width: 0; flex-shrink: 1; }
    .nd-left { flex-shrink: 0; }
    .nd-container { min-width: 0; gap: 6px; }
}
@media (max-width: 400px) {
    .nd-live { display: none; }
    .nd-auto-btn { padding: 0 .55rem; }
}
@media (max-width: 1024px) {
    .nd-sidebar-toggle, .nd-notifications { width: 44px; height: 44px; min-width: 44px; flex: none; }
    .nd-auto-btn, .nd-balance { height: 44px; min-width: 44px; justify-content: center; }
    .dash-sidebar .ds-nav a { min-height: 44px; }
    .dash-sidebar .ds-section-title { min-height: 44px; }
    .nd-user-dropdown a, .nd-user-dropdown button { min-height: 44px; }
    .nd-auto-row { min-height: 44px; }
    .dash-sidebar .ds-section-title span { font-size: .75rem; }
    .dash-sidebar .ds-footer .ds-website { display: flex; align-items: center; min-height: 44px; padding: 0; }
    aside.dash-sidebar .ds-scroll { overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
}
/* Short screens (a phone on its side, a small phone with the keyboard up): the pinned footer would leave almost no room for
   the menu, so the whole drawer scrolls as one list and every entry can be reached. */
@media (max-width: 1024px) and (max-height: 760px) {
    aside.dash-sidebar { overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
    aside.dash-sidebar .ds-scroll { flex: none; overflow: visible; }
}

/* Approvals inside the autopilot menu */
.nd-auto-list:empty { display: none; }
.nd-auto-list { display: grid; gap: 6px; padding: 4px 6px 8px; max-height: 50vh; overflow-y: auto; }
.nd-ap { border: 1px solid rgba(255,255,255,.08); border-radius: 8px; padding: 8px 10px; background: rgba(255,255,255,.02); }
.nd-ap-text { color: #e2e8f0; font-size: .84rem; line-height: 1.35; }
.nd-ap-text strong { color: #fff; }
.nd-ap-id { color: #94a3b8; font-size: .76rem; }
.nd-ap-btns { display: flex; gap: 8px; margin-top: 8px; }
.nd-ap-btns button { min-height: 44px; flex: 1; border-radius: 8px; font-weight: 600; font-size: .86rem; cursor: pointer; border: 1px solid transparent; }
.nd-ap-ok { background: #0ef2ff; color: #04121a; }
.nd-ap-no { background: transparent; color: #fca5a5; border-color: rgba(252,165,165,.45); }
.nd-ap-btns button:disabled { opacity: .5; cursor: default; }

/* ═══ App-like phone fit (2026-10-04h) ═══════════════════════════════════════════════════════════
   Every signed-in page: the top bar, the drawer and the pages themselves sit inside the notch / home-bar
   safe areas (pages declare viewport-fit=cover), nothing scrolls sideways, inputs are 16px so iOS never zooms,
   taps answer instantly, and wide tables scroll inside their own box instead of widening the page. */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
a, button, [role="button"], input, select, textarea, label, summary { touch-action: manipulation; }
@media (hover: none) { a, button, [role="button"] { -webkit-tap-highlight-color: rgba(14, 242, 255, .12); } }
.navbar-dashboard { padding-left: max(1.5rem, env(safe-area-inset-left)); padding-right: max(1.5rem, env(safe-area-inset-right)); }
.nd-credit-banner { padding-left: max(1.5rem, env(safe-area-inset-left)); padding-right: max(1.5rem, env(safe-area-inset-right)); }
@media (max-width: 1024px) {
    aside.dash-sidebar { width: min(300px, 86vw); max-width: 100vw; padding-left: env(safe-area-inset-left); overscroll-behavior: contain; }
    aside.dash-sidebar .ds-footer { padding-bottom: calc(.75rem + env(safe-area-inset-bottom)); }
    .dash-overlay { -webkit-tap-highlight-color: transparent; }
}
@media (max-width: 640px) {
    .navbar-dashboard { padding-left: max(10px, env(safe-area-inset-left)); padding-right: max(10px, env(safe-area-inset-right)); }
    .nd-credit-banner { padding-left: max(10px, env(safe-area-inset-left)); padding-right: max(10px, env(safe-area-inset-right)); }
    /* 16px form text: iOS zooms the page on focus for anything smaller */
    input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]),
    select, textarea { font-size: 16px !important; }
    /* Wide tables scroll inside themselves, never the page */
    .table-wrap, .tbl-wrap, .table-scroll { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    main table:not(.nd-keep), .dashboard-wrapper table:not(.nd-keep), .container table:not(.nd-keep) { max-width: 100%; }
    /* Panels that pop over the page: user and autopilot menus stay on screen */
    .nd-user-dropdown { position: fixed; top: 60px; right: max(10px, env(safe-area-inset-right)); left: auto; min-width: 0; width: min(280px, calc(100vw - 20px)); max-height: calc(100vh - 76px); overflow-y: auto; }
    .nd-auto-menu { left: max(10px, env(safe-area-inset-left)); right: max(10px, env(safe-area-inset-right)); max-height: calc(100vh - 76px); overflow-y: auto; overscroll-behavior: contain; }
}
@supports (height: 100dvh) {
    @media (max-width: 640px) {
        .nd-user-dropdown, .nd-auto-menu { max-height: calc(100dvh - 76px); }
    }
}
/* Bell badge: the unread count sat as loose text beside the bell; make it a real pill pinned to the corner */
.nd-notifications .nd-badge { width: auto; min-width: 16px; height: 16px; padding: 0 4px; display: grid; place-items: center; font-size: .66rem; font-weight: 700; line-height: 1; color: #fff; top: -4px; right: -4px; }
.nd-notifications .nd-badge:empty { display: none; }
@media (max-width: 640px) {
    /* one 16px gutter on every signed-in page that uses the design-system dashboard shell */
    .aw-dash .aw-dash-main { padding: 20px max(16px, env(safe-area-inset-right)) calc(40px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
}
@media (max-width: 640px) {
    /* a multi-line box must show more than half a line */
    textarea { min-height: 5.5rem; }
}
