/* Main Styles for Theme System */
:root {
  /* Light Theme Colors */
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-tertiary: #f1f5f9;
  --text-primary: #1e293b;  /* Dark blue-gray for light mode */
  --text-secondary: #475569;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --border-light: #f1f5f9;
  --shadow: rgba(0, 0, 0, 0.1);
  --accent: #16a34a;
  --accent-hover: #15803d;
  --accent-light: #dcfce7;
}

html.dark,
.dark {
  /* Dark Theme Colors */
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --text-primary: #f8fafc;  /* Light text for dark mode */
  --text-secondary: #e2e8f0;
  --text-muted: #94a3b8;
  --border-color: #334155;
  --border-light: #475569;
  --shadow: rgba(0, 0, 0, 0.3);
  --accent: #22c55e;
  --accent-hover: #16a34a;
  --accent-light: #15803d;
}

body {
    font-family: 'Tajawal', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Smooth transitions for theme changes */
*,
*::before,
*::after {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

/* Theme transition animation */
.theme-transitioning {
    pointer-events: none;
}

.theme-transitioning * {
    transition: background-color 0.6s ease, color 0.6s ease, border-color 0.6s ease, box-shadow 0.6s ease !important;
}

/* Global Theme Classes */
.bg-theme-primary { background-color: var(--bg-primary); }
.bg-theme-secondary { background-color: var(--bg-secondary); }
.bg-theme-tertiary { background-color: var(--bg-tertiary); }
.text-theme-primary { color: var(--text-primary) !important; }
.text-theme-secondary { color: var(--text-secondary) !important; }
.text-theme-muted { color: var(--text-muted) !important; }
.border-theme { border-color: var(--border-color); }
.border-theme-light { border-color: var(--border-light); }
.shadow-theme { box-shadow: 0 4px 6px var(--shadow); }

/* Text utilities that respect theme */
.text-primary-theme {
    color: var(--text-primary, #1e293b) !important;
}

.text-secondary-theme {
    color: var(--text-secondary, #475569) !important;
}

.text-muted-theme {
    color: var(--text-muted, #64748b) !important;
}

/* Additional text classes for better visibility */
.text-contrast {
    color: var(--text-primary) !important;
}

html.dark .text-contrast {
    color: #f8fafc !important;
}

/* Force visible text */
.text-visible {
    color: #1e293b !important;
}

html.dark .text-visible {
    color: #f8fafc !important;
}

/* Card styles */
.card-theme {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

/* Override Tailwind dark: classes for better theme integration */
.bg-white {
    background-color: var(--bg-primary) !important;
}

html.dark .bg-white {
    background-color: rgb(30 41 59 / 0.9) !important;
}

.dark\:bg-slate-800\/90 {
    background-color: var(--bg-primary) !important;
}

html.dark .dark\:bg-slate-800\/90 {
    background-color: rgb(30 41 59 / 0.9) !important;
}

/* Fix card backgrounds in both modes */
.bg-slate-100 {
    background-color: var(--bg-tertiary) !important;
}

html.dark .bg-slate-100 {
    background-color: rgb(51 65 85 / 0.5) !important;
}

.dark\:bg-slate-700\/50 {
    background-color: var(--bg-tertiary) !important;
}

html.dark .dark\:bg-slate-700\/50 {
    background-color: rgb(51 65 85 / 0.5) !important;
}

/* Fix borders in both modes */
.border-slate-100 {
    border-color: var(--border-light) !important;
}

html.dark .border-slate-100 {
    border-color: rgb(51 65 85 / 0.5) !important;
}

.dark\:border-slate-700\/50 {
    border-color: var(--border-light) !important;
}

html.dark .dark\:border-slate-700\/50 {
    border-color: rgb(51 65 85 / 0.5) !important;
}

/* Fix shadows in both modes */
.shadow-sm {
    box-shadow: 0 1px 2px 0 var(--shadow) !important;
}

.dark\:shadow-black\/20 {
    box-shadow: 0 1px 2px 0 var(--shadow) !important;
}

html.dark .dark\:shadow-black\/20 {
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.2) !important;
}

.hover\:shadow-lg:hover {
    box-shadow: 0 10px 15px -3px var(--shadow), 0 4px 6px -2px var(--shadow) !important;
}

.dark\:hover\:shadow-black\/30:hover {
    box-shadow: 0 10px 15px -3px var(--shadow), 0 4px 6px -2px var(--shadow) !important;
}

html.dark .dark\:hover\:shadow-black\/30:hover {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.3) !important;
}

/* Fix Tailwind text colors for better visibility */
.text-slate-800 {
    color: var(--text-primary) !important;
}

html.dark .text-slate-800 {
    color: #f8fafc !important;
}

.dark\:text-slate-100 {
    color: var(--text-primary) !important;
}

html.dark .dark\:text-slate-100 {
    color: #f1f5f9 !important;
}

/* Fix other common text colors */
.text-slate-600 {
    color: var(--text-secondary) !important;
}

html.dark .text-slate-600 {
    color: #e2e8f0 !important;
}

.text-slate-700 {
    color: var(--text-primary) !important;
}

html.dark .text-slate-700 {
    color: #f8fafc !important;
}

.text-gray-800 {
    color: var(--text-primary) !important;
}

html.dark .text-gray-800 {
    color: #f8fafc !important;
}

.text-gray-600 {
    color: var(--text-secondary) !important;
}

html.dark .text-gray-600 {
    color: #e2e8f0 !important;
}

/* Button styles */
.btn-accent {
    background-color: var(--accent);
    color: white;
}

.btn-accent:hover {
    background-color: var(--accent-hover);
}

/* Input styles */
.input-theme {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.input-theme:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
}

/* Search styles */
.search-overlay {
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.dark .search-overlay {
    background-color: rgba(0, 0, 0, 0.7);
}

/* Theme toggle button animation */
#theme-toggle {
    position: relative;
    overflow: hidden;
}

#theme-toggle::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: radial-gradient(circle, rgba(34, 197, 94, 0.2) 0%, transparent 70%);
    transform: translate(-50%, -50%);
    transition: width 0.3s ease, height 0.3s ease;
    border-radius: 50%;
    z-index: -1;
}

#theme-toggle:hover::before {
    width: 100px;
    height: 100px;
}

/* Custom scrollbar for dark theme */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Focus styles for better accessibility */
.focus\:ring-green:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.3);
}

/* Animation keyframes */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Apply animations to cards */
.animate-fadeIn {
    animation: fadeIn 0.5s ease-out;
}

.animate-slideUp {
    animation: slideUp 0.3s ease-out;
}
