/* Dark mode styles */
:root {
    --bg-primary: #f3f4f6;
    --bg-secondary: #ffffff;
    --text-primary: #111827;
    --text-secondary: #4b5563;
    --border-color: hsl(220, 13%, 91%);
    --accent-color: #ff8c00; /* Fruit orange color */
    --accent-hover: #e67e00; /* Darker orange for hover */
    --accent-color-glassy: rgba(255, 140, 0, 0.1); /* Glassy effect for accent color */
    --accent-color-glassy-hover: rgba(218, 127, 17, 0.445); /* Glassy effect for hover */
    --card-bg: #ffffff;
    --input-bg: #ffffff;
    --shadow-color: rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] {
    --bg-primary: #111827;
    --bg-secondary: #1f2937;
    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
    --border-color: #4b5563; /* Lighter border for better contrast */
    --accent-color: #ff9f1c; /* Brighter orange for dark mode */
    --accent-hover: #ffb347; /* Lighter orange for hover in dark mode */
    --accent-color-glassy: rgba(255, 155, 28, 0.1); /* Glassy effect for accent color in dark mode */
    --accent-color-glassy-hover: rgba(255, 155, 28, 0.2); /* Glassy effect for hover in dark mode */
    --card-bg: #374151; /* Even lighter background for cards */
    --input-bg: #374151;
    --shadow-color: rgba(0, 0, 0, 0.5);
}

/* Preload class to prevent flash during initial load */
.preload * {
    transition: none !important;
}

/* Theme transition class to handle smooth transitions */
.theme-transition {
    transition: background-color 0.6s cubic-bezier(0.22, 1, 0.36, 1), 
                color 0.6s cubic-bezier(0.22, 1, 0.36, 1) !important;
    will-change: background-color, color;
}

.theme-transition * {
    transition: background-color 0.6s cubic-bezier(0.22, 1, 0.36, 1), 
                color 0.6s cubic-bezier(0.22, 1, 0.36, 1),
                border-color 0.6s cubic-bezier(0.22, 1, 0.36, 1),
                box-shadow 0.6s cubic-bezier(0.22, 1, 0.36, 1) !important;
    will-change: background-color, color, border-color, box-shadow;
}

/* Apply variables to elements */
html {
    transition: all 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    transition: background-color 0.6s cubic-bezier(0.22, 1, 0.36, 1), 
                color 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Background colors */
.bg-white, 
.bg-white *,
nav, 
header, 
footer {
    background-color: var(--bg-secondary) !important;
    transition: background-color 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.bg-gray-50, 
.bg-gray-100, 
.min-h-screen,
main {
    background-color: var(--bg-primary) !important;
    transition: background-color 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Text colors */
.text-gray-500, 
.text-gray-700,
a:not(.bg-blue-600),
button:not(.bg-blue-600),
p, 
span:not(.theme-toggle-icon) {
    color: var(--text-secondary) !important;
    transition: color 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.text-gray-900,
h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary) !important;
    transition: color 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Border colors */
.border,
.border-gray-100, 
.border-gray-200, 
.border-gray-300,
.border-b,
.border-t,
.border-l,
.border-r {
    border-color: var(--border-color) !important;
    transition: border-color 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Shadows */
.shadow,
.shadow-md, 
.shadow-sm, 
.shadow-lg {
    box-shadow: 0 4px 6px -1px var(--shadow-color), 0 2px 4px -1px var(--shadow-color) !important;
    transition: box-shadow 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Form elements */
input, 
textarea, 
select {
    background-color: var(--input-bg) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
    transition: background-color 0.6s cubic-bezier(0.22, 1, 0.36, 1), 
                color 0.6s cubic-bezier(0.22, 1, 0.36, 1), 
                border-color 0.6s cubic-bezier(0.22, 1, 0.36, 1), 
                box-shadow 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Focus states */
.focus\:ring-blue-500:focus,
.focus\:border-blue-500:focus,
input:focus, 
textarea:focus, 
select:focus,
button:focus {
    --tw-ring-color: var(--accent-color) !important;
    --tw-ring-opacity: 1 !important;
    --tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color) !important;
    --tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color) !important;
    box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000) !important;
    border-color: var(--accent-color) !important;
    outline: none !important;
}

/* Button styles */
.bg-blue-600,
.hover\:bg-blue-700:hover,
.bg-blue-500 {
    background-color: var(--accent-color) !important;
    transition: background-color 0.3s ease;
}

.hover\:bg-blue-700:hover,
.hover\:bg-blue-900:hover {
    background-color: var(--accent-hover) !important;
}

.text-blue-600,
.hover\:text-blue-700:hover {
    color: var(--accent-color) !important;
    transition: color 0.3s ease;
}

.hover\:text-blue-700:hover,
.hover\:text-blue-800:hover {
    color: var(--accent-hover) !important;
}

.border-blue-400,
.border-blue-500,
.border-blue-600 {
    border-color: var(--accent-color) !important;
    transition: border-color 0.3s ease;
}

/* Cards and sections */
.bg-blue-50, 
.bg-green-50, 
.bg-purple-50, 
.bg-yellow-50,
.rounded-lg,
.p-4,
.p-6 {
    background-color: var(--card-bg) !important;
    border: 1px solid var(--border-color);
    transition: background-color 0.6s cubic-bezier(0.22, 1, 0.36, 1), 
                border-color 0.6s cubic-bezier(0.22, 1, 0.36, 1),
                box-shadow 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Enhanced card styling for dark mode */
[data-theme="dark"] .rounded-lg,
[data-theme="dark"] .p-4,
[data-theme="dark"] .p-6,
[data-theme="dark"] .card,
[data-theme="dark"] .bg-white,
[data-theme="dark"] .bg-blue-50, 
[data-theme="dark"] .bg-green-50, 
[data-theme="dark"] .bg-purple-50, 
[data-theme="dark"] .bg-yellow-50 {
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.3), 0 3px 5px rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
}

/* Theme toggle button styles */
.theme-toggle-btn {
    position: relative;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    border: none;
    cursor: pointer;
    transition: transform 0.2s ease, color 0.3s ease;
    z-index: 50;
}

.theme-toggle-btn:hover {
    color: var(--accent-color);
}

.theme-toggle-btn:active {
    transform: scale(0.95);
}

.theme-icon {
    width: 24px;
    height: 24px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: opacity 0.3s ease, stroke 0.3s ease;
}

/* Light mode shows sun icon */
.light-icon {
    display: block;
}

.dark-icon {
    display: none;
}

/* Dark mode shows moon icon */
[data-theme="dark"] .light-icon {
    display: none;
}

[data-theme="dark"] .dark-icon {
    display: block !important;
}

/* Add a subtle effect on hover */
.theme-toggle-btn:hover {
    animation: pulse 1s infinite alternate;
}

@keyframes pulse {
    0% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1.15);
    }
}
