/* Dark Mode Theme System */

:root {
  /* Light Theme Colors */
  --bg-primary: #ffffff;
  --bg-secondary: #f9fafb;
  --bg-tertiary: #f3f4f6;
  --bg-hover: #e5e7eb;

  --text-primary: #111827;
  --text-secondary: #6b7280;
  --text-tertiary: #9ca3af;

  --border-color: #e5e7eb;
  --border-light: #f3f4f6;

  --accent-primary: #3b82f6;
  --accent-hover: #2563eb;
  --accent-light: #dbeafe;

  --success: #10b981;
  --success-light: #d1fae5;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --error: #ef4444;
  --error-light: #fee2e2;
  --info: #3b82f6;
  --info-light: #dbeafe;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"],
.dark {
  /* Dark Theme Colors */
  --bg-primary: #1f2937;
  --bg-secondary: #111827;
  --bg-tertiary: #374151;
  --bg-hover: #4b5563;

  --text-primary: #f9fafb;
  --text-secondary: #d1d5db;
  --text-tertiary: #9ca3af;

  --border-color: #374151;
  --border-light: #4b5563;

  --accent-primary: #60a5fa;
  --accent-hover: #3b82f6;
  --accent-light: #1e3a8a;

  --success: #34d399;
  --success-light: #064e3b;
  --warning: #fbbf24;
  --warning-light: #78350f;
  --error: #f87171;
  --error-light: #7f1d1d;
  --info: #60a5fa;
  --info-light: #1e3a8a;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
}

/* Apply theme to body */
body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Common element remapping (dark mode only) */
[data-theme="dark"] .bg-white,
[data-theme="dark"] .bg-gray-50,
.dark .bg-white,
.dark .bg-gray-50 {
  background-color: var(--bg-primary) !important;
}

[data-theme="dark"] .bg-gray-100,
.dark .bg-gray-100 {
  background-color: var(--bg-secondary) !important;
}

[data-theme="dark"] .bg-gray-200,
.dark .bg-gray-200 {
  background-color: var(--bg-tertiary) !important;
}

[data-theme="dark"] .text-gray-900,
[data-theme="dark"] .text-gray-800,
.dark .text-gray-900,
.dark .text-gray-800 {
  color: var(--text-primary) !important;
}

[data-theme="dark"] .text-gray-700,
[data-theme="dark"] .text-gray-600,
.dark .text-gray-700,
.dark .text-gray-600 {
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .text-gray-500,
[data-theme="dark"] .text-gray-400,
[data-theme="dark"] .text-gray-300,
.dark .text-gray-500,
.dark .text-gray-400,
.dark .text-gray-300 {
  color: var(--text-tertiary) !important;
}

[data-theme="dark"] .bg-slate-50,
.dark .bg-slate-50 {
  background-color: var(--bg-secondary) !important;
}

[data-theme="dark"] .bg-slate-100,
.dark .bg-slate-100 {
  background-color: var(--bg-tertiary) !important;
}

[data-theme="dark"] .bg-slate-200,
.dark .bg-slate-200 {
  background-color: var(--bg-hover) !important;
}

[data-theme="dark"] .text-slate-900,
[data-theme="dark"] .text-slate-800,
.dark .text-slate-900,
.dark .text-slate-800 {
  color: var(--text-primary) !important;
}

[data-theme="dark"] .text-slate-700,
[data-theme="dark"] .text-slate-600,
.dark .text-slate-700,
.dark .text-slate-600 {
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .text-slate-500,
[data-theme="dark"] .text-slate-400,
.dark .text-slate-500,
.dark .text-slate-400 {
  color: var(--text-tertiary) !important;
}

[data-theme="dark"] .border-gray-200,
[data-theme="dark"] .border-gray-300,
.dark .border-gray-200,
.dark .border-gray-300 {
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .border-slate-200,
[data-theme="dark"] .border-slate-300,
.dark .border-slate-200,
.dark .border-slate-300 {
  border-color: var(--border-color) !important;
}

/* Cards and containers */
.card,
.rounded-lg.shadow {
  background-color: var(--bg-primary);
  border-color: var(--border-color);
}

.register-card {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

/* Buttons */
.btn-primary {
  background-color: var(--accent-primary);
}

.btn-primary:hover {
  background-color: var(--accent-hover);
}

/* Forms */
input,
textarea,
select {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  border-color: var(--border-color);
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent-primary);
  background-color: var(--bg-primary);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-tertiary);
}

/* Tables */
table {
  background-color: var(--bg-primary);
}

thead {
  background-color: var(--bg-secondary);
}

tbody tr {
  border-color: var(--border-color);
}

tbody tr:hover {
  background-color: var(--bg-hover);
}

/* Alerts */
[data-theme="dark"] .alert-success,
.dark .alert-success {
  background-color: var(--success-light);
  color: var(--success);
  border-color: var(--success);
}

[data-theme="dark"] .alert-warning,
.dark .alert-warning {
  background-color: var(--warning-light);
  color: var(--warning);
  border-color: var(--warning);
}

[data-theme="dark"] .alert-error,
[data-theme="dark"] .alert-danger,
.dark .alert-error,
.dark .alert-danger {
  background-color: var(--error-light);
  color: var(--error);
  border-color: var(--error);
}

[data-theme="dark"] .alert-info,
.dark .alert-info {
  background-color: var(--info-light);
  color: var(--info);
  border-color: var(--info);
}

/* Navigation */
.sidebar {
  background-color: var(--bg-secondary);
  border-color: var(--border-color);
}

.sidebar a:hover {
  background-color: var(--bg-hover);
}

/* Theme Toggle Button */
.theme-toggle-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0.5rem;
  color: var(--text-secondary);
  background-color: transparent;
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-right: 0.5rem;
}

.theme-toggle-btn:hover {
  color: var(--text-primary);
  background-color: var(--bg-hover);
}

.theme-toggle-btn:focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--accent-primary);
}

.theme-toggle-btn i {
  font-size: 1.125rem;
  transition: transform 0.3s ease;
}

.theme-toggle-btn:hover i {
  transform: rotate(20deg);
}

/* Ensure proper colors in both modes */
[data-theme="light"] .theme-toggle-btn {
  color: #6b7280;
}

[data-theme="light"] .theme-toggle-btn:hover {
  color: #111827;
  background-color: #f3f4f6;
}

[data-theme="dark"] .theme-toggle-btn {
  color: #9ca3af;
}

[data-theme="dark"] .theme-toggle-btn:hover {
  color: #f9fafb;
  background-color: #374151;
}

/* Smooth transitions for theme changes */
* {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* Code blocks */
pre,
code {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--border-color);
}

[data-theme="dark"] .bg-blue-50 { background-color: rgba(59, 130, 246, 0.12) !important; }
[data-theme="dark"] .bg-blue-100 { background-color: rgba(59, 130, 246, 0.18) !important; }
[data-theme="dark"] .bg-blue-200 { background-color: rgba(59, 130, 246, 0.28) !important; }
[data-theme="dark"] .border-blue-200 { border-color: rgba(59, 130, 246, 0.35) !important; }
[data-theme="dark"] .border-blue-300 { border-color: rgba(59, 130, 246, 0.45) !important; }
[data-theme="dark"] .text-blue-500,
[data-theme="dark"] .text-blue-600,
[data-theme="dark"] .text-blue-700,
[data-theme="dark"] .text-blue-800,
[data-theme="dark"] .text-blue-900 { color: #93c5fd !important; }

[data-theme="dark"] .bg-green-50 { background-color: rgba(16, 185, 129, 0.12) !important; }
[data-theme="dark"] .bg-green-100 { background-color: rgba(16, 185, 129, 0.18) !important; }
[data-theme="dark"] .bg-green-200 { background-color: rgba(16, 185, 129, 0.28) !important; }
[data-theme="dark"] .border-green-200 { border-color: rgba(16, 185, 129, 0.35) !important; }
[data-theme="dark"] .border-green-300 { border-color: rgba(16, 185, 129, 0.45) !important; }
[data-theme="dark"] .text-green-500,
[data-theme="dark"] .text-green-600,
[data-theme="dark"] .text-green-700,
[data-theme="dark"] .text-green-800,
[data-theme="dark"] .text-green-900 { color: #86efac !important; }

[data-theme="dark"] .bg-yellow-50 { background-color: rgba(245, 158, 11, 0.14) !important; }
[data-theme="dark"] .bg-yellow-100 { background-color: rgba(245, 158, 11, 0.2) !important; }
[data-theme="dark"] .bg-yellow-200 { background-color: rgba(245, 158, 11, 0.3) !important; }
[data-theme="dark"] .border-yellow-200 { border-color: rgba(245, 158, 11, 0.38) !important; }
[data-theme="dark"] .border-yellow-300 { border-color: rgba(245, 158, 11, 0.5) !important; }
[data-theme="dark"] .text-yellow-500,
[data-theme="dark"] .text-yellow-600,
[data-theme="dark"] .text-yellow-700,
[data-theme="dark"] .text-yellow-800,
[data-theme="dark"] .text-yellow-900 { color: #fde047 !important; }

[data-theme="dark"] .bg-red-50 { background-color: rgba(239, 68, 68, 0.12) !important; }
[data-theme="dark"] .bg-red-100 { background-color: rgba(239, 68, 68, 0.18) !important; }
[data-theme="dark"] .bg-red-200 { background-color: rgba(239, 68, 68, 0.28) !important; }
[data-theme="dark"] .border-red-200 { border-color: rgba(239, 68, 68, 0.35) !important; }
[data-theme="dark"] .border-red-300 { border-color: rgba(239, 68, 68, 0.45) !important; }
[data-theme="dark"] .text-red-500,
[data-theme="dark"] .text-red-600,
[data-theme="dark"] .text-red-700,
[data-theme="dark"] .text-red-800,
[data-theme="dark"] .text-red-900 { color: #fca5a5 !important; }

[data-theme="dark"] .bg-orange-50 { background-color: rgba(249, 115, 22, 0.14) !important; }
[data-theme="dark"] .bg-orange-100 { background-color: rgba(249, 115, 22, 0.2) !important; }
[data-theme="dark"] .bg-orange-200 { background-color: rgba(249, 115, 22, 0.3) !important; }
[data-theme="dark"] .border-orange-200 { border-color: rgba(249, 115, 22, 0.38) !important; }
[data-theme="dark"] .border-orange-300 { border-color: rgba(249, 115, 22, 0.5) !important; }
[data-theme="dark"] .text-orange-500,
[data-theme="dark"] .text-orange-600,
[data-theme="dark"] .text-orange-700,
[data-theme="dark"] .text-orange-800,
[data-theme="dark"] .text-orange-900 { color: #fdba74 !important; }

[data-theme="dark"] .bg-purple-50 { background-color: rgba(168, 85, 247, 0.12) !important; }
[data-theme="dark"] .bg-purple-100 { background-color: rgba(168, 85, 247, 0.18) !important; }
[data-theme="dark"] .bg-purple-200 { background-color: rgba(168, 85, 247, 0.28) !important; }
[data-theme="dark"] .border-purple-200 { border-color: rgba(168, 85, 247, 0.35) !important; }
[data-theme="dark"] .border-purple-300 { border-color: rgba(168, 85, 247, 0.45) !important; }
[data-theme="dark"] .text-purple-500,
[data-theme="dark"] .text-purple-600,
[data-theme="dark"] .text-purple-700,
[data-theme="dark"] .text-purple-800,
[data-theme="dark"] .text-purple-900 { color: #c4b5fd !important; }

[data-theme="dark"] .bg-indigo-50 { background-color: rgba(99, 102, 241, 0.12) !important; }
[data-theme="dark"] .bg-indigo-100 { background-color: rgba(99, 102, 241, 0.18) !important; }
[data-theme="dark"] .bg-indigo-200 { background-color: rgba(99, 102, 241, 0.28) !important; }
[data-theme="dark"] .border-indigo-200 { border-color: rgba(99, 102, 241, 0.35) !important; }
[data-theme="dark"] .border-indigo-300 { border-color: rgba(99, 102, 241, 0.45) !important; }
[data-theme="dark"] .text-indigo-500,
[data-theme="dark"] .text-indigo-600,
[data-theme="dark"] .text-indigo-700,
[data-theme="dark"] .text-indigo-800,
[data-theme="dark"] .text-indigo-900 { color: #a5b4fc !important; }

[data-theme="dark"] .shadow,
[data-theme="dark"] .shadow-sm,
[data-theme="dark"] .shadow-md,
[data-theme="dark"] .shadow-lg,
[data-theme="dark"] .shadow-xl,
[data-theme="dark"] .shadow-2xl { box-shadow: var(--shadow-md) !important; }

/* Modals */
.modal-content {
  background-color: var(--bg-primary);
  color: var(--text-primary);
}

/* Dropdowns */
.dropdown-menu {
  background-color: var(--bg-primary);
  border-color: var(--border-color);
}

.dropdown-item:hover {
  background-color: var(--bg-hover);
}

/* Progress bars */
.progress {
  background-color: var(--bg-tertiary);
}

.progress-bar {
  background-color: var(--accent-primary);
}

/* Badges */
.badge {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
}

/* Links */
a {
  color: var(--accent-primary);
}

a:hover {
  color: var(--accent-hover);
}

/* Scrollbar (Webkit browsers) */
::-webkit-scrollbar {
  width: 12px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: 6px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--bg-hover);
}

/* Firefox scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--bg-tertiary) var(--bg-secondary);
}
