/**
 * DESKTOP FRAMELESS WINDOW STYLES
 * Zoom-Style 3-Zone Layout (Left | Center | Right)
 */

/* ===== HEADER HEIGHT VARIABLE ===== */
:root {
    --header-height: 50px;
}

/* ──────────────────────────────────────────────────────────────────
   DRAG REGIONS — DO NOT SCATTER THESE RULES ELSEWHERE
   Chromium focus traps occur when drag is nested inside no-drag.
   All -webkit-app-region declarations live here and only here.
   Before adding a new drag rule, check the nesting below.

   DRAG (titlebar, draggable toolbar areas):
     #title-bar                    { -webkit-app-region: drag; }

   NO-DRAG (interactive elements inside drag areas):
     .tb-left                      { -webkit-app-region: no-drag; }
     .company-select               { -webkit-app-region: no-drag; }
     .header-company-dropdown      { -webkit-app-region: no-drag; }
     .tb-center                    { -webkit-app-region: no-drag; }
     .tb-center .nav-item          { -webkit-app-region: no-drag; }
     .tb-right                     { -webkit-app-region: no-drag; }
     .user-dropdown                { -webkit-app-region: no-drag; }
     .window-controls              { -webkit-app-region: no-drag; }
     .window-controls .control-btn { -webkit-app-region: no-drag; }
     .update-bell-btn              { -webkit-app-region: no-drag; }

   INPUT FOCUS TRAP PREVENTION (Chromium frameless window bug fix):
     input, textarea, select, button, [contenteditable],
     .alzar-input, .alzar-select, .form-control, .form-select
                                   { -webkit-app-region: no-drag !important; }
     button, [role="button"], .btn, .btn-icon, .nav-item
                                   { -webkit-app-region: no-drag !important; }
     .alzar-modal, .modal-backdrop, .offcanvas-backdrop, .cfo-popup-overlay,
     [class*="modal"], [class*="overlay"], [class*="backdrop"]
                                   { -webkit-app-region: no-drag !important; }
     #main-content, .view-container, .view-content, .app-sidebar, #app-sidebar
                                   { -webkit-app-region: no-drag !important; }
   ────────────────────────────────────────────────────────────────── */

/* AUDIT: native OS drag region — do not tokenize */
#title-bar                    { -webkit-app-region: drag; }
.tb-left                      { -webkit-app-region: no-drag; }
.company-select               { -webkit-app-region: no-drag; }
.header-company-dropdown      { -webkit-app-region: no-drag; }
.tb-center                    { -webkit-app-region: no-drag; }
.tb-center .nav-item          { -webkit-app-region: no-drag; }
.tb-right                     { -webkit-app-region: no-drag; }
.user-dropdown                { -webkit-app-region: no-drag; }
.window-controls              { -webkit-app-region: no-drag; }
.window-controls .control-btn { -webkit-app-region: no-drag; }
.update-bell-btn              { -webkit-app-region: no-drag; }

/* Input focus trap prevention — -webkit-app-region moved here from BUG FIX section */
input,
textarea,
select,
button,
[contenteditable],
.alzar-input,
.alzar-select,
.form-control,
.form-select                  { -webkit-app-region: no-drag !important; }
button,
[role="button"],
.btn,
.btn-icon,
.nav-item                     { -webkit-app-region: no-drag !important; }
.alzar-modal,
.modal-backdrop,
.offcanvas-backdrop,
.cfo-popup-overlay,
[class*="modal"],
[class*="overlay"],
[class*="backdrop"]           { -webkit-app-region: no-drag !important; }
#main-content,
.view-container,
.view-content,
.app-sidebar,
#app-sidebar                  { -webkit-app-region: no-drag !important; }

/* ===== TITLE BAR - MAIN CONTAINER ===== */
body.platform-electron #title-bar {
    position: relative;
    width: 100%;
    height: var(--header-height);
    flex: 0 0 auto;
    background: var(--color-bg-surface);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: nowrap;
    padding: 0 12px;
    /* -webkit-app-region moved to DRAG REGIONS section at top of file */
    user-select: none;
    border-bottom: 1px solid var(--overlay-active);
    z-index: var(--z-index-dropdown);
    box-sizing: border-box;
}

/* ===== LEFT ZONE ===== */
body.platform-electron .tb-left {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0; /* Left zone must NEVER shrink */
    /* -webkit-app-region moved to DRAG REGIONS section at top of file */
}

body.platform-electron .app-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #ffffff;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.5px;
    /* shell-layout.css .alzar-brand-icon sets width:36px/height:36px which collapses
       the logo-text span. Override here so the logo takes its natural content width. */
    width: auto;
    height: auto;
    white-space: nowrap;
    min-width: max-content;
    position: relative;
    margin: 0;
}

body.platform-electron .app-logo i {
    font-size: 20px;
    color: var(--color-primary);
}

body.platform-electron .app-logo .logo-text {
    font-size: 14px;
}

.company-select {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    background: var(--overlay-active);
    border-radius: var(--radius-ui);
    color: rgba(255, 255, 255, 0.9);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease, box-shadow 0.2s ease;
    /* -webkit-app-region moved to DRAG REGIONS section at top of file */
    position: relative;
    margin-left: 0;
}

.company-select:hover {
    background: rgba(255, 255, 255, 0.14);
    box-shadow: 0 0 0 1px var(--overlay-active);
}

.company-select:active {
    background: rgba(255, 255, 255, 0.18);
}

.company-select i {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
    transition: transform 0.2s ease;
}

.company-select:hover i {
    color: rgba(255, 255, 255, 0.8);
}

/* ===== HEADER COMPANY DROPDOWN ===== */
.company-select {
    position: relative; /* anchor for dropdown */
}

.header-company-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 220px;
    background: #383838;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-ui);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    padding: 4px;
    z-index: var(--z-index-modal);
    /* -webkit-app-region moved to DRAG REGIONS section at top of file */
}

.header-company-dropdown.open {
    display: flex;
    flex-direction: column;
}

.hcd-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 12px;
    background: transparent;
    border: none;
    border-radius: var(--radius-ui);
    color: rgba(255, 255, 255, 0.85);
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s ease;
    text-align: left;
    width: 100%;
}

.hcd-option:hover {
    background: rgba(255, 255, 255, 0.1);
}

.hcd-option.active {
    background: rgba(52, 152, 219, 0.2);
    color: #ffffff;
}

.hcd-option.active i {
    color: var(--color-active);
    font-size: 14px;
}

.hcd-name {
    flex: 1;
}

/* ===== CENTER ZONE - FLEX-BASED NAVIGATION ===== */
body.platform-electron .tb-center {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1 1 auto; /* Grow and shrink to fill available space */
    min-width: 0; /* allows flex child to shrink below content size */
    overflow: hidden; /* prevents bleeding into .tb-right */
    justify-content: flex-start; /* Force clipping on right side only - prevents left-slide under logo */
    /* -webkit-app-region moved to DRAG REGIONS section at top of file */
}

/* Lock all nav items to prevent internal squishing */
body.platform-electron .tb-center > * {
    flex-shrink: 0;
}

body.platform-electron .tb-center .nav-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: rgba(255, 255, 255, 0.65);
    font-size: 13px;
    font-weight: 400;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, border-bottom-color 0.2s ease;
    will-change: background, color, border-bottom-color;
    /* -webkit-app-region moved to DRAG REGIONS section at top of file */
    margin: 0 2px;
    width: auto;
    white-space: nowrap;
    flex-shrink: 0;
}

body.platform-electron .tb-center .nav-item i {
    font-size: 16px;
    opacity: 0.8;
}

body.platform-electron .tb-center .nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.9);
}

body.platform-electron .tb-center .nav-item.active {
    background: var(--color-primary-dim);
    color: #ffffff;
    border-bottom-color: var(--color-primary);
    border-right: none;
}

body.platform-electron .tb-center .nav-item.active i {
    opacity: 1;
    color: var(--color-primary);
}

/* ===== RIGHT ZONE ===== */
body.platform-electron .tb-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0; /* Right zone must NEVER shrink */
    /* -webkit-app-region moved to DRAG REGIONS section at top of file */
}

.tb-global-search {
    position: relative;
    display: flex;
    align-items: center;
    width: 160px;
    min-width: 0;
    flex-shrink: 1;
    transition: width 0.2s ease;
}

.tb-global-search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255, 255, 255, 0.55);
    font-size: 14px;
    pointer-events: none;
    z-index: 1;
}

.tb-global-search-input {
    width: 100%;
    height: 34px;
    padding: 0 12px 0 30px;
    border-radius: var(--radius-ui);
    border: 1px solid rgba(255, 255, 255, 0.10);
    background: var(--overlay-active);
    color: rgba(255, 255, 255, 0.92);
    font-size: 12px;
    transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.tb-global-search-input::placeholder {
    color: rgba(255, 255, 255, 0.42);
}

.tb-global-search-input:hover {
    background: rgba(255, 255, 255, 0.10);
}

.tb-global-search-input:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(34, 197, 94, 0.45);
    box-shadow: 0 0 0 3px var(--color-primary-dim);
}

.tb-global-search-results {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 260px;
    background: #383838;
    border: 1px solid var(--overlay-active);
    border-radius: var(--radius-ui);
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.35);
    overflow: hidden;
    z-index: var(--z-index-toast);
}

.tb-search-result {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--overlay-active);
    color: rgba(255, 255, 255, 0.86);
    text-align: left;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.tb-search-result:last-child {
    border-bottom: none;
}

.tb-search-result:hover,
.tb-search-result.active {
    background: var(--overlay-active);
    color: #ffffff;
}

.tb-search-result i {
    font-size: 16px;
    color: var(--color-primary);
}

.tb-search-result-main {
    display: block;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.2;
}

.tb-search-result-sub {
    display: block;
    font-size: 11px;
    color: var(--color-text-muted);
    margin-top: 2px;
}

.tb-search-empty {
    padding: 12px;
    color: var(--color-text-muted);
    font-size: 12px;
}

.tb-search-section-label {
    padding: 9px 12px 7px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.45);
    background: var(--overlay-hover);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.tb-search-section-label:first-child {
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 4px;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s ease;
}

.user-profile:hover {
    background: var(--overlay-active);
}

.user-profile .user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-primary), var(--color-active));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    font-weight: 600;
    overflow: hidden;
}

.user-profile .user-avatar img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

/* User name removed - avatar only */

/* ===== USER DROPDOWN MENU ===== */
.user-profile {
    position: relative;
}

.user-dropdown {
    display: none;
    position: fixed;   /* fixed escapes overflow:hidden and stacking contexts */
    top: 60px;         /* fallback; overridden by JS on open */
    right: 20px;       /* fallback; overridden by JS on open */
    width: 280px;
    background: var(--color-bg-elevated);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-ui);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
    z-index: var(--z-index-critical-overlay);
    /* -webkit-app-region moved to DRAG REGIONS section at top of file */
    overflow: hidden;
}
.user-dropdown.open {
    display: block;
}

/* ── Header (user info) ── */
.ud-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border-bottom: 1px solid var(--overlay-active);
}
.ud-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-primary), var(--color-active));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    flex-shrink: 0;
}
.ud-info {
    min-width: 0;
}
.ud-name {
    color: #fff;
    font-weight: 600;
    font-size: 14px;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ud-email {
    color: rgba(255, 255, 255, 0.45);
    font-size: 12px;
    margin: 2px 0 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ud-role {
    display: inline-block;
    margin-top: 4px;
    padding: 1px 8px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .04em;
    border-radius: 4px;
    background: var(--overlay-active);
    color: rgba(255, 255, 255, 0.5);
}

/* ── Section (tenant list) ── */
.ud-section {
    padding: 8px;
    border-bottom: 1px solid var(--overlay-active);
}
.ud-section-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: rgba(255, 255, 255, 0.35);
    padding: 4px 8px 6px;
    margin: 0;
}

/* ── Tenant buttons ── */
.ud-tenant-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 10px;
    background: transparent;
    border: none;
    border-radius: var(--radius-ui);
    color: rgba(255, 255, 255, 0.8);
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s ease;
    text-align: left;
    position: relative;
}
.ud-tenant-btn:hover {
    background: var(--overlay-active);
}
.ud-tenant-btn.active {
    background: rgba(var(--color-primary-rgb, 52, 152, 219), 0.15);
}
.ud-tenant-icon {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-ui);
    background: var(--overlay-active);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}
.ud-tenant-name {
    font-weight: 500;
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ud-tenant-tag {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.35);
    display: none; /* shown on wider dropdowns if needed */
}
.ud-check {
    color: var(--color-primary);
    font-size: 16px;
    margin-left: auto;
    flex-shrink: 0;
}

/* ── Footer (sign out) ── */
.ud-footer {
    padding: 8px;
}
.ud-logout-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 10px;
    background: transparent;
    border: none;
    border-radius: var(--radius-ui);
    color: var(--color-text-muted);
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    text-align: left;
}
.ud-logout-btn:hover {
    background: var(--color-bg-hover);
    color: var(--color-text-main);
}
/* Sign-out specifically keeps a danger hover */
button.ud-logout-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

/* ── HQ Dashboard Link ── */
.ud-hq-link {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 10px;
    border-radius: var(--radius-ui);
    color: var(--color-primary);
    font-size: 13px;
    text-decoration: none;
    transition: background 0.15s ease;
}
.ud-hq-link:hover {
    background: var(--color-bg-hover);
}

/* ── Brightness Toggle Row ── */
.ud-brightness-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    border-radius: var(--radius-ui);
    transition: background 0.15s;
}
.ud-brightness-row:hover {
    background: var(--color-bg-hover);
}
.ud-brightness-label {
    font-size: 13px;
    color: var(--color-text-main);
    display: flex;
    align-items: center;
    gap: 6px;
    opacity: 0.85;
}
.ud-brightness-toggle {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    flex-shrink: 0;
}
.ud-toggle-track {
    display: inline-flex;
    align-items: center;
    width: 34px;
    height: 18px;
    border-radius: 9px;
    background: var(--color-border);
    position: relative;
    transition: background 0.2s;
}
.ud-brightness-toggle.on .ud-toggle-track {
    background: var(--color-primary);
}
.ud-toggle-thumb {
    position: absolute;
    left: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #fff;
    transition: transform 0.2s;
    will-change: transform;
}
.ud-brightness-toggle.on .ud-toggle-thumb {
    transform: translateX(16px);
}

/* ===== WINDOW CONTROLS ===== */
.window-controls {
    display: flex;
    gap: 0;
    /* -webkit-app-region moved to DRAG REGIONS section at top of file */
}

.window-controls .control-btn {
    width: 46px;
    height: 48px;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    will-change: background, color;
    display: flex;
    align-items: center;
    justify-content: center;
    /* -webkit-app-region moved to DRAG REGIONS section at top of file */
}

.window-controls .control-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.window-controls .control-btn.close:hover {
    background: #e74c3c;
    color: #ffffff;
}

/* ===== ELECTRON ONLY: App shell is flex-column (title bar + viewport) ===== */
body.platform-electron #app-shell {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

body.platform-electron #app-viewport {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    background: #0f172a;
    padding-bottom: 40px;
}

/* ===== FIX: Main Content Fills Remaining Space ===== */
body.platform-electron #main-content {
    margin-top: 0;
    padding-top: 20px;
    flex: 1;
    overflow-y: auto;
    background-color: #0f172a; /* dark blue — no footer gap */
    width: 100%;
    box-sizing: border-box;
}

body.platform-electron #title-bar {
    height: var(--header-height);
    flex: 0 0 var(--header-height);
}

/* ===== 🚫 ELECTRON ONLY: Hide sidebar — nav lives in the title bar ===== */
body.platform-electron #app-sidebar,
body.platform-electron #sidebar,
body.platform-electron aside#app-sidebar,
body.platform-electron nav.sidebar,
body.platform-electron .sidebar-container,
body.platform-electron .sidebar-menu,
body.platform-electron .alzar-sidebar-header,
body.platform-electron .sidebar-footer {
    display: none !important;
    visibility: hidden !important;
    width: 0;
    height: 0;
    opacity: 0;
    pointer-events: none;
}

/* ===== ELECTRON ONLY: Flex column layout (no sidebar grid) ===== */
body.platform-electron #app-shell,
body.platform-electron #app-shell.shell-expanded,
body.platform-electron #app-shell.shell-collapsed {
    display: flex;
    flex-direction: column;
    grid-template-columns: none;
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
}

/* ===== ELECTRON ONLY: Full-width viewport (no sidebar column) ===== */
body.platform-electron #app-viewport,
body.platform-electron #main-content,
body.platform-electron .main-wrapper {
    margin-left: 0;
    margin-right: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    position: relative;
}

/* ===== BODY — BASE SHELL ===== */
body.platform-electron {
    overflow: hidden;
    height: 100vh;
    background-color: #0f172a; /* prevent bleed */
    display: flex;
    flex-direction: column;
}

/* ===== SCROLLBAR STYLING ===== */
@media not all and (min-resolution:.001dpcm) {
    @supports (-webkit-appearance:none) {
        #app-viewport::-webkit-scrollbar {
            width: 10px;
        }

        #app-viewport::-webkit-scrollbar-track {
            background: #e0e0e0;
        }

        #app-viewport::-webkit-scrollbar-thumb {
            background: #888;
            border-radius: 5px;
        }

        #app-viewport::-webkit-scrollbar-thumb:hover {
            background: #555;
        }
    }
}

/* ===== WEB MODE: Hide title-bar entirely — logo lives in #app-topbar ===== */
body:not(.platform-electron) #title-bar {
    display: none;
}

/* ===== ELECTRON MODE: Hide duplicate brand in topbar (title-bar already has it) ===== */
body.platform-electron .topbar-brand {
    display: none;
}

body.platform-electron #app-shell {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

body.platform-electron #title-bar {
    flex: 0 0 var(--header-height);
}

/* ===== DESKTOP MODE: Show Window Controls ===== */
body.platform-electron .window-controls {
    display: flex;
}

/* ===========================
   SOG PLATFORM MODE TOGGLE (Profile Dropdown)
   Segmented control rendered inside #user-dropdown.
   Visible only when window.SOG_ADMIN_MODE === true.
   =========================== */

/* Section separator — border-top above Platform Mode */
.ud-platform-section {
    border-top: 1px solid rgba(255, 255, 255, 0.10);
}

/* Segmented toggle container */
.ud-platform-toggle {
    display: flex;
    gap: 3px;
    padding: 4px;
    background: rgba(0, 0, 0, 0.22);
    border-radius: var(--radius-ui);
    margin: 2px 0 4px;
}

/* Individual pill — flex: 1 so both halves share width equally */
.ud-platform-pill {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 8px;
    border: none;
    border-radius: 7px;
    background: transparent;
    color: rgba(255, 255, 255, 0.45);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
    white-space: nowrap;
}
.ud-platform-pill i {
    font-size: 13px;
}
.ud-platform-pill:hover:not(.active) {
    background: rgba(255, 255, 255, 0.07);
    color: rgba(255, 255, 255, 0.75);
}

/* Global HQ — Purple active state */
.ud-platform-pill.hq.active {
    background: #6b21a8;
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(107, 33, 168, 0.45);
}

/* Impersonate — Amber active state */
.ud-platform-pill.impersonate.active {
    background: #d97706;
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(217, 119, 6, 0.45);
}

/* PII blur mask (body-level, toggled by sog-hq-command.js) */
body.sog-pii-mask [data-pii] {
    filter: blur(6px);
    transition: filter 0.2s ease;
    user-select: none;
    pointer-events: none; /* prevent clicks/copy while masked */
}

/* ===========================
   RESPONSIVE NAVIGATION
   =========================== */

/* Hamburger Menu Button (hidden on desktop) */
.hamburger-menu {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    border-radius: var(--radius-ui);
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
    margin-left: 8px;
}

.hamburger-menu:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.hamburger-menu i {
    font-size: 24px;
}

/* Mobile Navigation Drawer (hidden by default) */
.mobile-nav-drawer {
    display: block; /* Changed from 'none' - visibility controlled by pointer-events and transforms */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    pointer-events: none;
    visibility: hidden; /* Added to fully hide when not active */
}

.mobile-nav-drawer.is-active {
    pointer-events: all;
    visibility: visible; /* Added to show when active */
}

/* Dark Overlay */
.mobile-nav-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    opacity: 0;
    transition: opacity 0.3s ease;
    will-change: opacity;
}

.mobile-nav-drawer.is-active .mobile-nav-overlay {
    opacity: 1;
}

/* Drawer Panel */
.mobile-nav-content {
    position: absolute;
    top: 0;
    left: 0;
    width: 280px;
    height: 100%;
    background: var(--color-bg-surface);
    box-shadow: 4px 0 12px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    will-change: transform;
}

.mobile-nav-drawer.is-active .mobile-nav-content {
    transform: translateX(0);
}

/* Drawer Header */
.mobile-nav-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    min-height: 60px;
}

.mobile-nav-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.mobile-nav-brand .app-logo {
    font-size: 18px;
    font-weight: 700;
    color: #00D9FF;
}

.mobile-nav-title {
    font-size: 16px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.8);
}

.mobile-nav-close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-ui);
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
}

.mobile-nav-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.mobile-nav-close i {
    font-size: 20px;
}

/* Mobile Nav Links */
.mobile-nav-links {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.mobile-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 14px 16px;
    background: transparent;
    border: none;
    border-radius: var(--radius-ui);
    color: rgba(255, 255, 255, 0.7);
    font-size: 15px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
}

.mobile-nav-item:hover {
    background: var(--overlay-active);
    color: rgba(255, 255, 255, 0.9);
}

.mobile-nav-item.active {
    background: rgba(0, 217, 255, 0.15);
    color: #00D9FF;
}

.mobile-nav-item i {
    font-size: 22px;
    flex-shrink: 0;
}

/* ===========================
   RESPONSIVE BREAKPOINTS
   =========================== */

@media (max-width: 1023px) {
    /* Hide desktop navigation */
    body.platform-electron .tb-center {
        display: none;
    }

    /* Show hamburger menu */
    .hamburger-menu {
        display: flex;
    }

    /* Show mobile drawer */
    .mobile-nav-drawer {
        display: block;
    }

    /* User profile already condensed to avatar only */

    .user-profile {
        padding: 4px;
        min-width: auto;
    }

    /* .user-dropdown uses position:fixed; JS sets top/right on open */

    /* Adjust left zone spacing for mobile */
    .tb-left {
        gap: 8px;
    }

    /* Make company selector more compact */
    .company-select {
        max-width: 140px;
    }

    #header-company-name {
        font-size: 13px;
    }
}

/* ===== NAV ICONS-ONLY MODE (JS-driven auto-collapse) ===== */
#title-bar.nav-icons-only .tb-center .nav-item span {
    display: none;
}

#title-bar.nav-icons-only .tb-center .nav-item {
    padding: 6px 10px;
    gap: 0;
}

/* User name removed - no style needed */

#title-bar.nav-icons-only .tb-global-search {
    width: 34px;
    min-width: 34px;
}

#title-bar.nav-icons-only .tb-global-search-input {
    padding-left: 30px;
    color: transparent;
}

#title-bar.nav-icons-only .tb-global-search-input::placeholder {
    color: transparent;
}

#title-bar.nav-icons-only .tb-global-search:focus-within {
    width: 180px;
    min-width: 180px;
}

#title-bar.nav-icons-only .tb-global-search:focus-within .tb-global-search-input {
    color: rgba(255, 255, 255, 0.92);
}

#title-bar.nav-icons-only .tb-global-search:focus-within .tb-global-search-input::placeholder {
    color: rgba(255, 255, 255, 0.42);
}

/* ===== COMPACT-MODE (JS tier-2: hamburger when even icons overflow) ===== */
#title-bar.compact-mode .tb-center {
    display: none;
}

#title-bar.compact-mode .hamburger-menu {
    display: flex;
}

/* ============================================================
   🔔 UPDATE BELL — header notification widget
   ============================================================ */
#update-bell-wrap {
    display: flex;
    align-items: center;
    position: relative;
}

.update-bell-btn {
    position: relative;
    background: none;
    border: none;
    color: var(--color-text-muted);
    font-size: 18px;
    width: 34px;
    height: 34px;
    border-radius: var(--radius-ui);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    /* -webkit-app-region moved to DRAG REGIONS section at top of file */
}
.update-bell-btn:hover {
    background: var(--overlay-active);
    color: var(--color-text-main);
}

/* Shake animation when update available */
.update-bell-btn.ub-animate i {
    animation: bell-shake 1.2s ease infinite;
    transform-origin: top center;
    will-change: transform;
    color: var(--color-active);
}
@keyframes bell-shake {
    0%,100% { transform: rotate(0deg); }
    10%      { transform: rotate(12deg); }
    20%      { transform: rotate(-10deg); }
    30%      { transform: rotate(8deg); }
    40%      { transform: rotate(-6deg); }
    50%      { transform: rotate(0deg); }
}

/* Pulse animation when ready to install */
.update-bell-btn.ub-pulse i {
    animation: none;
    color: var(--color-primary);
}
.update-bell-btn.ub-pulse {
    animation: bell-pulse 1.8s ease infinite;
    will-change: box-shadow;
}
@keyframes bell-pulse {
    0%,100% { box-shadow: 0 0 0 0 rgba(34,197,94,0.5); }
    50%      { box-shadow: 0 0 0 6px rgba(34,197,94,0); }
}

/* Badge */
.update-bell-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 16px;
    height: 16px;
    border-radius: var(--radius-ui);
    font-size: 9px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
    padding: 0 3px;
    color: #fff;
    pointer-events: none;
}
.update-bell-badge.ub-blue  { background: var(--color-active); }
.update-bell-badge.ub-green { background: var(--color-primary); }

/* Popup panel */
.update-bell-popup {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 280px;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: var(--radius-ui);
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    z-index: 9999;
    overflow: hidden;
}
.ubp-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text-main);
    border-bottom: 1px solid #334155;
}
.ubp-header i { color: var(--color-active); font-size: 16px; }
.ubp-body {
    padding: 10px 14px;
    font-size: 0.8rem;
    color: var(--color-text-muted);
    line-height: 1.5;
}
.ubp-progress-wrap {
    margin: 0 14px 8px;
    height: 5px;
    background: rgba(0,0,0,0.3);
    border-radius: 3px;
    overflow: hidden;
}
.ubp-progress-bar {
    height: 100%;
    background: var(--color-active);
    border-radius: 3px;
    transition: width 0.3s ease;
}
.ubp-install-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: calc(100% - 28px);
    margin: 4px 14px 12px;
    padding: 8px 14px;
    background: var(--color-primary);
    color: #0f172a;
    font-size: 0.82rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-ui);
    cursor: pointer;
    transition: background 0.2s;
}
.ubp-install-btn:hover:not(:disabled) { background: #16a34a; }
.ubp-install-btn:disabled { opacity: 0.6; cursor: default; }

/* =============================================================================
   BUG FIX — INPUT FOCUS TRAPPING PREVENTION
   -webkit-app-region declarations moved to DRAG REGIONS section at top of file.
   Remaining declarations (user-select, pointer-events) kept here.
   ============================================================================= */

/* 1. Force all form elements to be interactive */
input,
textarea,
select,
button,
[contenteditable],
.alzar-input,
.alzar-select,
.form-control,
.form-select {
    /* -webkit-app-region moved to DRAG REGIONS section at top of file */
    user-select: text !important;
    -webkit-user-select: text !important;
    pointer-events: auto !important;
}

/* Buttons should restore default (no text selection needed) */
button,
[role="button"],
.btn,
.btn-icon,
.nav-item {
    user-select: none !important;
    -webkit-user-select: none !important;
    /* -webkit-app-region moved to DRAG REGIONS section at top of file */
    pointer-events: auto !important;
}

/* 2. Modals/overlays: -webkit-app-region moved to DRAG REGIONS section at top of file */

/* 3. The main content area and all scrollable views are never drag regions */
#main-content,
.view-container,
.view-content,
.app-sidebar,
#app-sidebar {
    /* -webkit-app-region moved to DRAG REGIONS section at top of file */
    pointer-events: auto !important;
}
