/* PMS Admin theme: light is the default; dark applies when <html data-theme="dark"> */
:root { color-scheme: light; }

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1218;          /* page */
  --surface: #181c24;     /* cards, tables, modals */
  --surface-2: #1f242e;   /* inputs, hover, subtle fills */
  --border: #2b313d;
  --text: #e6e8ec;
  --muted: #9aa3b2;

  /* variables used by individual pages */
  --cr-surface: var(--surface); --cr-border: var(--border); --cr-muted: var(--muted);
  --cr-text: var(--text); --cr-soft: var(--surface-2);
}

html[data-theme="dark"] body { background: var(--bg); color: var(--text); }

/* ── Tailwind surfaces ── */
html[data-theme="dark"] .bg-white            { background-color: var(--surface) !important; }
html[data-theme="dark"] .bg-gray-50          { background-color: var(--bg) !important; }
html[data-theme="dark"] .bg-gray-100,
html[data-theme="dark"] .hover\:bg-gray-100:hover { background-color: var(--surface-2) !important; }
html[data-theme="dark"] .bg-gray-200         { background-color: #2b313d !important; }
html[data-theme="dark"] .bg-orange-50        { background-color: rgba(230,81,0,.14) !important; }
html[data-theme="dark"] .bg-orange-100       { background-color: rgba(230,81,0,.22) !important; }
html[data-theme="dark"] .bg-green-100        { background-color: rgba(34,197,94,.18) !important; }
html[data-theme="dark"] .bg-red-100          { background-color: rgba(239,68,68,.18) !important; }
html[data-theme="dark"] .bg-blue-100         { background-color: rgba(59,130,246,.18) !important; }
html[data-theme="dark"] .bg-yellow-100       { background-color: rgba(234,179,8,.18) !important; }
html[data-theme="dark"] .bg-cyan-100         { background-color: rgba(6,182,212,.18) !important; }

/* ── Tailwind text ── */
html[data-theme="dark"] .text-black,
html[data-theme="dark"] .text-gray-900,
html[data-theme="dark"] .text-gray-800       { color: var(--text) !important; }
html[data-theme="dark"] .text-gray-700,
html[data-theme="dark"] .text-gray-600       { color: #c5cad3 !important; }
html[data-theme="dark"] .text-gray-500,
html[data-theme="dark"] .text-gray-400       { color: var(--muted) !important; }
html[data-theme="dark"] .text-green-700, html[data-theme="dark"] .text-green-800 { color: #4ade80 !important; }
html[data-theme="dark"] .text-red-700,  html[data-theme="dark"] .text-red-800, html[data-theme="dark"] .text-red-900 { color: #f87171 !important; }
html[data-theme="dark"] .text-blue-600, html[data-theme="dark"] .text-blue-900 { color: #60a5fa !important; }
html[data-theme="dark"] .text-orange-700 { color: #fb923c !important; }
html[data-theme="dark"] .text-cyan-700   { color: #22d3ee !important; }

/* ── Tailwind borders / dividers ── */
html[data-theme="dark"] .border-gray-100, html[data-theme="dark"] .border-gray-200,
html[data-theme="dark"] .border-gray-300 { border-color: var(--border) !important; }
html[data-theme="dark"] .divide-gray-200 > :not([hidden]) ~ :not([hidden]) { border-color: var(--border) !important; }
html[data-theme="dark"] .placeholder-gray-400::placeholder { color: var(--muted) !important; }

/* ── Shell ── */
html[data-theme="dark"] #sidebar { background-color: #0b0e13 !important; }
html[data-theme="dark"] header.bg-white { background-color: var(--surface) !important; }
html[data-theme="dark"] .shadow-xl, html[data-theme="dark"] .shadow-lg { --tw-shadow-color: rgba(0,0,0,.6); }

/* ── Shared pms-* components ── */
html[data-theme="dark"] .pms-page-header { background: var(--surface); border-bottom-color: var(--border); }
html[data-theme="dark"] .pms-page-title  { color: var(--text); }
html[data-theme="dark"] .pms-count-badge { background: rgba(230,81,0,.2); color: #fb923c; }
html[data-theme="dark"] .pms-table-wrap  { background: var(--surface); border-color: var(--border); box-shadow: none; }
html[data-theme="dark"] .pms-table tbody tr { border-bottom-color: var(--border); }
html[data-theme="dark"] .pms-table tbody tr:hover { background: var(--surface-2); }
html[data-theme="dark"] .pms-table tbody td { color: #c5cad3; }
html[data-theme="dark"] .pms-modal-card   { background: var(--surface); color: var(--text); }
html[data-theme="dark"] .pms-modal-footer { background: var(--surface); border-top-color: var(--border); }
html[data-theme="dark"] .pms-field-label  { color: var(--muted); }
html[data-theme="dark"] .pms-input,
html[data-theme="dark"] .pms-select,
html[data-theme="dark"] .pms-textarea,
html[data-theme="dark"] .pms-search-input {
  background: var(--surface-2); border-color: var(--border); color: var(--text);
}
html[data-theme="dark"] .pms-input::placeholder, html[data-theme="dark"] .pms-search-input::placeholder { color: var(--muted); }
html[data-theme="dark"] .pms-btn-cancel,
html[data-theme="dark"] .pms-page-btn,
html[data-theme="dark"] .pms-filter-btn { background: var(--surface-2); border-color: var(--border); color: var(--text); }
html[data-theme="dark"] .pms-pagination-info, html[data-theme="dark"] .pms-empty { color: var(--muted); }
html[data-theme="dark"] .pms-badge-gray { background: var(--surface-2); color: var(--muted); }

/* Native form controls on pages that don't use pms-input */
html[data-theme="dark"] input:not([type=checkbox]):not([type=radio]):not([type=color]):not([type=file]),
html[data-theme="dark"] select, html[data-theme="dark"] textarea {
  background-color: var(--surface-2); border-color: var(--border); color: var(--text);
}
html[data-theme="dark"] option { background: var(--surface); color: var(--text); }

/* Inline-styled whites used in a few pages */
html[data-theme="dark"] [style*="background:#fff"],
html[data-theme="dark"] [style*="background: #fff"],
html[data-theme="dark"] [style*="background:white"] { background: var(--surface) !important; }
html[data-theme="dark"] [style*="color:#111827"] { color: var(--text) !important; }
html[data-theme="dark"] [style*="color:#6B7280"] { color: var(--muted) !important; }

/* Theme toggle button (navbar) */
.theme-toggle .i-sun  { display: none; }
html[data-theme="dark"] .theme-toggle .i-sun  { display: block; }
html[data-theme="dark"] .theme-toggle .i-moon { display: none; }

/* ── Light mode: white sidebar (dark mode keeps the dark sidebar above) ── */
html:not([data-theme="dark"]) #sidebar {
  background-color: #ffffff;
  border-right: 1px solid #e5e7eb;
}
html:not([data-theme="dark"]) #sidebar .border-gray-700\/50 { border-color: #e5e7eb; }
html:not([data-theme="dark"]) #sidebar .text-white:not(.sidebar-link.active *):not(.bg-primary *):not(.bg-primary) { color: #111827; }
html:not([data-theme="dark"]) #sidebar .text-gray-400 { color: #4b5563; }          /* link + subtitle text */
html:not([data-theme="dark"]) #sidebar .text-gray-500 { color: #6b7280; }          /* link icons */
html:not([data-theme="dark"]) #sidebar .text-gray-600 { color: #9ca3af; }          /* section headings, chevrons */
html:not([data-theme="dark"]) #sidebar .sidebar-link:not(.active):hover { background-color: #f3f4f6; color: #111827; }
html:not([data-theme="dark"]) #sidebar .sidebar-link:not(.active):hover .text-gray-500,
html:not([data-theme="dark"]) #sidebar .group:hover .group-hover\:text-gray-300 { color: #111827; }
html:not([data-theme="dark"]) #sidebar button.hover\:bg-red-900\/30:hover { background-color: #fef2f2; color: #dc2626; }
