/* ============================================================
   app_dark.css — Komuniti dark theme colors
   ------------------------------------------------------------
   Everything that changes when the app is switched to dark mode
   lives here, separate from app.css's base/light rules. The
   stylesheet is always present in wwwroot/index.html as
   <link id="app-dark-theme"> but starts `disabled`; it is
   enabled/disabled together with the data-bs-theme="dark"
   attribute on <html> by wwwroot/scripts/theme-basic.js
   (window.themeHelper.setTheme / initTheme), which is what
   ThemeService.cs (ToggleAsync/InitAsync) calls via JS interop.

   Rules keep the [data-bs-theme="dark"] selector prefix rather
   than being bare selectors, so they stay inert if this
   stylesheet is ever left enabled for a moment while the
   attribute doesn't (yet) match — defense in depth, since in
   normal operation the two are always toggled together.
   ============================================================ */

/* ---- CSS variables consumed throughout app.css ---- */
[data-bs-theme="dark"] {
    --content-bg: #0d1117;
    --card-bg: #161b22;
    --card-border: rgba(255,255,255,0.08);
    --header-bg: var(--org-primary, #161b22);
    --content-text: #f8f9fa;
}

/* ---- Code/Monospace tags ---- */
[data-bs-theme="dark"] code {
    color: #79b8ff;
    background: rgba(121,184,255,0.1);
}

/* ============================================================
   Syncfusion CDN overrides
   The CDN bootstrap5-dark.css uses hardcoded dark-grey color
   values that are nearly unreadable on our dark backgrounds.
   All rules here use !important to win over the CDN specificity.
   ============================================================ */

/* -- Grid backgrounds -- */
[data-bs-theme="dark"] .e-grid,
[data-bs-theme="dark"] .e-grid .e-table,
[data-bs-theme="dark"] .e-grid .e-content,
[data-bs-theme="dark"] .e-grid .e-gridcontent,
[data-bs-theme="dark"] .e-grid .e-gridheader,
[data-bs-theme="dark"] .e-grid .e-headercell,
[data-bs-theme="dark"] .e-grid .e-filterbar {
    background-color: var(--card-bg) !important;
    border-color: var(--card-border) !important;
}

[data-bs-theme="dark"] .e-grid .e-altrow td {
    background-color: rgba(255,255,255,0.035) !important;
}

/* -- Grid header text -- */
[data-bs-theme="dark"] .e-grid .e-headertext,
[data-bs-theme="dark"] .e-grid .e-headercell,
[data-bs-theme="dark"] .e-grid .e-headercell .e-sortfilterdiv,
[data-bs-theme="dark"] .e-grid .e-rhandler {
    color: #94a3b8 !important;
}

/* -- Grid body cell text (normal state) -- */
[data-bs-theme="dark"] .e-grid .e-rowcell,
[data-bs-theme="dark"] .e-grid td.e-rowcell,
[data-bs-theme="dark"] .e-grid .e-rowcell .e-treecolumn-container span {
    color: #d1d5db !important;
}

/* -- Grid row hover — brighten to white -- */
[data-bs-theme="dark"] .e-grid .e-row:hover .e-rowcell,
[data-bs-theme="dark"] .e-grid tr.e-row:hover td.e-rowcell {
    color: #ffffff !important;
    background-color: rgba(255,255,255,0.055) !important;
}

/* -- Grid selected row -- */
[data-bs-theme="dark"] .e-grid .e-active .e-rowcell,
[data-bs-theme="dark"] .e-grid .e-selectionbackground {
    color: #ffffff !important;
    background-color: color-mix(in srgb, var(--org-accent, #0d6efd) 25%, transparent) !important;
}

/* -- Grid toolbar & pager -- */
[data-bs-theme="dark"] .e-grid .e-toolbar,
[data-bs-theme="dark"] .e-grid .e-toolbar-items,
[data-bs-theme="dark"] .e-pager {
    background-color: var(--card-bg) !important;
    border-color: var(--card-border) !important;
    color: #d1d5db !important;
}

[data-bs-theme="dark"] .e-pager .e-numericitem,
[data-bs-theme="dark"] .e-pager .e-pagercontainer,
[data-bs-theme="dark"] .e-pager .e-pagerdropdown,
[data-bs-theme="dark"] .e-pager .e-pagerexternalcount {
    color: #d1d5db !important;
    background-color: var(--card-bg) !important;
    border-color: var(--card-border) !important;
}

[data-bs-theme="dark"] .e-pager .e-currentitem,
[data-bs-theme="dark"] .e-pager .e-numericitem:hover {
    background-color: color-mix(in srgb, var(--org-accent, #0d6efd) 30%, transparent) !important;
    color: #ffffff !important;
}

[data-bs-theme="dark"] .e-grid .e-toolbar .e-tbar-btn,
[data-bs-theme="dark"] .e-grid .e-toolbar .e-tbar-btn .e-btn-icon,
[data-bs-theme="dark"] .e-grid .e-toolbar .e-tbar-btn-text {
    color: #d1d5db !important;
}

/* -- Dialog -- */
[data-bs-theme="dark"] .e-dialog,
[data-bs-theme="dark"] .e-dialog .e-dlg-content {
    background-color: var(--card-bg) !important;
    color: #d1d5db !important;
    border-color: var(--card-border) !important;
}

[data-bs-theme="dark"] .e-dlg-header-content,
[data-bs-theme="dark"] .e-dlg-header-content .e-dlg-header {
    background-color: var(--card-bg) !important;
    color: #f1f5f9 !important;
    border-bottom-color: var(--card-border) !important;
}

[data-bs-theme="dark"] .e-footer-content {
    background-color: var(--card-bg) !important;
    border-top-color: var(--card-border) !important;
}

/* -- Labels inside dialogs / forms -- */
[data-bs-theme="dark"] .e-dialog label,
[data-bs-theme="dark"] .e-dialog .e-label,
[data-bs-theme="dark"] .e-float-text,
[data-bs-theme="dark"] .e-label {
    color: #94a3b8 !important;
}

/* -- Inputs & textboxes -- */
[data-bs-theme="dark"] .e-input-group,
[data-bs-theme="dark"] .e-input-group.e-control-wrapper,
[data-bs-theme="dark"] .e-float-input,
[data-bs-theme="dark"] .e-float-input.e-control-wrapper {
    background-color: #1e2530 !important;
    color: #e2e8f0 !important;
    border-color: rgba(255,255,255,0.15) !important;
}

[data-bs-theme="dark"] .e-input-group input.e-input,
[data-bs-theme="dark"] .e-input-group.e-control-wrapper input.e-input,
[data-bs-theme="dark"] .e-float-input input,
[data-bs-theme="dark"] input.e-input {
    background-color: #1e2530 !important;
    color: #e2e8f0 !important;
    caret-color: #e2e8f0;
}

[data-bs-theme="dark"] .e-input-group input.e-input::placeholder,
[data-bs-theme="dark"] .e-float-input input::placeholder {
    color: #64748b !important;
}

/* -- DropDownList / ComboBox -- */
[data-bs-theme="dark"] .e-dropdownlist,
[data-bs-theme="dark"] .e-ddl .e-input-group-icon {
    color: #d1d5db !important;
}

[data-bs-theme="dark"] .e-popup.e-ddl-popup,
[data-bs-theme="dark"] .e-popup.e-ddl-popup .e-dropdownbase {
    background-color: #1e2530 !important;
    border-color: var(--card-border) !important;
}

[data-bs-theme="dark"] .e-dropdownbase .e-list-item {
    background-color: transparent !important;
    color: #d1d5db !important;
}

[data-bs-theme="dark"] .e-dropdownbase .e-list-item.e-hover,
[data-bs-theme="dark"] .e-dropdownbase .e-list-item:hover {
    background-color: rgba(255,255,255,0.08) !important;
    color: #ffffff !important;
}

[data-bs-theme="dark"] .e-dropdownbase .e-list-item.e-active,
[data-bs-theme="dark"] .e-dropdownbase .e-list-item.e-active.e-hover {
    background-color: color-mix(in srgb, var(--org-accent, #0d6efd) 25%, transparent) !important;
    color: #7eb3ff !important;
}

/* -- DatePicker popup -- */
[data-bs-theme="dark"] .e-calendar,
[data-bs-theme="dark"] .e-calendar .e-header,
[data-bs-theme="dark"] .e-calendar .e-content {
    background-color: #1e2530 !important;
    color: #d1d5db !important;
}

[data-bs-theme="dark"] .e-calendar .e-content td span.e-day {
    color: #d1d5db !important;
}

[data-bs-theme="dark"] .e-calendar .e-content td:hover span.e-day,
[data-bs-theme="dark"] .e-calendar .e-content td.e-focused-date span.e-day {
    background-color: rgba(255,255,255,0.1) !important;
    color: #ffffff !important;
}

[data-bs-theme="dark"] .e-calendar .e-content td.e-selected span.e-day,
[data-bs-theme="dark"] .e-calendar .e-content td.e-today span.e-day {
    background-color: var(--org-accent, #0d6efd) !important;
    color: #ffffff !important;
}

/* -- Spinner -- */
[data-bs-theme="dark"] .e-spinner-pane .e-spinner-inner .e-spin-bootstrap5 {
    stroke: var(--org-accent, #7eb3ff) !important;
}

/* ---- Settings panels — list-group dark overrides ---- */
[data-bs-theme="dark"] .list-group-item {
    background-color: var(--card-bg);
    border-color: var(--card-border);
    color: var(--bs-body-color);
}

[data-bs-theme="dark"] .list-group-flush .list-group-item {
    background-color: transparent;
    border-color: var(--card-border);
}

[data-bs-theme="dark"] .data-table-card {
    background-color: var(--card-bg);
}

[data-bs-theme="dark"] .data-table-card h6,
[data-bs-theme="dark"] .data-table-card .fw-semibold,
[data-bs-theme="dark"] .data-table-card .fw-bold {
    color: var(--bs-body-color);
}

/* Inline edit area inside settings list items */
[data-bs-theme="dark"] .list-group-item .e-input-group,
[data-bs-theme="dark"] .list-group-item .e-control-wrapper {
    background-color: #1e2530;
    border-color: var(--card-border);
}

[data-bs-theme="dark"] .list-group-item input.e-input {
    background-color: #1e2530;
    color: var(--bs-body-color);
}

/* ---- Sidebar dark variant ---- */
[data-bs-theme="dark"] .sidebar {
    background: #0d1117;
    border-right: 1px solid rgba(255,255,255,0.05);
}

/* ---- Login page ----
   .login-card already switches to --card-bg/--card-border (see
   Pages/Account/Login.razor), which is enough for the surface color and
   edge itself; the one thing that still needs a per-theme value is the
   shadow, since the light-mode rgba(0,0,0,0.08) reads as invisible once
   the page behind it is nearly black. Same treatment as .user-dropdown-menu
   below. */
[data-bs-theme="dark"] .login-card {
    box-shadow: 0 8px 32px rgba(0,0,0,0.45);
    color: white;
}

/* ============================================================
   Header — user button, dropdown & flyout panels
   Bootstrap's CSS vars sometimes lose to higher-specificity
   rules from Syncfusion or inherited styles on fixed elements,
   so every text node is explicitly overridden here.
   ============================================================ */

/* -- Header avatar button text -- */
[data-bs-theme="dark"] .user-name {
    color: #e2e8f0 !important;
}

[data-bs-theme="dark"] .user-sub,
[data-bs-theme="dark"] .user-chevron {
    /*color: #94a3b8;*/
}

[data-bs-theme="dark"] .user-avatar-btn:hover {
    background: rgba(255,255,255,0.06) !important;
}

[data-bs-theme="dark"] .user-avatar-btn:hover .user-name {
    color: #ffffff !important;
}

/* -- User dropdown menu -- */
[data-bs-theme="dark"] .user-dropdown-menu {
    box-shadow: 0 8px 32px rgba(0,0,0,0.45) !important;
}

[data-bs-theme="dark"] .user-menu-name {
    color: #e2e8f0 !important;
}

[data-bs-theme="dark"] .user-menu-email {
    color: #64748b !important;
}

[data-bs-theme="dark"] .user-menu-item {
    color: #d1d5db !important;
}

[data-bs-theme="dark"] .user-menu-item:hover {
    background: rgba(255,255,255,0.06) !important;
    color: #ffffff !important;
}

[data-bs-theme="dark"] .user-menu-item .menu-icon {
    color: #64748b !important;
}

[data-bs-theme="dark"] .user-menu-item:hover .menu-icon {
    color: #94a3b8 !important;
}

[data-bs-theme="dark"] .user-menu-item.danger {
    color: #f87171 !important;
}

[data-bs-theme="dark"] .user-menu-item.danger:hover {
    background: rgba(248,113,113,0.1) !important;
    color: #fca5a5 !important;
}

[data-bs-theme="dark"] .user-menu-item.danger .menu-icon {
    color: #f87171 !important;
}

/* -- Flyout panels — all text nodes -- */
[data-bs-theme="dark"] .flyout-title {
    color: #f1f5f9 !important;
}

[data-bs-theme="dark"] .flyout-close {
    color: #64748b !important;
}

[data-bs-theme="dark"] .flyout-close:hover {
    background: rgba(255,255,255,0.08) !important;
    color: #e2e8f0 !important;
}

/* Section title (uppercase label) */
[data-bs-theme="dark"] .flyout-section-title {
    color: #475569 !important;
}

/* Primary labels (form-label, fw-semibold, fw-bold headings) */
[data-bs-theme="dark"] .flyout-panel .form-label,
[data-bs-theme="dark"] .flyout-panel .fw-semibold,
[data-bs-theme="dark"] .flyout-panel .fw-bold {
    color: #cbd5e1 !important;
}

/* Secondary / muted text (descriptions under switch labels) */
[data-bs-theme="dark"] .flyout-panel .text-muted,
[data-bs-theme="dark"] .flyout-panel [style*="font-size:0.75rem"] {
    color: #64748b !important;
}

/* Plain paragraph / small text inside flyout */
[data-bs-theme="dark"] .flyout-panel .small {
    color: #cbd5e1 !important;
}

/* Profile avatar section — name & email next to avatar */
[data-bs-theme="dark"] .profile-avatar-section .fw-semibold {
    color: #e2e8f0 !important;
}

[data-bs-theme="dark"] .profile-avatar-section .text-muted {
    color: #64748b !important;
}

/* Flyout input fields */
[data-bs-theme="dark"] .flyout-panel .e-input-group,
[data-bs-theme="dark"] .flyout-panel .e-input-group.e-control-wrapper,
[data-bs-theme="dark"] .flyout-panel .e-float-input {
    background-color: #1e2530 !important;
    border-color: rgba(255,255,255,0.12) !important;
    color: #e2e8f0 !important;
}

[data-bs-theme="dark"] .flyout-panel input.e-input,
[data-bs-theme="dark"] .flyout-panel .e-input-group input {
    background-color: #1e2530 !important;
    color: #e2e8f0 !important;
    caret-color: #e2e8f0 !important;
}

[data-bs-theme="dark"] .flyout-panel input.e-input::placeholder {
    color: #475569 !important;
}

/* Flyout DropDownList value text */
[data-bs-theme="dark"] .flyout-panel .e-dropdownlist,
[data-bs-theme="dark"] .flyout-panel .e-ddl input.e-input {
    color: #e2e8f0 !important;
    background-color: #1e2530 !important;
}

[data-bs-theme="dark"] .flyout-panel .e-input-group-icon {
    color: #64748b !important;
    background-color: #1e2530 !important;
}

/* ============================================================
   Label Designer — panel text
   ============================================================ */

[data-bs-theme="dark"] .ld-prop-field label,
[data-bs-theme="dark"] .ld-empty-title,
[data-bs-theme="dark"] .ld-prop-group-title,
[data-bs-theme="dark"] .ld-panel-header {
    color: #94a3b8 !important;
}

[data-bs-theme="dark"] .ld-tool-btn {
    color: #cbd5e1 !important;
}

[data-bs-theme="dark"] .ld-zoom-chip {
    color: #94a3b8 !important;
}

[data-bs-theme="dark"] .ld-color-hex {
    color: #64748b !important;
}

[data-bs-theme="dark"] .ld-fmt-btn {
    color: #94a3b8 !important;
    border-color: rgba(255,255,255,0.1) !important;
}

[data-bs-theme="dark"] .ld-palette-body .e-symbol-tile {
    background: #1e2530 !important;
}

/* -- Label Designer: Image upload panel -- */
[data-bs-theme="dark"] .ld-barcode-hint {
    color: #94a3b8 !important;
    background: rgba(99,102,241,0.08) !important;
    border-left-color: #6366f1 !important;
}

[data-bs-theme="dark"] .ld-file-label {
    background: rgba(255,255,255,0.05) !important;
    border-color: rgba(255,255,255,0.12) !important;
    color: #94a3b8 !important;
}

[data-bs-theme="dark"] .ld-file-label:hover {
    background: rgba(77,148,255,0.12) !important;
    border-color: var(--org-accent, #4d94ff) !important;
    color: #93c5fd !important;
}

[data-bs-theme="dark"] .ld-img-preview {
    background: repeating-conic-gradient(#374151 0% 25%, #1f2937 0% 50%) 0 0 / 12px 12px;
    border-color: rgba(255,255,255,0.1) !important;
}

/* Additional dark overrides below (natPOS-derived) */
[data-bs-theme="dark"] .search-criteria-panel,
[data-bs-theme="dark"] .search-loading {
    color: #d1d5db !important;
}

[data-bs-theme="dark"] .sidebar-nav .nav-link {
    color: #94a3b8;
}
[data-bs-theme="dark"] .sidebar-nav .nav-link:hover {
    color: var(--org-accent, #0d6efd);
}
[data-bs-theme="dark"] li .section-outline-item .active {
    color: #212529 !important;
}