:root {
    --theme-page-bg: #f3f4f6;
    --theme-surface: #ffffff;
    --theme-surface-muted: #f8fafc;
    --theme-border: rgba(148, 163, 184, 0.28);
    --theme-text: #0f172a;
    --theme-text-soft: #475569;
    --theme-text-muted: #64748b;
    --theme-shadow: 0 20px 45px rgba(15, 23, 42, 0.12);
    --theme-input-bg: #f8fafc;
    --theme-toggle-bg: rgba(255, 255, 255, 0.92);
    --theme-toggle-text: #0f172a;
    color-scheme: light;
}

html[data-theme="dark"] {
    --theme-page-bg: #020617;
    --theme-surface: #0f172a;
    --theme-surface-muted: #111827;
    --theme-border: rgba(148, 163, 184, 0.2);
    --theme-text: #e5eefb;
    --theme-text-soft: #cbd5e1;
    --theme-text-muted: #94a3b8;
    --theme-shadow: 0 24px 60px rgba(2, 6, 23, 0.55);
    --theme-input-bg: #0b1220;
    --theme-toggle-bg: rgba(15, 23, 42, 0.92);
    --theme-toggle-text: #f8fafc;
    color-scheme: dark;
}

body {
    transition: background-color 0.25s ease, color 0.25s ease;
}

html[data-theme="dark"] body {
    background:
        radial-gradient(circle at top left, rgba(229, 138, 89, 0.16), transparent 28%),
        radial-gradient(circle at bottom right, rgba(63, 72, 105, 0.26), transparent 34%),
        var(--theme-page-bg) !important;
    color: var(--theme-text);
}

html[data-theme="dark"] :is(.bg-white, .bg-white\/90, .bg-white\/95) {
    background-color: var(--theme-surface) !important;
    color: var(--theme-text) !important;
    border-color: var(--theme-border) !important;
    box-shadow: var(--theme-shadow) !important;
}

html[data-theme="dark"] :is(.bg-gray-50, .bg-gray-100, .bg-slate-50) {
    background-color: var(--theme-surface-muted) !important;
    color: var(--theme-text) !important;
    border-color: var(--theme-border) !important;
}

html[data-theme="dark"] header.bg-white,
html[data-theme="dark"] header.bg-white\/90,
html[data-theme="dark"] #cartDrawer {
    background-color: rgba(8, 15, 28, 0.96) !important;
    color: var(--theme-text) !important;
    box-shadow: var(--theme-shadow) !important;
}

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

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

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

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

html[data-theme="dark"] .text-primary {
    color: #d6dcff !important;
}

html[data-theme="dark"] .border-primary {
    border-color: #7c8ccc !important;
}

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

html[data-theme="dark"] :is(input, textarea, select) {
    background-color: var(--theme-input-bg) !important;
    color: var(--theme-text) !important;
    border-color: var(--theme-border) !important;
}

html[data-theme="dark"] :is(input, textarea, select)::placeholder {
    color: var(--theme-text-muted) !important;
}

html[data-theme="dark"] .bg-blue-50 {
    background-color: rgba(37, 99, 235, 0.14) !important;
    border-color: rgba(96, 165, 250, 0.28) !important;
}

html[data-theme="dark"] .bg-orange-50 {
    background-color: rgba(234, 88, 12, 0.14) !important;
    border-color: rgba(251, 146, 60, 0.28) !important;
}

html[data-theme="dark"] .bg-green-100 {
    background-color: rgba(16, 185, 129, 0.14) !important;
}

html[data-theme="dark"] .bg-blue-100 {
    background-color: rgba(59, 130, 246, 0.14) !important;
}

html[data-theme="dark"] .bg-purple-50 {
    background-color: rgba(168, 85, 247, 0.14) !important;
}

html[data-theme="dark"] .bg-red-50 {
    background-color: rgba(239, 68, 68, 0.14) !important;
}

html[data-theme="dark"] .text-blue-900 {
    color: #dbeafe !important;
}

html[data-theme="dark"] :is(.text-blue-700, .text-blue-600) {
    color: #93c5fd !important;
}

html[data-theme="dark"] .text-orange-900 {
    color: #ffedd5 !important;
}

html[data-theme="dark"] .text-orange-700 {
    color: #fdba74 !important;
}

html[data-theme="dark"] .text-green-700 {
    color: #86efac !important;
}

html[data-theme="dark"] .text-purple-500 {
    color: #d8b4fe !important;
}

.theme-toggle {
    position: fixed;
    left: 1rem;
    bottom: calc(1rem + env(safe-area-inset-bottom));
    z-index: 120;
    display: inline-flex;
    align-items: center;
    gap: 0.7rem;
    border: 1px solid rgba(148, 163, 184, 0.24);
    border-radius: 999px;
    background: var(--theme-toggle-bg);
    color: var(--theme-toggle-text);
    box-shadow: 0 18px 35px rgba(15, 23, 42, 0.18);
    backdrop-filter: blur(16px);
    padding: 0.85rem 1rem;
    font-family: 'Cairo', sans-serif;
    font-size: 0.95rem;
    font-weight: 800;
    line-height: 1;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.theme-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 22px 42px rgba(15, 23, 42, 0.22);
}

.theme-toggle:active {
    transform: translateY(0);
}

.theme-toggle__icon {
    width: 2rem;
    height: 2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: linear-gradient(135deg, #3F4869, #E58A59);
    color: #fff;
    font-size: 1.05rem;
}

.theme-toggle__label {
    white-space: nowrap;
}

@media (max-width: 640px) {
    .theme-toggle {
        left: 0.75rem;
        bottom: calc(0.75rem + env(safe-area-inset-bottom));
        padding: 0.8rem 0.9rem;
        gap: 0.55rem;
        font-size: 0.88rem;
    }

    .theme-toggle__icon {
        width: 1.8rem;
        height: 1.8rem;
    }
}