/* ViyaBook Dark Mode — dark.css — load last in every page */

/* ══ Legacy system: html[data-theme="dark"] — kept for backward compat ══ */
html[data-theme="dark"] {
  --vb-bg: #07111f; --vb-card: #0d1f3c; --vb-text: #e2e8f0;
  --vb-muted: #94a3b8; --vb-border: rgba(148,163,184,0.14);
  --ui-bg: #07111f; --ui-card: rgba(15,31,60,0.88); --ui-card-solid: #0d1f3c;
  --ui-text: #e2e8f0; --ui-muted: #94a3b8; --ui-border: rgba(148,163,184,0.14);
  --bg: #07111f; --card: #0d1f3c; --text: #e2e8f0;
  --border: rgba(148,163,184,0.14); --muted: #94a3b8;
}
html[data-theme="dark"] body { background: #07111f !important; color: #e2e8f0 !important; }
html[data-theme="dark"] .card, html[data-theme="dark"] .panel, html[data-theme="dark"] .table-card,
html[data-theme="dark"] .mini-card, html[data-theme="dark"] .side-card, html[data-theme="dark"] .stat-card,
html[data-theme="dark"] .summary-card, html[data-theme="dark"] .type-card, html[data-theme="dark"] .grid-card,
html[data-theme="dark"] .dash-card, html[data-theme="dark"] .quick-card, html[data-theme="dark"] .section,
html[data-theme="dark"] .trip-grid-card { background: #0d1f3c !important; border-color: rgba(148,163,184,0.14) !important; color: #e2e8f0 !important; }
html[data-theme="dark"] .topbar, html[data-theme="dark"] .toolbar, html[data-theme="dark"] .filter-bar,
html[data-theme="dark"] .page-head { background: rgba(13,31,60,0.95) !important; border-color: rgba(148,163,184,0.12) !important; color: #e2e8f0 !important; }
html[data-theme="dark"] .topbar input, html[data-theme="dark"] .search-box input, html[data-theme="dark"] .filter-input { background: rgba(15,23,42,0.8) !important; border-color: rgba(148,163,184,0.2) !important; color: #e2e8f0 !important; }
html[data-theme="dark"] .icon-btn, html[data-theme="dark"] .user-pill { background: rgba(13,31,60,0.9) !important; border-color: rgba(148,163,184,0.18) !important; color: #94a3b8 !important; }
html[data-theme="dark"] thead, html[data-theme="dark"] th { background: #081628 !important; color: #94a3b8 !important; border-color: rgba(148,163,184,0.12) !important; }
html[data-theme="dark"] td { border-color: rgba(148,163,184,0.10) !important; color: #e2e8f0 !important; }
html[data-theme="dark"] tr:hover td { background: rgba(148,163,184,0.05) !important; }
html[data-theme="dark"] input:not([type="checkbox"]):not([type="radio"]), html[data-theme="dark"] select, html[data-theme="dark"] textarea { background: #071627 !important; border-color: rgba(148,163,184,0.22) !important; color: #f1f5f9 !important; }
html[data-theme="dark"] input::placeholder, html[data-theme="dark"] textarea::placeholder { color: #475569 !important; }
html[data-theme="dark"] select option { background: #0d1f3c !important; color: #e2e8f0 !important; }
html[data-theme="dark"] .btn, html[data-theme="dark"] .btn-light, html[data-theme="dark"] button.tab:not(.active), html[data-theme="dark"] .page-btn:not(.active) { background: #0f2040 !important; border-color: rgba(148,163,184,0.2) !important; color: #cbd5e1 !important; }
html[data-theme="dark"] .btn-primary, html[data-theme="dark"] button.tab.active, html[data-theme="dark"] .page-btn.active { background: #0869ff !important; color: #fff !important; border-color: transparent !important; }
html[data-theme="dark"] label, html[data-theme="dark"] .field label { color: #94a3b8 !important; }
html[data-theme="dark"] h1, html[data-theme="dark"] h2, html[data-theme="dark"] h3, html[data-theme="dark"] h4 { color: #f1f5f9 !important; }
html[data-theme="dark"] p, html[data-theme="dark"] .muted, html[data-theme="dark"] .sub, html[data-theme="dark"] small { color: #94a3b8 !important; }
html[data-theme="dark"] strong, html[data-theme="dark"] b { color: #f1f5f9 !important; }
html[data-theme="dark"] .pill-green, html[data-theme="dark"] .pill-paid { background: rgba(34,197,94,0.15) !important; color: #4ade80 !important; }
html[data-theme="dark"] .pill-red, html[data-theme="dark"] .pill-rejected { background: rgba(239,68,68,0.15) !important; color: #f87171 !important; }
html[data-theme="dark"] .pill-blue, html[data-theme="dark"] .pill-approved { background: rgba(59,130,246,0.15) !important; color: #60a5fa !important; }
html[data-theme="dark"] .pill-orange, html[data-theme="dark"] .pill-pending { background: rgba(245,158,11,0.18) !important; color: #fbbf24 !important; }
html[data-theme="dark"] .pill-draft { background: rgba(100,116,139,0.2) !important; color: #94a3b8 !important; }
html[data-theme="dark"] .info-note { background: rgba(59,130,246,0.10) !important; border-color: rgba(59,130,246,0.25) !important; color: #93c5fd !important; }
html[data-theme="dark"] .settings-link.active { background: rgba(59,130,246,0.15) !important; color: #60a5fa !important; }
html[data-theme="dark"] [style*="color:#28466f"], html[data-theme="dark"] [style*="color:#64748b"],
html[data-theme="dark"] [style*="color:#385071"], html[data-theme="dark"] [style*="color:#50698f"] { color: #94a3b8 !important; }
html[data-theme="dark"] [style*="background:#f8fbff"], html[data-theme="dark"] [style*="background:#f0fdf4"],
html[data-theme="dark"] [style*="background:#f8faff"] { background: rgba(15,31,60,0.6) !important; border-color: rgba(148,163,184,0.14) !important; }
html[data-theme="dark"] hr, html[data-theme="dark"] .divider { border-color: rgba(148,163,184,0.12) !important; }
@media print { html[data-theme="dark"] * { background: #fff !important; color: #000 !important; } }

/* ══ ViyaBook Dark Mode — Complete (html.viya-dv flash-safe system) ══ */

html.viya-dv,
html.viya-dv body {
  background: #0a0f1e !important;
  color: #e2e8f0 !important;
}

/* Cards and panels */
html.viya-dv .card,
html.viya-dv .panel,
html.viya-dv .section-card,
html.viya-dv .metric-card,
html.viya-dv .td-card,
html.viya-dv .modal-card,
html.viya-dv .settings-card,
html.viya-dv [class*="-card"],
html.viya-dv [class*="-panel"] {
  background: #111827 !important;
  border-color: #1f2937 !important;
  color: #e2e8f0 !important;
}

/* Tables */
html.viya-dv table,
html.viya-dv .td-table,
html.viya-dv .data-table {
  color: #e2e8f0 !important;
}
html.viya-dv thead,
html.viya-dv th {
  background: #1f2937 !important;
  color: #94a3b8 !important;
  border-color: #374151 !important;
}
html.viya-dv tbody tr {
  background: #111827 !important;
  border-color: #1f2937 !important;
}
html.viya-dv tbody tr:hover {
  background: #1f2937 !important;
}
html.viya-dv td {
  color: #e2e8f0 !important;
  border-color: #1f2937 !important;
}

/* All text must be readable */
html.viya-dv h1, html.viya-dv h2, html.viya-dv h3,
html.viya-dv h4, html.viya-dv h5, html.viya-dv h6 {
  color: #f1f5f9 !important;
}
html.viya-dv p, html.viya-dv span, html.viya-dv div,
html.viya-dv label, html.viya-dv li {
  color: #cbd5e1;
}
html.viya-dv .text-muted,
html.viya-dv .muted,
html.viya-dv [class*="muted"],
html.viya-dv [class*="sub"],
html.viya-dv .description {
  color: #64748b !important;
}

/* Forms and inputs */
html.viya-dv input,
html.viya-dv select,
html.viya-dv textarea {
  background: #1f2937 !important;
  border-color: #374151 !important;
  color: #e2e8f0 !important;
}
html.viya-dv input::placeholder,
html.viya-dv textarea::placeholder {
  color: #4b5563 !important;
}
html.viya-dv input:focus,
html.viya-dv select:focus,
html.viya-dv textarea:focus {
  border-color: #7c3aed !important;
  outline: none !important;
}

/* Buttons */
html.viya-dv .btn,
html.viya-dv button:not(.btn-primary):not([class*="gradient"]) {
  background: #1f2937 !important;
  border-color: #374151 !important;
  color: #e2e8f0 !important;
}
html.viya-dv .btn:hover {
  background: #374151 !important;
}
/* Keep gradient/primary buttons */
html.viya-dv .btn-primary,
html.viya-dv [style*="linear-gradient"] {
  background: inherit !important;
  color: #fff !important;
}

/* Search bar — dark mode: all patterns */
html.viya-dv .search,
html.viya-dv .top-search,
html.viya-dv .search-box,
html.viya-dv .filter-search,
html.viya-dv .table-search,
html.viya-dv .search-wrap,
html.viya-dv .viya-header-search,
html.viya-dv .topbar-search,
html.viya-dv .pos-search-bar,
html.viya-dv [class*="search-bar"],
html.viya-dv [class*="search-wrap"] {
  background-color: #1e293b !important;
  border-color:     #334155 !important;
}
/* Wrapper inner inputs */
html.viya-dv .search input,
html.viya-dv .top-search input,
html.viya-dv .search-box input,
html.viya-dv .filter-search input,
html.viya-dv .table-search input,
html.viya-dv .search-wrap input,
html.viya-dv .viya-header-search input,
html.viya-dv .topbar-search input,
html.viya-dv .pos-search-bar input {
  background:   transparent !important;
  border:       none !important;
  color:        #e2e8f0 !important;
}
html.viya-dv .search input::placeholder,
html.viya-dv .top-search input::placeholder,
html.viya-dv .search-box input::placeholder,
html.viya-dv .filter-search input::placeholder {
  color: #64748b !important;
}
/* Direct inputs */
html.viya-dv input.search,
html.viya-dv input.top-search,
html.viya-dv input.search-box,
html.viya-dv input.filter-search {
  background-color: #1e293b !important;
  border-color:     #334155 !important;
  color:            #e2e8f0 !important;
}
html.viya-dv input.search::placeholder,
html.viya-dv input.top-search::placeholder,
html.viya-dv input.search-box::placeholder {
  color: #64748b !important;
}
/* Panel / filter-bar classless inputs */
html.viya-dv .panel-head > input,
html.viya-dv .filter-bar > input {
  background-color: #1e293b !important;
  border-color:     #334155 !important;
  color:            #e2e8f0 !important;
}
html.viya-dv .panel-head > input::placeholder,
html.viya-dv .filter-bar > input::placeholder {
  color: #64748b !important;
}

/* Top bar / Header */
html.viya-dv .viya-app-header,
html.viya-dv .topbar,
html.viya-dv .pos-header,
html.viya-dv header,
html.viya-dv .page-header,
html.viya-dv .head-actions {
  background: #111827 !important;
  border-color: #1f2937 !important;
}

/* Header action buttons — keep white bg with dark text → dark bg */
html.viya-dv .viya-back-btn,
html.viya-dv .viya-icon-btn,
html.viya-dv .viya-profile-trigger {
  background: #1f2937 !important;
  border-color: #374151 !important;
  color: #e2e8f0 !important;
}

/* Profile menu */
html.viya-dv .viya-profile-menu {
  background: #111827 !important;
  border-color: #374151 !important;
}
html.viya-dv .viya-profile-menu a,
html.viya-dv .viya-profile-menu button {
  color: #e2e8f0 !important;
  background: transparent !important;
}
html.viya-dv .viya-profile-menu a:hover,
html.viya-dv .viya-profile-menu button:hover {
  background: #1f2937 !important;
  color: #a78bfa !important;
}

/* Sidebar */
html.viya-dv .sidebar,
html.viya-dv aside.sidebar,
html.viya-dv .viya-sidebar {
  background: #0d1425 !important;
  border-color: #1f2937 !important;
}
html.viya-dv .sidebar-nav a,
html.viya-dv .nav-item {
  color: #94a3b8 !important;
}
html.viya-dv .sidebar-nav a:hover,
html.viya-dv .nav-item:hover {
  background: #1f2937 !important;
  color: #e2e8f0 !important;
}
html.viya-dv .sidebar-nav a.active,
html.viya-dv .nav-item.active {
  background: rgba(124,58,237,0.2) !important;
  color: #a78bfa !important;
}

/* Modals */
html.viya-dv .modal-card,
html.viya-dv .modal > div {
  background: #111827 !important;
  border-color: #1f2937 !important;
  color: #e2e8f0 !important;
}

/* Dropdowns */
html.viya-dv [id^="dd-"],
html.viya-dv .dropdown,
html.viya-dv .vb-select-popover,
html.viya-dv [class*="dropdown"],
html.viya-dv #gasAddressDropdown {
  background: #111827 !important;
  border-color: #374151 !important;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5) !important;
}
html.viya-dv [id^="dd-"] button,
html.viya-dv .dropdown button {
  color: #e2e8f0 !important;
}
html.viya-dv [id^="dd-"] button:hover {
  background: #1f2937 !important;
}

/* Settings sections */
html.viya-dv .setting-row,
html.viya-dv .settings-section,
html.viya-dv .settings-tab-content {
  border-color: #1f2937 !important;
  color: #e2e8f0 !important;
}
html.viya-dv .setting-title { color: #f1f5f9 !important; }
html.viya-dv .setting-desc { color: #64748b !important; }

/* Category tabs */
html.viya-dv .cat {
  background: #1f2937 !important;
  border-color: #374151 !important;
  color: #94a3b8 !important;
}
html.viya-dv .cat:hover {
  border-color: #7c3aed !important;
  color: #a78bfa !important;
}
html.viya-dv .cat.active {
  background: linear-gradient(135deg,#7c3aed,#4f46e5) !important;
  color: #fff !important;
  border-color: transparent !important;
}

/* Product cards */
html.viya-dv .prod-card {
  background: #111827 !important;
  border-color: #1f2937 !important;
}
html.viya-dv .prod-card:hover {
  border-color: #7c3aed !important;
  background: #1a1f35 !important;
}
html.viya-dv .prod-name { color: #f1f5f9 !important; }
html.viya-dv .prod-cat { color: #4b5563 !important; }
html.viya-dv .prod-img {
  background: linear-gradient(135deg,#1f2937,#111827) !important;
}
html.viya-dv .prod-card .prod-price { color: #818cf8 !important; }
html.viya-dv .prod-grid-wrap { background: #0a0f1e !important; }
html.viya-dv .cat-scroll-wrap {
  background: #111827 !important;
  border-color: #1f2937 !important;
}

/* Cart panel */
html.viya-dv .cart-panel {
  background: #111827 !important;
  border-color: #1f2937 !important;
}
html.viya-dv .cart-item { border-color: #1f2937 !important; }
html.viya-dv .cart-item:hover { background: #1f2937 !important; }
html.viya-dv .cart-table-head {
  background: #1f2937 !important;
  color: #4b5563 !important;
  border-color: #374151 !important;
}
html.viya-dv .qty-ctrl button {
  background: #1f2937 !important;
  border-color: #374151 !important;
  color: #a78bfa !important;
}

/* Invoice/quotation detail */
html.viya-dv .invoice-wrap,
html.viya-dv .invoice-preview {
  background: #111827 !important;
  color: #e2e8f0 !important;
}

/* Tabs */
html.viya-dv .tab-btn,
html.viya-dv .tab-item,
html.viya-dv [class*="tab-"] {
  color: #64748b !important;
}
html.viya-dv .tab-btn.active,
html.viya-dv [class*="tab-"].active {
  color: #7c3aed !important;
  border-color: #7c3aed !important;
}

/* Status badges — keep colored */
html.viya-dv [style*="background:#dcfce7"],
html.viya-dv [style*="background:#dbeafe"],
html.viya-dv [style*="background:#fee2e2"],
html.viya-dv [style*="background:#fef3c7"] {
  opacity: 0.9;
}

/* Skeleton loader */
html.viya-dv .skel-row,
html.viya-dv [class*="skeleton"],
html.viya-dv [class*="skel-"] {
  background: #1f2937 !important;
}
html.viya-dv .shimmer::after {
  background: linear-gradient(90deg,
    transparent, rgba(255,255,255,0.05), transparent) !important;
}

/* Payment method buttons */
html.viya-dv .pay-method {
  background: #1f2937 !important;
  border-color: #374151 !important;
  color: #94a3b8 !important;
}
html.viya-dv .pay-method:hover {
  border-color: #7c3aed !important;
  color: #a78bfa !important;
}

/* Trip/project detail */
html.viya-dv .trip-info-card,
html.viya-dv .td-info-card,
html.viya-dv .trip-summary-card {
  background: #111827 !important;
  border-color: #1f2937 !important;
}

/* Approval center */
html.viya-dv .approval-card,
html.viya-dv .approval-section {
  background: #111827 !important;
  border-color: #374151 !important;
}

/* Reports */
html.viya-dv .summary-grid > div,
html.viya-dv .mira-card,
html.viya-dv .filter-panel {
  background: #111827 !important;
  border-color: #1f2937 !important;
  color: #e2e8f0 !important;
}

/* Keep white text on gradient backgrounds */
html.viya-dv [style*="background:linear-gradient"],
html.viya-dv [style*="background: linear-gradient"] {
  color: #fff !important;
}

/* Fix links */
html.viya-dv a:not(.btn):not([class*="btn"]) {
  color: #818cf8 !important;
}
html.viya-dv a:hover {
  color: #a78bfa !important;
}

/* Borders everywhere */
html.viya-dv [class*="border"],
html.viya-dv hr {
  border-color: #1f2937 !important;
}

/* Scrollbars */
html.viya-dv ::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
html.viya-dv ::-webkit-scrollbar-track {
  background: #111827;
}
html.viya-dv ::-webkit-scrollbar-thumb {
  background: #374151;
  border-radius: 3px;
}

/* ── Trip detail page ── */
html.viya-dv #invoiceRows tr,
html.viya-dv #expenseRows tr,
html.viya-dv #customerRows tr,
html.viya-dv #productRows tr {
  background: #111827 !important;
  color: #e2e8f0 !important;
}
html.viya-dv #invoiceRows tr:hover {
  background: #1f2937 !important;
}
html.viya-dv .trip-info-row td {
  color: #e2e8f0 !important;
  border-color: #1f2937 !important;
}
html.viya-dv .metric-card,
html.viya-dv .kpi-card {
  background: #111827 !important;
  border-color: #1f2937 !important;
}
html.viya-dv .metric-value { color: #818cf8 !important; }
html.viya-dv .metric-label { color: #64748b !important; }

/* ── Settings page ── */
html.viya-dv .settings-sidebar button,
html.viya-dv .settings-tab-btn {
  color: #94a3b8 !important;
}
html.viya-dv .settings-sidebar button.active,
html.viya-dv .settings-tab-btn.active {
  background: rgba(124,58,237,0.2) !important;
  color: #a78bfa !important;
}

/* ── Dashboard ── */
html.viya-dv .dashboard-card,
html.viya-dv .recent-list-item {
  background: #111827 !important;
  border-color: #1f2937 !important;
  color: #e2e8f0 !important;
}

@media print {
  html.viya-dv * { background: #fff !important; color: #000 !important; }
}
