/* ============================================================
   Theme System — CSS Custom Properties for Light / Dark modes
   ============================================================ */

:root {
  /* Light mode (default) */
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-tertiary: #f1f5f9;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --bg-sidebar: #ffffff;
  --bg-input: #f1f5f9;
  --border-primary: #e2e8f0;
  --border-secondary: #f1f5f9;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-tertiary: #94a3b8;
  --text-heading: #1e293b;
  --shadow-card: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-sidebar: 1px 0 0 var(--border-primary);
  --accent: #6366f1;
}

html.dark {
  --bg-primary: #0c0a1d;
  --bg-secondary: #111127;
  --bg-tertiary: #1a1a3e;
  --bg-card: rgba(255,255,255,0.04);
  --bg-card-hover: rgba(255,255,255,0.06);
  --bg-sidebar: #0d0d25;
  --bg-input: rgba(255,255,255,0.05);
  --border-primary: rgba(255,255,255,0.08);
  --border-secondary: rgba(255,255,255,0.05);
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-tertiary: #64748b;
  --text-heading: #ffffff;
  --shadow-card: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-sidebar: 1px 0 0 rgba(255,255,255,0.06);
  --accent: #818cf8;
}


/* ============================================================
   Component Styles
   ============================================================ */

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  border-radius: 12px;
  box-shadow: var(--shadow-card);
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-primary);
}

.card-solid {
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  border-radius: 12px;
  box-shadow: var(--shadow-card);
}

/* Form inputs */
input, select, textarea {
  background: var(--bg-input);
  border-color: var(--border-primary);
  color: var(--text-primary);
}
input::placeholder, textarea::placeholder {
  color: var(--text-tertiary);
}
/* Fix native select dropdown options (white text on white bg) */
select option {
  background: var(--bg-primary);
  color: var(--text-primary);
}
html.dark select option {
  background: #1a1a3e;
  color: #f1f5f9;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 8px;
  transition: all 0.15s;
  cursor: pointer;
  white-space: nowrap;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
}
.btn-primary:hover { opacity: 0.9; }
.btn-secondary {
  background: var(--bg-input);
  color: var(--text-secondary);
  border: 1px solid var(--border-primary);
}
.btn-secondary:hover {
  background: var(--bg-tertiary);
  color: var(--text-heading);
}
.btn-danger {
  background: rgba(239,68,68,0.1);
  color: #ef4444;
  border: 1px solid rgba(239,68,68,0.2);
}
.btn-danger:hover {
  background: rgba(239,68,68,0.2);
}

/* Badge pills */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 9999px;
  line-height: 16px;
}

/* Empty state container */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 2rem;
  text-align: center;
}
.empty-state svg {
  width: 48px;
  height: 48px;
  color: var(--text-tertiary);
  margin-bottom: 12px;
  opacity: 0.6;
}
.empty-state h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-heading);
  margin-bottom: 4px;
}
.empty-state p {
  font-size: 13px;
  color: var(--text-tertiary);
  max-width: 320px;
}
.empty-state .empty-action {
  margin-top: 16px;
  font-size: 12px;
  color: var(--accent);
  font-weight: 500;
}

/* Table striping */
.table-striped tbody tr:nth-child(even) {
  background: var(--bg-secondary);
}
html.dark .table-striped tbody tr:nth-child(even) {
  background: rgba(255,255,255,0.02);
}

/* Chart fade-in animation */
@keyframes chart-in {
  0% { opacity: 0; transform: translateY(12px); }
  100% { opacity: 1; transform: translateY(0); }
}
.chart-animated {
  animation: chart-in 0.4s ease-out;
}

/* Stat card number animation */
@keyframes count-in {
  0% { opacity: 0; transform: scale(0.8); }
  100% { opacity: 1; transform: scale(1); }
}
.stat-animated {
  animation: count-in 0.3s ease-out;
}

/* Divider */
.divider {
  height: 1px;
  background: var(--border-primary);
  margin: 16px 0;
}

/* Search dropdown */
.search-results {
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
html.dark .search-results {
  background: rgba(15,15,35,0.95);
  backdrop-filter: blur(20px);
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}


/* ============================================================
   Light-mode compatibility layer
   Remaps existing dark-theme Tailwind classes so all 20
   dashboard templates work in light mode without modification.
   ============================================================ */

/* Text colors */
:root:not(.dark) .text-white {
  color: var(--text-heading);
}
:root:not(.dark) .text-gray-200 {
  color: var(--text-primary);
}
:root:not(.dark) .text-gray-300 {
  color: var(--text-primary);
}
:root:not(.dark) .text-gray-400 {
  color: var(--text-secondary);
}
:root:not(.dark) .text-gray-500 {
  color: var(--text-tertiary);
}
:root:not(.dark) .text-gray-600 {
  color: var(--text-tertiary);
}

/* Background colors */
:root:not(.dark) .bg-white\/5 {
  background: var(--bg-input);
}
:root:not(.dark) .bg-white\/\[0\.03\] {
  background: var(--bg-tertiary);
}
:root:not(.dark) .bg-white\/\[0\.07\] {
  background: var(--bg-tertiary);
}
:root:not(.dark) .bg-white\/3 {
  background: var(--bg-tertiary);
}
:root:not(.dark) .bg-white\/8 {
  background: var(--bg-tertiary);
}
:root:not(.dark) .bg-white\/10 {
  background: var(--bg-tertiary);
}

/* Border colors */
:root:not(.dark) .border-white\/5 {
  border-color: var(--border-secondary);
}
:root:not(.dark) .border-white\/10 {
  border-color: var(--border-primary);
}
:root:not(.dark) .border-white\/\[0\.06\] {
  border-color: var(--border-primary);
}
:root:not(.dark) .border-white\/\[0\.08\] {
  border-color: var(--border-primary);
}

/* App background */
:root:not(.dark) .app-bg {
  background: var(--bg-secondary);
}

/* Glass morphism -> clean solid in light mode */
:root:not(.dark) .glass {
  background: var(--bg-card);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border-color: var(--border-primary);
}
:root:not(.dark) .glass-strong {
  background: var(--bg-card);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border-color: var(--border-primary);
  box-shadow: var(--shadow-card);
}

/* Dot grid subtle in light */
:root:not(.dark) .dot-grid {
  background-image: radial-gradient(circle, rgba(0,0,0,0.04) 1px, transparent 1px);
  background-size: 32px 32px;
}

/* Table row hovers */
:root:not(.dark) .hover\:bg-white\/5:hover {
  background: var(--bg-tertiary);
}

/* Glow effects — remove in light */
:root:not(.dark) .glow-purple,
:root:not(.dark) .glow-blue {
  box-shadow: none;
}

/* Shadow overrides */
:root:not(.dark) .shadow-purple-500\/20,
:root:not(.dark) .shadow-purple-500\/25,
:root:not(.dark) .shadow-black\/40,
:root:not(.dark) .shadow-black\/20 {
  --tw-shadow-color: rgba(0,0,0,0.08);
}

/* Progress bars */
:root:not(.dark) .bg-white\/10 {
  background: #e2e8f0;
}

/* Additional background opacity variants */
:root:not(.dark) .bg-white\/\[0\.02\] {
  background: var(--bg-secondary);
}
:root:not(.dark) .bg-white\/\[0\.04\] {
  background: var(--bg-tertiary);
}
:root:not(.dark) .bg-white\/\[0\.06\] {
  background: var(--bg-tertiary);
}
:root:not(.dark) .bg-white\/\[0\.08\] {
  background: var(--bg-input);
}

/* Additional hover background variants */
:root:not(.dark) .hover\:bg-white\/\[0\.02\]:hover {
  background: var(--bg-tertiary);
}
:root:not(.dark) .hover\:bg-white\/\[0\.04\]:hover {
  background: var(--bg-tertiary);
}
:root:not(.dark) .hover\:bg-white\/\[0\.06\]:hover {
  background: var(--bg-tertiary);
}
:root:not(.dark) .hover\:bg-white\/\[0\.08\]:hover {
  background: var(--bg-input);
}
:root:not(.dark) .hover\:bg-white\/3:hover {
  background: var(--bg-tertiary);
}

/* Additional border variants */
:root:not(.dark) .border-white\/\[0\.03\] {
  border-color: var(--border-secondary);
}
:root:not(.dark) .border-white\/20 {
  border-color: var(--border-primary);
}
