﻿/*
 * ═══════════════════════════════════════════════════════════════════
 *  VININA ERP — DARK MODE OVERRIDES v2.1
 *  Targeted ONLY at dark mode — does NOT affect light mode.
 *  Fixes modals, tables, inputs, search bars, text colors.
 *  v2.1: Stat Summary Card — unified stats panel
 * ═══════════════════════════════════════════════════════════════════
 */

/* ══════════════════════════════════════════════════════════════════
   MODULE TOP CARD — Gộp header + toolbar + stats thành 1 card lớn
   ══════════════════════════════════════════════════════════════════ */
.module-top-card {
  border-radius: 16px;
  overflow: hidden;

  /* Glass effect - light mode default */
  background: rgba(255, 255, 255, 0.80);
  backdrop-filter: blur(22px) saturate(160%);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  border: 1px solid rgba(255, 255, 255, 0.92);
  box-shadow:
    0 4px 32px rgba(0, 0, 0, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.98);
}


[data-theme="light"] .module-top-card {
  background: rgba(255, 255, 255, 0.85);
  border-color: rgba(255, 255, 255, 0.96);
}

:root:not([data-theme="light"]) .module-top-card,
[data-theme="dark"] .module-top-card {
  background: rgba(12, 15, 28, 0.65);
  backdrop-filter: blur(26px) saturate(150%);
  -webkit-backdrop-filter: blur(26px) saturate(150%);
  border: 1px solid rgba(255, 255, 255, 0.11);
  box-shadow:
    0 4px 32px rgba(0, 0, 0, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.09);
}

/* ── Header row (title + action buttons) ── */
.module-top-card .mtc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px 16px;
  gap: 12px;
  flex-wrap: wrap;
}

.module-top-card .mtc-header-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.module-top-card .mtc-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Title */
.module-top-card .page-title {
  font-size: 20px;
  font-weight: 700;
  margin: 0;
  line-height: 1.2;
  color: var(--text, #1a2a3a);
}

:root:not([data-theme="light"]) .module-top-card .page-title,
[data-theme="dark"] .module-top-card .page-title {
  color: rgba(225, 238, 255, 0.97);
}

.module-top-card .page-sub {
  font-size: 12px;
  margin: 0;
  color: var(--text-muted, rgba(100, 120, 140, 0.80));
}

/* ── Horizontal divider between sections ── */
.module-top-card .mtc-divider {
  height: 1px;
  background: rgba(0, 0, 0, 0.07);
  margin: 0 16px;
}

:root:not([data-theme="light"]) .module-top-card .mtc-divider,
[data-theme="dark"] .module-top-card .mtc-divider {
  background: rgba(255, 255, 255, 0.09);
}

/* ── Toolbar/search row ── */
.module-top-card .mtc-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  flex-wrap: wrap;
}

/* Override toolbar glass since parent is already glass */
.module-top-card .mtc-toolbar .search-input,
.module-top-card .mtc-toolbar .form-input {
  background: rgba(255, 255, 255, 0.55) !important;
  border: 1px solid rgba(0, 0, 0, 0.10) !important;
}

:root:not([data-theme="light"]) .module-top-card .mtc-toolbar .search-input,
:root:not([data-theme="light"]) .module-top-card .mtc-toolbar .form-input,
[data-theme="dark"] .module-top-card .mtc-toolbar .search-input,
[data-theme="dark"] .module-top-card .mtc-toolbar .form-input {
  background: rgba(255, 255, 255, 0.07) !important;
  border: 1px solid rgba(255, 255, 255, 0.13) !important;
  color: rgba(220, 235, 255, 0.92) !important;
}

:root:not([data-theme="light"]) .module-top-card .mtc-toolbar .search-input::placeholder,
[data-theme="dark"] .module-top-card .mtc-toolbar .search-input::placeholder {
  color: rgba(150, 175, 215, 0.55) !important;
}

/* ── Stats row (flex items inline) ── */
.module-top-card .mtc-stats {
  display: flex;
  align-items: stretch;
  border-top: 1px solid rgba(0, 0, 0, 0.07);
}

:root:not([data-theme="light"]) .module-top-card .mtc-stats,
[data-theme="dark"] .module-top-card .mtc-stats {
  border-top: 1px solid rgba(255, 255, 255, 0.09);
}

.module-top-card .mtc-stats .stat-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 14px 22px;
  position: relative;
  cursor: default;
  transition: background 0.18s ease;
  min-width: 0;
}

.module-top-card .mtc-stats .stat-item[onclick] {
  cursor: pointer;
}

.module-top-card .mtc-stats .stat-item:hover {
  background: rgba(0, 0, 0, 0.03);
}

:root:not([data-theme="light"]) .module-top-card .mtc-stats .stat-item:hover,
[data-theme="dark"] .module-top-card .mtc-stats .stat-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

/* Vertical divider between stat items */
.module-top-card .mtc-stats .stat-item+.stat-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 20%;
  height: 60%;
  width: 1px;
  background: rgba(0, 0, 0, 0.09);
}

:root:not([data-theme="light"]) .module-top-card .mtc-stats .stat-item+.stat-item::before,
[data-theme="dark"] .module-top-card .mtc-stats .stat-item+.stat-item::before {
  background: rgba(255, 255, 255, 0.11);
}

.module-top-card .mtc-stats .stat-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.1px;
  text-transform: uppercase;
  color: var(--text-muted, rgba(100, 125, 145, 0.80));
  margin-bottom: 4px;
  white-space: nowrap;
}

.module-top-card .mtc-stats .stat-value {
  font-size: 24px;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.5px;
  color: var(--text, #1a2a3a);
}

:root:not([data-theme="light"]) .module-top-card .mtc-stats .stat-value,
[data-theme="dark"] .module-top-card .mtc-stats .stat-value {
  color: rgba(220, 235, 255, 0.95);
}

.module-top-card .mtc-stats .stat-badge {
  display: inline-flex;
  align-items: center;
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  margin-top: 5px;
  white-space: nowrap;
}

/* ── Responsive ── */
@media (max-width: 640px) {
  .module-top-card .mtc-stats {
    flex-wrap: wrap;
  }

  .module-top-card .mtc-stats .stat-item {
    flex: 1 1 45%;
  }

  .module-top-card .mtc-stats .stat-item:nth-child(odd)::before {
    display: none;
  }
}

/* ══════════════════════════════════════════════════════════════════
   STAT SUMMARY CARD — standalone version (fallback, not inside mtc)
   ══════════════════════════════════════════════════════════════════ */
.stat-summary-card {
  display: flex;
  align-items: stretch;
  gap: 0;
  margin-bottom: 16px;
  border-radius: 18px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid rgba(255, 255, 255, 0.90);
  box-shadow: 0 4px 28px rgba(0, 0, 0, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

:root:not([data-theme="light"]) .stat-summary-card,
[data-theme="dark"] .stat-summary-card {
  background: rgba(12, 15, 28, 0.62);
  backdrop-filter: blur(24px) saturate(150%);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 4px 28px rgba(0, 0, 0, 0.30), inset 0 1px 0 rgba(255, 255, 255, 0.10);
}

.stat-summary-card .stat-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 16px 22px;
  position: relative;
  cursor: default;
  transition: background 0.2s ease;
  min-width: 0;
}

.stat-summary-card .stat-item[onclick] {
  cursor: pointer;
}

.stat-summary-card .stat-item:hover {
  background: rgba(255, 255, 255, 0.12);
}

:root:not([data-theme="light"]) .stat-summary-card .stat-item:hover,
[data-theme="dark"] .stat-summary-card .stat-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.stat-summary-card .stat-item+.stat-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 18%;
  height: 64%;
  width: 1px;
  background: rgba(0, 0, 0, 0.10);
}

:root:not([data-theme="light"]) .stat-summary-card .stat-item+.stat-item::before,
[data-theme="dark"] .stat-summary-card .stat-item+.stat-item::before {
  background: rgba(255, 255, 255, 0.12);
}

.stat-summary-card .stat-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text-muted, rgba(100, 120, 140, 0.85));
  margin-bottom: 6px;
}

.stat-summary-card .stat-value {
  font-size: 26px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.5px;
  color: var(--text, #1a2a3a);
}

:root:not([data-theme="light"]) .stat-summary-card .stat-value,
[data-theme="dark"] .stat-summary-card .stat-value {
  color: rgba(220, 235, 255, 0.95);
}

.stat-summary-card .stat-badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  margin-top: 6px;
}

@media (max-width: 600px) {
  .stat-summary-card {
    flex-wrap: wrap;
  }

  .stat-summary-card .stat-item {
    flex: 1 1 calc(50% - 1px);
    min-width: 120px;
  }

  .stat-summary-card .stat-item:nth-child(2n+1)::before {
    display: none;
  }
}

/* ══ Shared dark selector — apply to both explicit dark AND default (no theme set) ══ */
:root:not([data-theme="light"]),
[data-theme="dark"] {

  /* ── CSS variable overrides for dark mode ── */
  --bg-surface: rgba(12, 16, 30, 0.72);
  --bg-card: rgba(12, 15, 28, 0.65);
  --bg-hover: rgba(255, 255, 255, 0.07);
  --bg-input: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.13);
  --border-light: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(93, 169, 47, 0.6);
  --text: rgba(225, 238, 255, 0.95);
  --text-muted: rgba(150, 180, 220, 0.72);
  --text-subtle: rgba(110, 145, 195, 0.55);

  /* ── KEY FIX: --bg-page must be dark in dark mode ──
     In stockin.js rows use background:var(--bg-page); this overrides the
     #f3f4f6 default from style.css so rows appear dark/glassy. */
  --bg-page: rgba(10, 13, 26, 0.55);
}

/* ══════════════════════════════════════════════════════════════════
   MODAL — Dark glass effect
   ══════════════════════════════════════════════════════════════════ */
:root:not([data-theme="light"]) .modal,
[data-theme="dark"] .modal {
  background: rgba(10, 14, 28, 0.84) !important;
  backdrop-filter: blur(28px) saturate(1.8) !important;
  -webkit-backdrop-filter: blur(28px) saturate(1.8) !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  box-shadow:
    0 24px 64px rgba(0, 0, 0, 0.58),
    0 4px 16px rgba(0, 0, 0, 0.38),
    inset 0 1px 0 rgba(255, 255, 255, 0.10) !important;
  color: rgba(225, 238, 255, 0.95) !important;
}

:root:not([data-theme="light"]) .modal-overlay,
[data-theme="dark"] .modal-overlay {
  background: rgba(2, 4, 12, 0.62) !important;
  backdrop-filter: blur(8px) !important;
  -webkit-backdrop-filter: blur(8px) !important;
}

:root:not([data-theme="light"]) .modal-header,
[data-theme="dark"] .modal-header {
  background: rgba(255, 255, 255, 0.04) !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09) !important;
}

:root:not([data-theme="light"]) .modal-title,
[data-theme="dark"] .modal-title {
  color: rgba(218, 234, 255, 0.96) !important;
}

:root:not([data-theme="light"]) .modal-body,
[data-theme="dark"] .modal-body {
  background: transparent !important;
}

:root:not([data-theme="light"]) .modal-footer,
[data-theme="dark"] .modal-footer {
  background: rgba(255, 255, 255, 0.035) !important;
  border-top: 1px solid rgba(255, 255, 255, 0.09) !important;
}

:root:not([data-theme="light"]) .modal-close,
[data-theme="dark"] .modal-close {
  background: rgba(255, 255, 255, 0.07) !important;
  border-color: rgba(255, 255, 255, 0.12) !important;
  color: rgba(180, 200, 240, 0.72) !important;
}

:root:not([data-theme="light"]) .modal-close:hover,
[data-theme="dark"] .modal-close:hover {
  background: rgba(220, 38, 38, 0.18) !important;
  border-color: rgba(220, 38, 38, 0.35) !important;
  color: #ff6b6b !important;
}

/* ══════════════════════════════════════════════════════════════════
   TABLES — Inside and outside modals
   ══════════════════════════════════════════════════════════════════ */
:root:not([data-theme="light"]) thead,
[data-theme="dark"] thead {
  background: rgba(255, 255, 255, 0.06) !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12) !important;
}

:root:not([data-theme="light"]) th,
[data-theme="dark"] th {
  color: rgba(150, 185, 230, 0.80) !important;
}

:root:not([data-theme="light"]) td,
[data-theme="dark"] td {
  color: rgba(215, 230, 255, 0.90) !important;
  border-bottom-color: rgba(255, 255, 255, 0.07) !important;
}

:root:not([data-theme="light"]) tr:hover td,
[data-theme="dark"] tr:hover td {
  background: rgba(255, 255, 255, 0.05) !important;
}

:root:not([data-theme="light"]) .table-card,
[data-theme="dark"] .table-card {
  background: rgba(10, 14, 28, 0.60) !important;
  border-color: rgba(255, 255, 255, 0.10) !important;
}

/* ══════════════════════════════════════════════════════════════════
   SEARCH INPUTS — Glass effect in all modules
   ══════════════════════════════════════════════════════════════════ */
:root:not([data-theme="light"]) .search-input,
[data-theme="dark"] .search-input {
  background: rgba(255, 255, 255, 0.08) !important;
  border: 1px solid rgba(255, 255, 255, 0.16) !important;
  color: rgba(220, 235, 255, 0.95) !important;
  backdrop-filter: blur(10px) !important;
  -webkit-backdrop-filter: blur(10px) !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06),
    inset 0 -1px 0 rgba(0, 0, 0, 0.12) !important;
}

:root:not([data-theme="light"]) .search-input::placeholder,
[data-theme="dark"] .search-input::placeholder {
  color: rgba(150, 175, 215, 0.48) !important;
}

:root:not([data-theme="light"]) .search-input:focus,
[data-theme="dark"] .search-input:focus {
  background: rgba(255, 255, 255, 0.12) !important;
  border-color: rgba(93, 169, 47, 0.55) !important;
  box-shadow: 0 0 0 3px rgba(93, 169, 47, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.10) !important;
}

/* ══════════════════════════════════════════════════════════════════
   ALL FORM INPUTS
   ══════════════════════════════════════════════════════════════════ */
:root:not([data-theme="light"]) input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="file"]),
:root:not([data-theme="light"]) select,
:root:not([data-theme="light"]) textarea,
[data-theme="dark"] input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="file"]),
[data-theme="dark"] select,
[data-theme="dark"] textarea {
  background: rgba(255, 255, 255, 0.08) !important;
  border-color: rgba(255, 255, 255, 0.15) !important;
  color: rgba(220, 235, 255, 0.95) !important;
}

:root:not([data-theme="light"]) input::placeholder,
:root:not([data-theme="light"]) textarea::placeholder,
[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder {
  color: rgba(140, 170, 210, 0.46) !important;
}

:root:not([data-theme="light"]) input:focus,
:root:not([data-theme="light"]) select:focus,
:root:not([data-theme="light"]) textarea:focus,
[data-theme="dark"] input:focus,
[data-theme="dark"] select:focus,
[data-theme="dark"] textarea:focus {
  background: rgba(255, 255, 255, 0.12) !important;
  border-color: rgba(93, 169, 47, 0.55) !important;
  box-shadow: 0 0 0 3px rgba(93, 169, 47, 0.16) !important;
  outline: none !important;
}

:root:not([data-theme="light"]) select option,
[data-theme="dark"] select option {
  background: #0f1525 !important;
  color: #d0e4ff !important;
}

:root:not([data-theme="light"]) .form-group label,
[data-theme="dark"] .form-group label {
  color: rgba(162, 192, 232, 0.80) !important;
}

/* ══════════════════════════════════════════════════════════════════
   BUTTONS — Ghost/secondary
   ══════════════════════════════════════════════════════════════════ */
:root:not([data-theme="light"]) .btn-ghost,
[data-theme="dark"] .btn-ghost {
  background: rgba(255, 255, 255, 0.07) !important;
  border-color: rgba(255, 255, 255, 0.15) !important;
  color: rgba(200, 220, 255, 0.85) !important;
}

:root:not([data-theme="light"]) .btn-ghost:hover,
[data-theme="dark"] .btn-ghost:hover {
  background: rgba(255, 255, 255, 0.12) !important;
  color: rgba(220, 238, 255, 0.95) !important;
}

/* ══════════════════════════════════════════════════════════════════
   STATUS CHIPS — Dark mode adaptation
   ══════════════════════════════════════════════════════════════════ */
:root:not([data-theme="light"]) .chip-draft,
[data-theme="dark"] .chip-draft {
  background: rgba(100, 116, 139, 0.20) !important;
  color: rgba(180, 200, 230, 0.85) !important;
  border-color: rgba(100, 116, 139, 0.30) !important;
}

:root:not([data-theme="light"]) .chip-open,
[data-theme="dark"] .chip-open {
  background: rgba(47, 142, 38, 0.20) !important;
  color: #7dda6e !important;
  border-color: rgba(47, 142, 38, 0.35) !important;
}

:root:not([data-theme="light"]) .chip-progress,
[data-theme="dark"] .chip-progress {
  background: rgba(217, 119, 6, 0.20) !important;
  color: #fbbf24 !important;
  border-color: rgba(217, 119, 6, 0.35) !important;
}

:root:not([data-theme="light"]) .chip-done,
:root:not([data-theme="light"]) .chip-posted,
[data-theme="dark"] .chip-done,
[data-theme="dark"] .chip-posted {
  background: rgba(5, 150, 105, 0.20) !important;
  color: #34d399 !important;
  border-color: rgba(5, 150, 105, 0.35) !important;
}

:root:not([data-theme="light"]) .chip-cancelled,
[data-theme="dark"] .chip-cancelled {
  background: rgba(220, 38, 38, 0.18) !important;
  color: #f87171 !important;
  border-color: rgba(220, 38, 38, 0.32) !important;
}

/* ══════════════════════════════════════════════════════════════════
   GENERAL TEXT
   ══════════════════════════════════════════════════════════════════ */
:root:not([data-theme="light"]) .page-title,
[data-theme="dark"] .page-title {
  color: rgba(218, 236, 255, 0.96) !important;
}

:root:not([data-theme="light"]) .page-sub,
[data-theme="dark"] .page-sub {
  color: rgba(148, 178, 225, 0.72) !important;
}

:root:not([data-theme="light"]) .stat-label,
[data-theme="dark"] .stat-label {
  color: rgba(140, 175, 220, 0.75) !important;
}

/* ══════════════════════════════════════════════════════════════════
   TOPBAR ELEMENTS
   ══════════════════════════════════════════════════════════════════ */
:root:not([data-theme="light"]) .topbar-username,
[data-theme="dark"] .topbar-username {
  color: rgba(210, 228, 255, 0.90) !important;
}

:root:not([data-theme="light"]) .bc-item,
[data-theme="dark"] .bc-item {
  color: rgba(160, 190, 230, 0.72) !important;
}

:root:not([data-theme="light"]) .bc-item:last-child,
[data-theme="dark"] .bc-item:last-child {
  color: rgba(220, 238, 255, 0.95) !important;
}

:root:not([data-theme="light"]) .bc-sep,
[data-theme="dark"] .bc-sep {
  color: rgba(100, 130, 180, 0.42) !important;
}

/* Topbar search dropdown */
:root:not([data-theme="light"]) .topbar-search-results,
[data-theme="dark"] .topbar-search-results {
  background: rgba(10, 14, 30, 0.92) !important;
  border-color: rgba(255, 255, 255, 0.12) !important;
  backdrop-filter: blur(20px) !important;
}

:root:not([data-theme="light"]) .tsr-item:hover,
[data-theme="dark"] .tsr-item:hover {
  background: rgba(255, 255, 255, 0.055) !important;
}

/* User dropdown */
:root:not([data-theme="light"]) .topbar-dropdown,
[data-theme="dark"] .topbar-dropdown {
  background: rgba(10, 14, 30, 0.92) !important;
  border-color: rgba(255, 255, 255, 0.12) !important;
  backdrop-filter: blur(20px) !important;
}

:root:not([data-theme="light"]) .td-header,
[data-theme="dark"] .td-header {
  background: rgba(255, 255, 255, 0.046) !important;
}

:root:not([data-theme="light"]) .td-item,
[data-theme="dark"] .td-item {
  color: rgba(210, 228, 255, 0.88) !important;
}

:root:not([data-theme="light"]) .td-item:hover,
[data-theme="dark"] .td-item:hover {
  background: rgba(255, 255, 255, 0.055) !important;
}

:root:not([data-theme="light"]) .td-divider,
[data-theme="dark"] .td-divider {
  background: rgba(255, 255, 255, 0.08) !important;
}

/* ══════════════════════════════════════════════════════════════════
   TOOLBAR FILTER SELECTS
   ══════════════════════════════════════════════════════════════════ */
:root:not([data-theme="light"]) .toolbar select,
[data-theme="dark"] .toolbar select {
  background: rgba(255, 255, 255, 0.08) !important;
  border-color: rgba(255, 255, 255, 0.15) !important;
  color: rgba(215, 232, 255, 0.90) !important;
}

/* ══════════════════════════════════════════════════════════════════
   CONFIRM DIALOGS
   ══════════════════════════════════════════════════════════════════ */
:root:not([data-theme="light"]) .confirm-dialog,
[data-theme="dark"] .confirm-dialog {
  background: rgba(8, 12, 24, 0.90) !important;
  border-color: rgba(255, 255, 255, 0.12) !important;
  backdrop-filter: blur(24px) !important;
  -webkit-backdrop-filter: blur(24px) !important;
  color: rgba(220, 235, 255, 0.95) !important;
}

/* ══════════════════════════════════════════════════════════════════
   EMPTY STATE & CODE
   ══════════════════════════════════════════════════════════════════ */
:root:not([data-theme="light"]) .empty-row td,
[data-theme="dark"] .empty-row td {
  color: rgba(130, 165, 210, 0.52) !important;
}

:root:not([data-theme="light"]) code,
[data-theme="dark"] code {
  background: rgba(93, 169, 47, 0.16) !important;
  color: #9bd46a !important;
  border-color: rgba(93, 169, 47, 0.28) !important;
}

/* ══════════════════════════════════════════════════════════════════
   LIGHT MODE — Preserve clean white glass appearance
   ══════════════════════════════════════════════════════════════════ */
[data-theme="light"] .modal {
  background: rgba(248, 252, 255, 0.94) !important;
  border-color: rgba(80, 130, 200, 0.18) !important;
  color: rgba(15, 25, 55, 0.95) !important;
  backdrop-filter: blur(24px) saturate(1.6) !important;
  -webkit-backdrop-filter: blur(24px) saturate(1.6) !important;
}

[data-theme="light"] .modal-header {
  background: rgba(255, 255, 255, 0.55) !important;
  border-bottom-color: rgba(80, 130, 200, 0.12) !important;
}

[data-theme="light"] .modal-footer {
  background: rgba(240, 248, 255, 0.72) !important;
  border-top-color: rgba(80, 130, 200, 0.12) !important;
}

[data-theme="light"] .modal-title {
  color: rgba(12, 22, 55, 0.96) !important;
}

[data-theme="light"] .modal-close {
  background: rgba(0, 0, 0, 0.05) !important;
  border-color: rgba(0, 0, 0, 0.10) !important;
  color: rgba(60, 80, 120, 0.65) !important;
}

[data-theme="light"] .search-input {
  background: rgba(255, 255, 255, 0.78) !important;
  border-color: rgba(80, 130, 200, 0.20) !important;
  color: rgba(15, 25, 55, 0.95) !important;
  backdrop-filter: blur(8px) !important;
}

[data-theme="light"] thead {
  background: rgba(235, 245, 255, 0.88) !important;
}

[data-theme="light"] th {
  color: rgba(40, 80, 140, 0.80) !important;
}

[data-theme="light"] td {
  color: rgba(15, 30, 70, 0.90) !important;
  border-bottom-color: rgba(80, 130, 200, 0.10) !important;
}

[data-theme="light"] tr:hover td {
  background: rgba(200, 222, 255, 0.22) !important;
}

[data-theme="light"] select option {
  background: #f0f6ff !important;
  color: #0f1d3a !important;
}

[data-theme="light"] .chip-draft {
  background: rgba(100, 116, 139, 0.10) !important;
  color: #475569 !important;
  border-color: rgba(100, 116, 139, 0.22) !important;
}

[data-theme="light"] .topbar-dropdown,
[data-theme="light"] .topbar-search-results {
  background: rgba(248, 252, 255, 0.96) !important;
  border-color: rgba(80, 130, 200, 0.16) !important;
  backdrop-filter: blur(16px) !important;
}

[data-theme="light"] .td-item {
  color: rgba(20, 40, 80, 0.88) !important;
}

[data-theme="light"] .td-item:hover {
  background: rgba(200, 222, 255, 0.22) !important;
}

/* ══════════════════════════════════════════════════════════════════
   STOCK-IN SEARCHABLE SELECT (pn-ss-trigger) — Dark mode glass
   The trigger button uses a plain background that's hardcoded in JS;
   we override here so it matches the dark glass aesthetic.
   ══════════════════════════════════════════════════════════════════ */
:root:not([data-theme="light"]) .pn-ss-trigger,
[data-theme="dark"] .pn-ss-trigger {
  background: rgba(255, 255, 255, 0.08) !important;
  border: 1px solid rgba(255, 255, 255, 0.15) !important;
  color: rgba(220, 235, 255, 0.95) !important;
  border-radius: 7px;
  backdrop-filter: blur(8px) !important;
  -webkit-backdrop-filter: blur(8px) !important;
}

:root:not([data-theme="light"]) .pn-ss-trigger:hover,
:root:not([data-theme="light"]) .pn-ss-trigger.open,
[data-theme="dark"] .pn-ss-trigger:hover,
[data-theme="dark"] .pn-ss-trigger.open {
  background: rgba(255, 255, 255, 0.13) !important;
  border-color: rgba(93, 169, 47, 0.50) !important;
}

:root:not([data-theme="light"]) .pn-ss-label,
[data-theme="dark"] .pn-ss-label {
  color: rgba(220, 235, 255, 0.92) !important;
}

:root:not([data-theme="light"]) .pn-ss-arrow,
[data-theme="dark"] .pn-ss-arrow {
  color: rgba(140, 175, 215, 0.65) !important;
}

:root:not([data-theme="light"]) .pn-ss-dropdown,
[data-theme="dark"] .pn-ss-dropdown {
  background: rgba(10, 14, 30, 0.95) !important;
  border: 1px solid rgba(255, 255, 255, 0.14) !important;
  backdrop-filter: blur(20px) !important;
  -webkit-backdrop-filter: blur(20px) !important;
}

:root:not([data-theme="light"]) .pn-ss-opt,
[data-theme="dark"] .pn-ss-opt {
  color: rgba(210, 228, 255, 0.90) !important;
}

:root:not([data-theme="light"]) .pn-ss-opt:hover,
[data-theme="dark"] .pn-ss-opt:hover {
  background: rgba(93, 169, 47, 0.16) !important;
  color: rgba(180, 230, 140, 0.95) !important;
}

:root:not([data-theme="light"]) .pn-ss-opt.selected,
[data-theme="dark"] .pn-ss-opt.selected {
  background: rgba(93, 169, 47, 0.22) !important;
  color: #9bd46a !important;
}

:root:not([data-theme="light"]) .pn-ss-search,
[data-theme="dark"] .pn-ss-search {
  background: rgba(255, 255, 255, 0.07) !important;
  border-color: rgba(255, 255, 255, 0.13) !important;
  color: rgba(215, 232, 255, 0.95) !important;
}

/* ══════════════════════════════════════════════════════════════════
   STOCK-IN TABLE ROWS — explicit bg-page rows (from inline style)
   These tr elements use style="background:var(--bg-page)".
   The --bg-page override in :root ensures they appear dark, but
   we add a belt-and-suspenders tr override for any edge cases.
   ══════════════════════════════════════════════════════════════════ */
:root:not([data-theme="light"]) #pn-form-overlay tr,
[data-theme="dark"] #pn-form-overlay tr {
  background-color: transparent !important;
}

:root:not([data-theme="light"]) #pn-form-overlay tr[style*="bg-page"],
[data-theme="dark"] #pn-form-overlay tr[style*="bg-page"] {
  background: rgba(255, 255, 255, 0.04) !important;
}

:root:not([data-theme="light"]) #pn-form-overlay #pn-addline-row td,
[data-theme="dark"] #pn-form-overlay #pn-addline-row td {
  background: rgba(255, 255, 255, 0.03) !important;
  border-color: rgba(255, 255, 255, 0.10) !important;
}

/* ══════════════════════════════════════════════════════════════════
   PROJECT DETAIL PANEL (proj-panel) — GLASS EFFECT BOTH MODES
   Applied via a pn-form-overlay sibling — glass on the fixed panel.
   ══════════════════════════════════════════════════════════════════ */

/* DARK MODE — Deep glass panel */
:root:not([data-theme="light"]) .proj-panel,
[data-theme="dark"] .proj-panel {
  background: rgba(8, 11, 24, 0.82) !important;
  backdrop-filter: blur(32px) saturate(1.6) !important;
  -webkit-backdrop-filter: blur(32px) saturate(1.6) !important;
  border-left: 1px solid rgba(255, 255, 255, 0.10) !important;
  box-shadow:
    -12px 0 48px rgba(0, 0, 0, 0.50),
    inset 1px 0 0 rgba(255, 255, 255, 0.06) !important;
}

:root:not([data-theme="light"]) .proj-panel-head,
[data-theme="dark"] .proj-panel-head {
  background: rgba(255, 255, 255, 0.04) !important;
  border-bottom-color: rgba(255, 255, 255, 0.08) !important;
}

:root:not([data-theme="light"]) .proj-panel-title,
[data-theme="dark"] .proj-panel-title {
  color: rgba(218, 236, 255, 0.96) !important;
}

:root:not([data-theme="light"]) .proj-panel-tabs,
[data-theme="dark"] .proj-panel-tabs {
  background: rgba(255, 255, 255, 0.03) !important;
  border-bottom-color: rgba(255, 255, 255, 0.08) !important;
}

:root:not([data-theme="light"]) .ppanel-tab,
[data-theme="dark"] .ppanel-tab {
  color: rgba(150, 182, 228, 0.72) !important;
}

:root:not([data-theme="light"]) .ppanel-tab.active,
[data-theme="dark"] .ppanel-tab.active {
  color: #9bd46a !important;
  border-bottom-color: #9bd46a !important;
}

:root:not([data-theme="light"]) .ppanel-chat,
[data-theme="dark"] .ppanel-chat {
  background: rgba(255, 255, 255, 0.04) !important;
  border-color: rgba(255, 255, 255, 0.09) !important;
}

:root:not([data-theme="light"]) .ppanel-msg-bubble,
[data-theme="dark"] .ppanel-msg-bubble {
  background: rgba(255, 255, 255, 0.07) !important;
  border-color: rgba(255, 255, 255, 0.10) !important;
  color: rgba(215, 230, 255, 0.92) !important;
}

:root:not([data-theme="light"]) .ppanel-chat-input-row,
[data-theme="dark"] .ppanel-chat-input-row {
  background: rgba(255, 255, 255, 0.04) !important;
  border-top-color: rgba(255, 255, 255, 0.08) !important;
}

:root:not([data-theme="light"]) .ppanel-assign,
[data-theme="dark"] .ppanel-assign {
  background: rgba(255, 255, 255, 0.05) !important;
  border-color: rgba(255, 255, 255, 0.10) !important;
}

/* LIGHT MODE — Frosted bright glass panel */
[data-theme="light"] .proj-panel {
  background: rgba(240, 248, 255, 0.82) !important;
  backdrop-filter: blur(28px) saturate(1.8) !important;
  -webkit-backdrop-filter: blur(28px) saturate(1.8) !important;
  border-left: 1px solid rgba(100, 160, 230, 0.22) !important;
  box-shadow:
    -8px 0 32px rgba(30, 80, 160, 0.14),
    inset 1px 0 0 rgba(255, 255, 255, 0.80) !important;
}

[data-theme="light"] .proj-panel-head {
  background: rgba(255, 255, 255, 0.60) !important;
  border-bottom-color: rgba(80, 140, 215, 0.14) !important;
}

[data-theme="light"] .proj-panel-tabs {
  background: rgba(255, 255, 255, 0.50) !important;
  border-bottom-color: rgba(80, 140, 215, 0.12) !important;
}

[data-theme="light"] .ppanel-chat {
  background: rgba(255, 255, 255, 0.55) !important;
  border-color: rgba(80, 140, 215, 0.16) !important;
}

[data-theme="light"] .ppanel-chat-input-row {
  background: rgba(240, 248, 255, 0.72) !important;
  border-top-color: rgba(80, 140, 215, 0.14) !important;
}

[data-theme="light"] .ppanel-assign {
  background: rgba(255, 255, 255, 0.68) !important;
  border-color: rgba(80, 140, 215, 0.18) !important;
}


[data-theme="light"] .ppanel-msg-bubble {
  background: rgba(225, 238, 255, 0.82) !important;
  border-color: rgba(80, 140, 215, 0.18) !important;
  color: rgba(20, 40, 90, 0.92) !important;
}

/* ══════════════════════════════════════════════════════════════════
   KANBAN BOARD — Dark mode overrides
   Fix: kanban cards/cols hien thi mau light khi dark mode bat
   ══════════════════════════════════════════════════════════════════ */

:root:not([data-theme="light"]) .kanban-col,
[data-theme="dark"] .kanban-col {
  background: rgba(18, 24, 42, 0.82) !important;
  border-color: rgba(255, 255, 255, 0.10) !important;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.32) !important;
}

:root:not([data-theme="light"]) .kanban-col-header,
[data-theme="dark"] .kanban-col-header {
  background: rgba(255, 255, 255, 0.04) !important;
  border-bottom-color: rgba(255, 255, 255, 0.09) !important;
}

:root:not([data-theme="light"]) .kanban-card,
[data-theme="dark"] .kanban-card {
  background: rgba(22, 30, 52, 0.90) !important;
  border-color: rgba(255, 255, 255, 0.11) !important;
  box-shadow: 0 2px 10px rgba(0,0,0,.28), inset 0 1px 0 rgba(255,255,255,.06) !important;
}

:root:not([data-theme="light"]) .kanban-card:hover,
[data-theme="dark"] .kanban-card:hover {
  background: rgba(28, 38, 66, 0.95) !important;
  border-color: rgba(93, 169, 47, 0.35) !important;
  box-shadow: 0 4px 20px rgba(0,0,0,.35), 0 0 0 1px rgba(93,169,47,.18) !important;
}

:root:not([data-theme="light"]) .kanban-card-name,
[data-theme="dark"] .kanban-card-name {
  color: rgba(220, 235, 255, 0.95) !important;
}

:root:not([data-theme="light"]) .kanban-card-meta,
:root:not([data-theme="light"]) .kanban-card-cust,
[data-theme="dark"] .kanban-card-meta,
[data-theme="dark"] .kanban-card-cust {
  color: rgba(148, 178, 225, 0.72) !important;
}

:root:not([data-theme="light"]) .kanban-card-footer,
[data-theme="dark"] .kanban-card-footer {
  border-top-color: rgba(255, 255, 255, 0.09) !important;
}

:root:not([data-theme="light"]) .kcard-date,
[data-theme="dark"] .kcard-date {
  background: rgba(255, 255, 255, 0.07) !important;
  color: rgba(148, 178, 225, 0.80) !important;
}

:root:not([data-theme="light"]) .kanban-empty,
[data-theme="dark"] .kanban-empty {
  border-color: rgba(255, 255, 255, 0.12) !important;
  color: rgba(140, 175, 220, 0.60) !important;
  background: rgba(255, 255, 255, 0.03) !important;
}

:root:not([data-theme="light"]) .kanban-add-btn,
[data-theme="dark"] .kanban-add-btn {
  border-color: rgba(255, 255, 255, 0.13) !important;
  color: rgba(140, 175, 220, 0.65) !important;
}

:root:not([data-theme="light"]) .kanban-add-btn:hover,
[data-theme="dark"] .kanban-add-btn:hover {
  border-color: rgba(93, 169, 47, 0.45) !important;
  color: rgba(155, 212, 106, 0.90) !important;
  background: rgba(93, 169, 47, 0.10) !important;
}

:root:not([data-theme="light"]) .kanban-col[data-dragover="true"],
[data-theme="dark"] .kanban-col[data-dragover="true"] {
  background: rgba(93, 169, 47, 0.12) !important;
  border-color: rgba(93, 169, 47, 0.50) !important;
  box-shadow: 0 0 0 3px rgba(93,169,47,.22), 0 8px 32px rgba(0,0,0,.32) !important;
}

:root:not([data-theme="light"]) #kanban-drag-ghost,
[data-theme="dark"] #kanban-drag-ghost {
  background: rgba(22, 30, 52, 0.97) !important;
  border-color: rgba(93, 169, 47, 0.60) !important;
  box-shadow: 0 20px 56px rgba(0,0,0,.52), 0 0 0 1px rgba(93,169,47,.25) !important;
}

:root:not([data-theme="light"]) #kanban-col-ghost,
[data-theme="dark"] #kanban-col-ghost {
  background: rgba(18, 24, 42, 0.90) !important;
  border-color: rgba(93, 169, 47, 0.55) !important;
  box-shadow: 0 20px 56px rgba(0,0,0,.50), 0 0 0 1.5px rgba(93,169,47,.30) !important;
}

:root:not([data-theme="light"]) .kanban-col-placeholder,
[data-theme="dark"] .kanban-col-placeholder {
  background: rgba(93, 169, 47, 0.06) !important;
  border-color: rgba(93, 169, 47, 0.30) !important;
}
