/* ============================================================
   ADMIN SHELL β€” SUPPLEMENTAL OVERRIDES (Pilot)
   Small additions on top of qcms-admin/css/admin.css that
   the new Topbar/Sidebar/Empty shell components use.
   ============================================================ */

/* ============================================================
   BORDER VISIBILITY TUNING
   The default theme tokens (0.05 / 0.08) are too faint for
   admin pages with dense data tables and form grids. Bump them
   to ~0.15 so card edges and table separators are visible
   without becoming heavy.
   ============================================================ */
:root,
[data-bs-theme="light"] {
    --border-subtle:  rgba(0, 0, 0, 0.12);
    --border-default: rgba(0, 0, 0, 0.18);
    --bs-border-color: rgba(0, 0, 0, 0.18);
    --bs-border-color-translucent: rgba(0, 0, 0, 0.12);
}
[data-bs-theme="dark"] {
    --border-subtle:  rgba(255, 255, 255, 0.12);
    --border-default: rgba(255, 255, 255, 0.18);
    --bs-border-color: rgba(255, 255, 255, 0.18);
    --bs-border-color-translucent: rgba(255, 255, 255, 0.12);
}

/* ============================================================
   PRIMARY = BRAND (Roomzy 2025 refresh)
   The Roomzy brand is now a blue scale (#2563EB primary,
   #1E40AF deep) derived directly from the official logo. Blue
   is visually distinct from .btn-danger (red), so we no longer
   need to split "primary action" from "brand" — .btn-primary,
   .btn-theme, sidebar active, focus rings and mobile bottom-nav
   all share the same brand blue.
   --bs-primary / --bs-primary-rgb are defined in theme-light.css
   and theme-dark.css and resolve to var(--brand-500).
   ============================================================ */

/* Override admin-components.css mapping so .btn-primary follows brand. */
.btn-primary {
    background-color: var(--brand-500);
    border-color: var(--brand-500);
    color: #fff;
}
.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active,
.btn-primary.active {
    background-color: var(--brand-600);
    border-color: var(--brand-700);
    color: #fff;
}
.btn-primary:disabled,
.btn-primary.disabled {
    background-color: var(--bs-primary);
    border-color: var(--bs-primary);
    color: #fff;
    opacity: 0.65;
}

.btn-outline-primary {
    background-color: transparent;
    border-color: var(--brand-500);
    color: var(--brand-500);
}
.btn-outline-primary:hover,
.btn-outline-primary:focus,
.btn-outline-primary:active {
    background-color: var(--brand-500);
    border-color: var(--brand-500);
    color: #fff;
}

/* ============================================================
   LEGACY ADMIN BUTTON BRIDGE
   The admin pages still use a few legacy color-name button
   classes from the old HUD theme. Map them onto Bootstrap 5.3
   + new theme tokens so pages don't need to be rewritten.
   (btn-yellow was retired in favor of btn-outline-primary for
   row-level Edit actions.)
   ============================================================ */
.btn-green {
    background-color: var(--bs-success, #198754);
    border-color: var(--bs-success, #198754);
    color: #fff;
}
.btn-green:hover,
.btn-green:focus { filter: brightness(0.92); color: #fff; }

.btn-pink {
    background-color: var(--brand-500, #2563EB);
    border-color: var(--brand-500, #2563EB);
    color: #fff;
}
.btn-pink:hover,
.btn-pink:focus { filter: brightness(0.92); color: #fff; }

.btn-default {
    background-color: var(--bs-secondary-bg, #e9ecef);
    border-color: var(--bs-border-color, #ced4da);
    color: var(--bs-body-color, #212529);
}
.btn-default:hover,
.btn-default:focus { filter: brightness(0.97); }

/* Brand button — Roomzy blue. Used 60+ times across admin pages
   (primary CTAs: Create, Save, Add, etc.). */
.btn-theme {
    background-color: var(--brand-500, #2563EB);
    border-color: var(--brand-500, #2563EB);
    color: #fff;
}
.btn-theme:hover,
.btn-theme:focus,
.btn-theme:active,
.btn-theme.active {
    background-color: var(--brand-600, #1D4ED8);
    border-color: var(--brand-700, #1E40AF);
    color: #fff;
}
.btn-theme:disabled,
.btn-theme.disabled {
    background-color: var(--brand-300, #93C5FD);
    border-color: var(--brand-300, #93C5FD);
    color: #fff;
    opacity: 0.65;
}
.btn-outline-theme {
    background-color: transparent;
    border-color: var(--brand-500, #2563EB);
    color: var(--brand-500, #2563EB);
}
.btn-outline-theme:hover,
.btn-outline-theme:focus,
.btn-outline-theme:active {
    background-color: var(--brand-500, #2563EB);
    border-color: var(--brand-500, #2563EB);
    color: #fff;
}

/* ============================================================
   LEGACY UTILITY BRIDGE
   The old HUD theme provided pixel-precise sizing/typography
   utilities (w-10px, h-60px, fs-14px, fw-500, invert-dark, ...)
   that admin pages still rely on. Re-declare the ones actually
   in use so the new shell renders them correctly.
   ============================================================ */

/* Pixel widths */
.w-10px { width: 10px !important; }
.w-20px { width: 20px !important; }
.w-30px { width: 30px !important; }
.w-40px { width: 40px !important; }
.w-50px { width: 50px !important; }
.w-60px { width: 60px !important; }
.w-80px { width: 80px !important; }
.w-100px { width: 100px !important; }

/* Pixel heights */
.h-10px { height: 10px !important; }
.h-20px { height: 20px !important; }
.h-30px { height: 30px !important; }
.h-40px { height: 40px !important; }
.h-50px { height: 50px !important; }
.h-60px { height: 60px !important; }
.h-80px { height: 80px !important; }
.h-100px { height: 100px !important; }

/* Pixel font sizes */
.fs-10px { font-size: 10px !important; }
.fs-11px { font-size: 11px !important; }
.fs-12px { font-size: 12px !important; }
.fs-13px { font-size: 13px !important; }
.fs-14px { font-size: 14px !important; }
.fs-15px { font-size: 15px !important; }
.fs-16px { font-size: 16px !important; }
.fs-18px { font-size: 18px !important; }
.fs-20px { font-size: 20px !important; }
.fs-24px { font-size: 24px !important; }
.fs-28px { font-size: 28px !important; }
.fs-32px { font-size: 32px !important; }

/* Numeric font weights */
.fw-300 { font-weight: 300 !important; }
.fw-400 { font-weight: 400 !important; }
.fw-500 { font-weight: 500 !important; }
.fw-600 { font-weight: 600 !important; }
.fw-700 { font-weight: 700 !important; }

/* Invert images in dark mode (legacy "no image" placeholder) */
[data-bs-theme="dark"] .invert-dark {
    filter: invert(1);
}

/* Topbar / general bar */
.app-topbar {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: 0 var(--space-3);
    height: var(--topbar-height);
    background: var(--topbar-bg, var(--surface-1));
    border-bottom: 1px solid var(--topbar-border, var(--border-subtle));
    flex-shrink: 0;
}

.topbar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background var(--transition-base);
}
.topbar-toggle:hover { background: var(--sidebar-item-hover-bg); color: var(--text-primary); }

.topbar-brand-link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--text-primary);
    text-decoration: none;
    font-weight: var(--fw-medium);
    padding: 0 var(--space-2);
    border-radius: var(--radius-md);
}
.topbar-brand-link:hover { color: var(--brand-500); }

.topbar-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    transition: background var(--transition-base), color var(--transition-base);
}
.topbar-icon-btn:hover {
    background: var(--sidebar-item-hover-bg);
    color: var(--text-primary);
}

.topbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

/* User menu */
.topbar-user-menu { position: relative; }
.user-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border-subtle, transparent);
    background: var(--brand-alpha-12);
    color: var(--brand-700);
    font-weight: var(--fw-medium);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.user-avatar:hover { background: var(--brand-alpha-18); }

.user-menu-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 200px;
    background: var(--surface-overlay);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    z-index: 1080;
    padding: 4px 0;
    backdrop-filter: none;
}
[data-bs-theme="dark"] .user-menu-dropdown {
    background: var(--surface-raised);
    border-color: var(--border-default);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.6);
}
.user-menu-header {
    padding: 8px 12px;
    font-size: var(--fs-sm);
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: 4px;
}
.user-menu-item {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 12px;
    width: 100%;
    background: transparent;
    border: 0;
    color: var(--text-primary);
    text-decoration: none;
    text-align: left;
    cursor: pointer;
    font-size: var(--fs-sm);
}
.user-menu-item:hover { background: var(--sidebar-item-hover-bg); }

/* Sidebar collapsible section button (replaces the legacy menu-header click) */
.sidebar-section-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: transparent;
    border: 0;
    padding: var(--space-3) var(--space-3) var(--space-1);
    color: var(--sidebar-section-label);
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: var(--ls-wide);
    cursor: pointer;
}
.sidebar-section-toggle:hover { color: var(--text-primary); }
.sidebar-section-toggle.open { color: var(--text-primary); font-weight: 600; }
.sidebar-section-toggle.open .sidebar-section { color: var(--text-primary); font-weight: 600; }
.sidebar-section-toggle .sidebar-section { padding: 0; }

.sidebar-bottom {
    border-top: 1px solid var(--sidebar-border);
    padding: var(--space-2) 0;
    flex-shrink: 0;
}

/* Empty admin shell (login / error pages) */
.admin-shell--empty {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
.admin-shell--empty .admin-main {
    width: 100%;
    display: flex;
    flex-direction: column;
    flex: 1;
}
.app-content--centered {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-6);
}

/* QCMS culture selector (legacy markup) inside the new topbar */
.app-topbar .menu-item.dropdown { display: inline-flex; align-items: center; }
.app-topbar .menu-item.dropdown .menu-link {
    display: inline-flex;
    align-items: center;
    padding: 0 var(--space-2);
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-md);
    height: 36px;
}
.app-topbar .menu-item.dropdown .menu-link:hover { background: var(--sidebar-item-hover-bg); }
.app-topbar .menu-item.dropdown .dropdown-menu { font-size: 0.75rem; z-index: 1060; }

/* ============================================================
   Syncfusion theme integration
   ------------------------------------------------------------
   The Syncfusion stylesheet itself is swapped at runtime
   (bootstrap5.3.css <-> bootstrap5.3-dark.css) by
   theme-switcher.js, driven by data-bs-theme on <html>.

   This block is only for fine-tuning controls that do not
   blend with our admin token system after the theme swap.
   Keep overrides minimal and grouped by control.
   ============================================================ */

/* Popups / overlays render to <body>, outside .admin-shell.
   Make sure they sit above our sidebar/backdrop layers. */
.e-popup,
.e-dialog,
.e-tooltip-wrap,
.e-dropdown-popup,
.e-ddl.e-popup,
.e-datepicker.e-popup,
.e-timepicker.e-popup {
    z-index: 1080;
}

/* ----- Light mode tweaks ----- */
[data-bs-theme="light"] .e-input-group:not(.e-disabled):not(.e-success):not(.e-warning):not(.e-error):hover:not(.e-float-icon-left):not(.e-input-focus)::before,
[data-bs-theme="light"] .e-input-group:not(.e-disabled):not(.e-success):not(.e-warning):not(.e-error):hover:not(.e-float-icon-left):not(.e-input-focus)::after {
    background: var(--brand-500);
}

/* ----- Dark mode tweaks ----- */
[data-bs-theme="dark"] {
    /* Input focus underline / accent should match our brand blue,
       not Syncfusion's default blue, in dark mode. */
    --color-sf-primary: var(--brand-500);
}

[data-bs-theme="dark"] .e-input-group:not(.e-disabled):not(.e-success):not(.e-warning):not(.e-error).e-input-focus:not(.e-float-icon-left)::before,
[data-bs-theme="dark"] .e-input-group:not(.e-disabled):not(.e-success):not(.e-warning):not(.e-error).e-input-focus:not(.e-float-icon-left)::after {
    background: var(--brand-500);
}

/* RichTextEditor: blend the toolbar/border with our card surface in dark */
[data-bs-theme="dark"] .e-richtexteditor {
    background-color: var(--surface-base);
    border-color: var(--border-default);
}
[data-bs-theme="dark"] .e-richtexteditor .e-toolbar,
[data-bs-theme="dark"] .e-richtexteditor .e-toolbar-wrapper,
[data-bs-theme="dark"] .e-richtexteditor .e-toolbar .e-toolbar-items,
[data-bs-theme="dark"] .e-richtexteditor .e-toolbar .e-tbar-btn {
    background-color: var(--surface-raised);
    border-color: var(--border-default);
    color: var(--text-primary);
}
[data-bs-theme="dark"] .e-richtexteditor .e-toolbar .e-tbar-btn:hover {
    background-color: var(--sidebar-item-hover-bg);
}
[data-bs-theme="dark"] .e-richtexteditor .e-rte-content,
[data-bs-theme="dark"] .e-richtexteditor .e-source-content,
[data-bs-theme="dark"] .e-richtexteditor .e-rte-content .e-content,
[data-bs-theme="dark"] .e-richtexteditor iframe {
    background-color: var(--surface-base);
    color: var(--text-primary);
}

/* RichTextEditor sticky/floating toolbar (when scrolling past the editor)
   Syncfusion attaches this floating bar to <body>, so .admin-shell parent
   selectors don't reach it. Match it in both modes via [data-bs-theme]. */
.e-rte-toolbar.e-rte-toolbar-float,
.e-richtexteditor .e-toolbar-wrapper.e-rte-tb-float,
.e-richtexteditor .e-toolbar-wrapper.e-toolbar-wrapper-sticky {
    background-color: var(--surface-raised);
    border-color: var(--border-default);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}
[data-bs-theme="dark"] .e-rte-toolbar.e-rte-toolbar-float,
[data-bs-theme="dark"] .e-richtexteditor .e-toolbar-wrapper.e-rte-tb-float,
[data-bs-theme="dark"] .e-richtexteditor .e-toolbar-wrapper.e-toolbar-wrapper-sticky {
    background-color: var(--surface-raised);
    border-color: var(--border-default);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.6);
}
[data-bs-theme="dark"] .e-rte-toolbar.e-rte-toolbar-float .e-toolbar-items,
[data-bs-theme="dark"] .e-rte-toolbar.e-rte-toolbar-float .e-tbar-btn,
[data-bs-theme="dark"] .e-richtexteditor .e-toolbar-wrapper.e-rte-tb-float .e-toolbar-items,
[data-bs-theme="dark"] .e-richtexteditor .e-toolbar-wrapper.e-rte-tb-float .e-tbar-btn {
    background-color: var(--surface-raised);
    color: var(--text-primary);
}
[data-bs-theme="dark"] .e-rte-toolbar.e-rte-toolbar-float .e-tbar-btn:hover,
[data-bs-theme="dark"] .e-richtexteditor .e-toolbar-wrapper.e-rte-tb-float .e-tbar-btn:hover {
    background-color: var(--surface-hover);
}
[data-bs-theme="dark"] .e-rte-toolbar.e-rte-toolbar-float .e-icons,
[data-bs-theme="dark"] .e-richtexteditor .e-toolbar-wrapper.e-rte-tb-float .e-icons {
    color: var(--text-primary);
}

/* DataGrid: align row/header/border colors with our tokens in dark */
[data-bs-theme="dark"] .e-grid {
    background-color: var(--surface-base);
    color: var(--text-primary);
    border-color: var(--border-default);
}
[data-bs-theme="dark"] .e-grid .e-headercontent,
[data-bs-theme="dark"] .e-grid .e-gridheader,
[data-bs-theme="dark"] .e-grid .e-gridheader tr th,
[data-bs-theme="dark"] .e-grid .e-headercell,
[data-bs-theme="dark"] .e-grid .e-detailheadercell {
    background-color: var(--surface-raised);
    border-color: var(--border-default);
    color: var(--text-primary);
}
[data-bs-theme="dark"] .e-grid .e-gridcontent,
[data-bs-theme="dark"] .e-grid .e-content,
[data-bs-theme="dark"] .e-grid .e-table,
[data-bs-theme="dark"] .e-grid .e-row,
[data-bs-theme="dark"] .e-grid .e-row .e-rowcell {
    background-color: var(--surface-base);
    color: var(--text-primary);
    border-color: var(--border-subtle);
}
[data-bs-theme="dark"] .e-grid .e-altrow,
[data-bs-theme="dark"] .e-grid .e-altrow .e-rowcell {
    background-color: var(--surface-raised);
}
[data-bs-theme="dark"] .e-grid .e-emptyrow,
[data-bs-theme="dark"] .e-grid .e-emptyrow td {
    background-color: var(--surface-base);
    color: var(--text-secondary);
}
[data-bs-theme="dark"] .e-grid .e-gridpager,
[data-bs-theme="dark"] .e-pager {
    background-color: var(--surface-raised);
    border-color: var(--border-default);
    color: var(--text-primary);
}
[data-bs-theme="dark"] .e-pager .e-pagercontainer,
[data-bs-theme="dark"] .e-pager .e-numericitem,
[data-bs-theme="dark"] .e-pager .e-pagerdropdown {
    background-color: transparent;
    color: var(--text-primary);
    border-color: var(--border-default);
}
[data-bs-theme="dark"] .e-grid .e-filterbarcell,
[data-bs-theme="dark"] .e-grid .e-filterbarcell input,
[data-bs-theme="dark"] .e-grid .e-filtermenudiv {
    background-color: var(--surface-raised);
    color: var(--text-primary);
    border-color: var(--border-default);
}

/* Dialog / popup surfaces */
[data-bs-theme="dark"] .e-dialog,
[data-bs-theme="dark"] .e-popup,
[data-bs-theme="dark"] .e-dropdown-popup {
    background-color: var(--surface-base);
    color: var(--text-primary);
    border-color: var(--border-default);
}
[data-bs-theme="dark"] .e-dialog .e-dlg-header-content,
[data-bs-theme="dark"] .e-dialog .e-footer-content {
    background-color: var(--surface-raised);
    border-color: var(--border-default);
    color: var(--text-primary);
}

/* Buttons rendered by Syncfusion: keep semantic mapping consistent */
[data-bs-theme="dark"] .e-btn.e-primary,
[data-bs-theme="dark"] .e-css.e-btn.e-primary {
    background-color: var(--bs-primary);
    border-color: var(--bs-primary);
}

/* ============================================================
   Bootstrap utility overrides for bg-light / table-light.
   In light mode, Bootstrap's default .bg-light (#f8f9fa) is
   nearly identical to our card surface (--surface-raised),
   so headers/sections using it look flat. We nudge it a touch
   darker to create clear separation against cards.
   In dark mode it must map to a dimmed surface token so it
   doesn't appear as a harsh white block.
   ============================================================ */
[data-bs-theme="light"] .bg-light {
    background-color: #F3F3F2 !important;
}

[data-bs-theme="dark"] .bg-light {
    background-color: var(--surface-raised) !important;
    color: var(--text-primary);
}

[data-bs-theme="dark"] .text-bg-light {
    background-color: var(--surface-raised) !important;
    color: var(--text-primary) !important;
}

/* Inactive row β€” theme-aware alternative to Bootstrap's .table-secondary */
tr.row-inactive {
    --bs-table-bg: var(--table-row-inactive-bg);
    background-color: var(--table-row-inactive-bg);
    color: var(--text-muted);
}

/* Table variants */
[data-bs-theme="dark"] .table-light,
[data-bs-theme="dark"] .table-light > th,
[data-bs-theme="dark"] .table-light > td,
[data-bs-theme="dark"] .table > thead.table-light > tr > th,
[data-bs-theme="dark"] .table > thead.table-light > tr > td,
[data-bs-theme="dark"] .table > tbody > tr.table-light > td,
[data-bs-theme="dark"] .table > tbody > tr.table-light > th {
    --bs-table-color: var(--text-primary);
    --bs-table-bg: var(--surface-raised);
    --bs-table-border-color: var(--border-default);
    background-color: var(--surface-raised);
    color: var(--text-primary);
}

/* bg-white in dark mode: map to base surface so it doesn't blind the eye */
[data-bs-theme="dark"] .bg-white {
    background-color: var(--surface-raised) !important;
    color: var(--text-primary);
}

/* ============================================================
   Badge dark-mode overrides
   Bootstrap's raw bg-* classes are designed for light surfaces.
   In dark mode every semantic color is remapped to the token
   system so contrast is guaranteed in both themes.
   ============================================================ */

/* bg-light / text-bg-light β€” was blinding white */
[data-bs-theme="dark"] .bg-light.badge,
[data-bs-theme="dark"] .badge.text-bg-light {
    background-color: var(--surface-overlay) !important;
    color: var(--text-primary) !important;
}

/* bg-dark β€” near-black on dark surface = invisible */
[data-bs-theme="dark"] .badge.bg-dark,
[data-bs-theme="dark"] .badge.text-bg-dark {
    background-color: var(--surface-overlay) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-default);
}

/* bg-secondary */
[data-bs-theme="dark"] .badge.bg-secondary,
[data-bs-theme="dark"] .badge.text-bg-secondary {
    background-color: var(--badge-neutral-bg) !important;
    color: var(--badge-neutral-fg) !important;
}

/* bg-success */
[data-bs-theme="dark"] .badge.bg-success,
[data-bs-theme="dark"] .badge.text-bg-success {
    background-color: var(--badge-success-bg) !important;
    color: var(--badge-success-fg) !important;
}

/* bg-danger */
[data-bs-theme="dark"] .badge.bg-danger,
[data-bs-theme="dark"] .badge.text-bg-danger {
    background-color: var(--badge-danger-bg) !important;
    color: var(--badge-danger-fg) !important;
}

/* bg-warning / bg-warning β€” yellow bg with black text unreadable on dark */
[data-bs-theme="dark"] .badge.bg-warning,
[data-bs-theme="dark"] .badge.text-bg-warning {
    background-color: var(--badge-warning-bg) !important;
    color: var(--badge-warning-fg) !important;
}

/* bg-info */
[data-bs-theme="dark"] .badge.bg-info,
[data-bs-theme="dark"] .badge.text-bg-info {
    background-color: var(--badge-info-bg) !important;
    color: var(--badge-info-fg) !important;
}

/* ============================================================
   FOCUS-ON-NAVIGATE
   Blazor's <FocusOnNavigate> calls .focus() programmatically
   on the h1 after each navigation. Suppress the visible outline
   for script/mouse-triggered focus while keeping it for
   keyboard users (:focus-visible).
   ============================================================ */
h1:focus:not(:focus-visible),
h2:focus:not(:focus-visible),
h3:focus:not(:focus-visible) {
    outline: none;
}

