/*
 * Croplod Theme System
 * OS-level dark mode detection + smooth transitions
 */

/* OS-level dark mode when user hasn't chosen light */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg-primary: #000000;
        --bg-secondary: #000000;
        --bg-tertiary: #121212;
        --bg-card: #151515;
        --bg-elevated: #1c1c1c;
        --bg-input: #121212;
        --bg-hover: rgba(255, 255, 255, 0.06);
        --bg-pressed: rgba(255, 255, 255, 0.1);
        --bg-active: rgba(255, 255, 255, 0.06);
        --bg-sidebar: #000000;

        --text-primary: #f1f5f9;
        --text-secondary: #94a3b8;
        --text-tertiary: #64748b;
        --text-disabled: #3f3f46;
        --text-inverse: #0f172a;

        --border-primary: #26262b;
        --border-secondary: #3f3f46;
        --border-focus: var(--color-primary-400);
        --border-subtle: rgba(255, 255, 255, 0.05);

        --overlay: rgba(0, 0, 0, 0.65);

        --sidebar-bg-active: rgba(59, 113, 247, 0.14);
        --sidebar-text-active: #93bbfd;
        --sidebar-icon-active: #93bbfd;

        --btn-primary-shadow: rgba(37, 99, 235, 0.28);
        --btn-primary-shadow-hover: rgba(37, 99, 235, 0.38);
        --btn-danger-shadow: rgba(220, 38, 38, 0.28);
        --btn-danger-shadow-hover: rgba(220, 38, 38, 0.38);

        --focus-ring: rgba(96, 150, 250, 0.28);

        --card-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.5), 0 1px 3px 0 rgb(0 0 0 / 0.4);
        --card-shadow-hover: 0 2px 4px -1px rgb(0 0 0 / 0.5), 0 6px 14px -2px rgb(0 0 0 / 0.55);
        --card-shadow-elevated: 0 8px 24px rgb(0 0 0 / 0.6);

        --surface-1: #0a0a0a;
        --surface-2: #121212;
        --surface-3: #1c1c1c;

        --search-shadow-focus: 0 1px 6px rgba(0, 0, 0, 0.6);

        --icon-bg-blue: rgba(96, 150, 250, 0.14);
        --icon-bg-green: rgba(34, 197, 94, 0.14);
        --icon-bg-orange: rgba(245, 158, 11, 0.14);
        --icon-bg-purple: rgba(148, 163, 184, 0.14);
        --icon-bg-primary: rgba(96, 150, 250, 0.14);
        --icon-bg-success: rgba(34, 197, 94, 0.14);
        --icon-bg-error: rgba(239, 68, 68, 0.14);
        --icon-bg-warning: rgba(245, 158, 11, 0.14);

        --avatar-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);

        --scrollbar-track: transparent;
        --scrollbar-thumb: #3f3f46;
    }
}

/* Smooth theme transitions - exclude transform-heavy elements */
body {
    transition: background-color var(--transition-normal),
                color var(--transition-normal);
}

/* Don't animate sidebar/modal transforms during theme switch */
.account-sidebar,
.profile-modal,
.croplod-confirm-modal,
.profile-modal-overlay,
.croplod-confirm-overlay {
    transition: none;
}

/* Re-enable transitions after initial load */
body.loaded .account-sidebar,
body.loaded .profile-modal,
body.loaded .croplod-confirm-modal {
    transition: transform 280ms cubic-bezier(0.2, 0, 0, 1),
                opacity 0.2s ease;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    body,
    body *,
    body *::before,
    body *::after {
        transition-duration: 0ms !important;
        animation-duration: 0ms !important;
    }
}