/* ==========================================================================
   MIHWAR Auto Parts & Upgrades — Master Style Tokens
   - Translucent Luxurious Obsidian Dark Theme (Lightened, Softened & Frosted Glass)
   - Cross-Browser & Windows Chrome Select / Option Dark Mode Fix
   - Locked Micro-Tokens for Header Cart, SVG Badges & Typography
   ========================================================================== */

:root {
    /* Base Font Family */
    --font-sans: 'Alexandria', 'Cairo', -apple-system, sans-serif;
    --font-mono: 'Plus Jakarta Sans', monospace;
    
    /* Light Mode Tokens (Titanium Clean) */
    --bg-page-light: #f8fafc;
    --bg-surface-light: #ffffff;
    --bg-card-light: #ffffff;
    --bg-card-hover-light: #f1f5f9;
    --border-light: #e2e8f0;
    --text-primary-light: #0f172a;
    --text-secondary-light: #475569;
    --text-muted-light: #94a3b8;
    --hyper-red: #ef4444;
    --hyper-red-hover: #dc2626;
    --hyper-red-glow: rgba(239, 68, 68, 0.25);
    
    /* Softened & Translucent Dark Mode Tokens (Obsidian Titanium Luxury) */
    --bg-page-dark: #121622;                  /* Softened obsidian lifted from pitch black */
    --bg-surface-dark: rgba(22, 29, 44, 0.82);
    --bg-card-dark: #182030;                  /* Premium automotive charcoal slate */
    --bg-card-hover-dark: #202b3f;
    --border-dark: rgba(255, 255, 255, 0.08);
    --text-primary-dark: #f8fafc;
    --text-secondary-dark: #cbd5e1;
    --text-muted-dark: #8191a6;
}

/* Base Body Styles */
body {
    font-family: var(--font-sans);
    line-height: 1.7;
    letter-spacing: 0;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Light Theme Styling */
html:not(.dark) body {
    background-color: var(--bg-page-light);
    color: var(--text-primary-light);
    background-image: 
        radial-gradient(circle at 10% 10%, rgba(239, 68, 68, 0.03) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(14, 165, 233, 0.03) 0%, transparent 40%);
    background-attachment: fixed;
}

html:not(.dark) .carbon-glass {
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-light);
    box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.05);
}

html:not(.dark) .surface-card {
    background-color: var(--bg-card-light);
    border: 1px solid var(--border-light);
    color: var(--text-primary-light);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
    transition: all 0.25s ease;
}

html:not(.dark) .surface-card:hover {
    border-color: rgba(239, 68, 68, 0.4);
    box-shadow: 0 10px 25px -4px rgba(0, 0, 0, 0.08);
}

/* Lightened & Translucent Luxury Dark Theme Styling */
html.dark body {
    background-color: var(--bg-page-dark);
    color: var(--text-primary-dark);
    background-image: 
        radial-gradient(circle at 12% 10%, rgba(239, 68, 68, 0.07) 0%, transparent 45%),
        radial-gradient(circle at 88% 85%, rgba(14, 165, 233, 0.06) 0%, transparent 45%),
        linear-gradient(180deg, #121622 0%, #0d111a 100%);
    background-attachment: fixed;
}

html.dark .carbon-glass {
    background: var(--bg-surface-dark);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-dark);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.28);
}

html.dark .surface-card {
    background-color: rgba(24, 32, 48, 0.72);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--border-dark);
    color: var(--text-primary-dark);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.25s ease, box-shadow 0.25s ease;
}

html.dark .surface-card:hover {
    background-color: rgba(32, 43, 63, 0.85);
    border-color: rgba(239, 68, 68, 0.45);
    box-shadow: 0 14px 34px -6px rgba(0, 0, 0, 0.35), 0 0 18px rgba(239, 68, 68, 0.12);
    transform: translateY(-3px);
}

/* ==========================================================================
   Cross-Browser Windows Chrome & Firefox Select / Option Fix
   ========================================================================== */
select {
    color-scheme: light dark;
    cursor: pointer;
}

html.dark select {
    background-color: #182030 !important;
    color: #f8fafc !important;
    border-color: rgba(255, 255, 255, 0.12) !important;
}

html.dark select option {
    background-color: #182030 !important;
    color: #f8fafc !important;
    padding: 10px 14px !important;
}

html:not(.dark) select {
    background-color: #ffffff !important;
    color: #0f172a !important;
    border-color: #cbd5e1 !important;
}

html:not(.dark) select option {
    background-color: #ffffff !important;
    color: #0f172a !important;
    padding: 10px 14px !important;
}

/* ==========================================================================
   Header Cart Button & SVG Dimensional Locks (Strict Overlap Prevention)
   ========================================================================== */
header button svg,
.cart-drawer svg {
    max-width: 24px;
    max-height: 24px;
}



/* Button & Interactive Micro-Tokens */
.btn-hyper-red {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(239, 68, 68, 0.35);
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-hyper-red:hover {
    background: linear-gradient(135deg, #f87171 0%, #ef4444 100%);
    box-shadow: 0 6px 22px rgba(239, 68, 68, 0.55);
    transform: translateY(-1px);
}

.btn-whatsapp {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.3);
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-whatsapp:hover {
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.5);
    transform: translateY(-1px);
}

/* Interactive Image Gallery Thumbnails */
.gallery-thumb-btn {
    border: 2px solid transparent;
    transition: all 0.2s ease;
    cursor: pointer;
}

.gallery-thumb-btn:hover {
    border-color: rgba(239, 68, 68, 0.6);
    transform: scale(1.05);
}

.gallery-thumb-btn.active {
    border-color: #ef4444;
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.4);
}

/* Toast Notifications */
#mihvar-toast {
    position: fixed;
    bottom: 24px;
    left: 24px;
    z-index: 100;
    transform: translateY(120%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
    opacity: 0;
}

#mihvar-toast.show {
    transform: translateY(0);
    opacity: 1;
}

/* Scrollbar Cleanliness */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.25);
    border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(239, 68, 68, 0.5);
}

/* Headings Line-Height Safeguard - Eliminates Arabic Letter and Diacritic Collisions */
h1 {
    line-height: 1.52 !important;
    letter-spacing: 0 !important;
}
h2, h3, h4, h5, h6 {
    line-height: 1.45 !important;
    letter-spacing: 0 !important;
}

/* ==========================================================================
   Dynamic Circular Emblem (Mihwar Dynamic Rotor)
   ========================================================================== */
.mihwar-circular-logo {
    width: 44px;
    height: 44px;
    border-radius: 9999px;
    object-fit: contain;
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.3s ease;
}

@media (min-width: 640px) {
    .mihwar-circular-logo {
        width: 48px;
        height: 48px;
    }
}

a:hover .mihwar-circular-logo,
.group:hover .mihwar-circular-logo {
    transform: rotate(60deg) scale(1.08);
    filter: drop-shadow(0 0 14px rgba(239, 68, 68, 0.75));
}

/* ==========================================================================
   Master Cart Drawer Styles (Smooth Hardware-Accelerated Sliding & Responsiveness)
   ========================================================================== */
#cart-drawer-backdrop {
    position: fixed !important;
    inset: 0 !important;
    z-index: 100 !important;
    background-color: rgba(0, 0, 0, 0.75) !important;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

#cart-drawer-backdrop.open {
    opacity: 1 !important;
    pointer-events: auto !important;
}

#cart-drawer {
    position: fixed !important;
    top: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 100% !important;
    max-width: 440px !important;
    height: 100% !important;
    z-index: 101 !important;
    transform: translateX(-100%);
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.35s ease;
    will-change: transform;
}

#cart-drawer.open {
    transform: translateX(0) !important;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.5) !important;
}

/* Custom Scrollbar for Cart Items */
#cart-drawer-items::-webkit-scrollbar {
    width: 5px;
}
#cart-drawer-items::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.3);
    border-radius: 9999px;
}

/* ==========================================================================
   Cross-Browser Select & Option Dropdown Enforcement (Windows Chrome & Safari)
   - Eliminates White-on-White Text Collisions in Select Popups
   ========================================================================== */
select {
    color-scheme: dark !important;
    cursor: pointer;
}

select option,
select optgroup {
    background-color: #182030 !important;
    color: #f8fafc !important;
    padding: 10px 14px !important;
}

html.dark select,
.bg-slate-950 select,
#tab-pane-parts select,
#tab-pane-booking select,
#booking-box select {
    background-color: #182030 !important;
    color: #f8fafc !important;
    color-scheme: dark !important;
    border-color: rgba(255, 255, 255, 0.12) !important;
}

html.dark select option,
.bg-slate-950 select option,
#tab-pane-parts select option,
#tab-pane-booking select option,
#booking-box select option {
    background-color: #182030 !important;
    color: #f8fafc !important;
}

/* Light Mode Overrides for Non-Hero Selects */
html:not(.dark) select:not(.hero-select):not(.dark-select):not(#hero-select-make):not(#hero-select-model):not(#hero-select-engine):not(#booking-select-make):not(#booking-select-city) {
    background-color: #ffffff !important;
    color: #0f172a !important;
    color-scheme: light !important;
}

html:not(.dark) select:not(.hero-select):not(.dark-select):not(#hero-select-make):not(#hero-select-model):not(#hero-select-engine):not(#booking-select-make):not(#booking-select-city) option {
    background-color: #ffffff !important;
    color: #0f172a !important;
}

/* ==========================================================================
   Header Cart & Navigation SVG Dimensional Locks (Strict Overlap Prevention)
   ========================================================================== */
header button svg,
header a svg,
.cart-drawer svg,
#mobile-bottom-nav svg {
    max-width: 24px !important;
    max-height: 24px !important;
    flex-shrink: 0 !important;
}



/* ==========================================================================
   Cross-Browser Light Mode Default Select & Option Styling
   ========================================================================== */
select {
    color-scheme: light !important;
    background-color: #ffffff !important;
    color: #0f172a !important;
    cursor: pointer;
}

select option,
select optgroup {
    background-color: #ffffff !important;
    color: #0f172a !important;
    padding: 10px 14px !important;
}

html.dark select {
    color-scheme: dark !important;
    background-color: #182030 !important;
    color: #f8fafc !important;
    border-color: rgba(255, 255, 255, 0.12) !important;
}

html.dark select option,
html.dark select optgroup {
    background-color: #182030 !important;
    color: #f8fafc !important;
}


/* ==========================================================================
   BULLETPROOF HIGH-CONTRAST SELECT MENUS & SVG RESCUE LOCK
   ========================================================================== */
select {
    color-scheme: light dark;
}

#tab-pane-parts select,
#tab-pane-booking select,
.hero-select,
.dark-select,
select#hero-select-make,
select#hero-select-model,
select#hero-select-engine,
select#booking-select-make,
select#booking-select-city {
    background-color: #182030 !important;
    color: #f8fafc !important;
    color-scheme: dark !important;
}

#tab-pane-parts select option,
#tab-pane-booking select option,
.hero-select option,
.dark-select option,
select#hero-select-make option,
select#hero-select-model option,
select#hero-select-engine option,
select#booking-select-make option,
select#booking-select-city option {
    background-color: #182030 !important;
    color: #f8fafc !important;
    padding: 8px 12px !important;
}

/* Strict SVG Lock - Prevent Any SVG from Blowing Up */
header button svg,
header a svg,
.cart-btn svg,
#cart-drawer svg,
#mobile-bottom-nav svg {
    max-width: 22px !important;
    max-height: 22px !important;
    flex-shrink: 0 !important;
}
/* ==========================================================================
   Calm Dynamic 10s Automotive Hero Slideshow Engine
   - 1.8s Ultra-Smooth Velvet Crossfade (هادي وغير مفاجئ)
   - 10s Gentle Breathing Ken-Burns Scale Motion (ديناميكي ناعم)
   - Hardware-Accelerated 3D Transform
   ========================================================================== */
.hero-bg-slide {
    position: absolute !important;
    inset: 0 !important;
    opacity: 0 !important;
    z-index: 1 !important;
    pointer-events: none !important;
    transition: opacity 1800ms cubic-bezier(0.4, 0, 0.2, 1) !important;
    will-change: opacity;
}

.hero-bg-slide.active {
    opacity: 1 !important;
    z-index: 2 !important;
}

.hero-bg-slide img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    object-position: center !important;
    transform: scale(1.0);
    transition: transform 12000ms cubic-bezier(0.15, 0.85, 0.35, 1) !important;
    will-change: transform;
}

.hero-bg-slide.active img {
    transform: scale(1.055);
}

/* Header Action Tokens & Refined Cart Badge */
.cart-badge-count {
    min-width: 18px !important;
    height: 18px !important;
    padding: 0 4px !important;
    line-height: 1 !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 10px !important;
    font-weight: 900 !important;
    flex-shrink: 0 !important;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.cart-badge-count:not(.hidden) {
    display: inline-flex !important;
}

.cart-badge-count.hidden {
    display: none !important;
}

/* ==========================================================================
   Minimalist White-Shape Theme Switch (No Emojis, Pure White Knob Slider)
   ========================================================================== */
.theme-switch-btn {
    width: 48px !important;
    height: 28px !important;
    border-radius: 9999px !important;
    padding: 2px 3px !important;
    display: inline-flex !important;
    align-items: center !important;
    cursor: pointer !important;
    transition: background-color 0.28s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.28s ease !important;
    border: 1.5px solid #cbd5e1 !important;
    background-color: #e2e8f0 !important;
}

html.dark .theme-switch-btn {
    background-color: #dc2626 !important;
    border-color: #ef4444 !important;
}

.theme-switch-knob {
    width: 20px !important;
    height: 20px !important;
    border-radius: 9999px !important;
    background-color: #ffffff !important;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25) !important;
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1) !important;
    transform: translateX(0) !important;
    flex-shrink: 0 !important;
}

/* In RTL context: Light mode knob is at 0 (right), Dark mode knob slides left (-20px) */
[dir="rtl"] html.dark .theme-switch-knob {
    transform: translateX(-20px) !important;
}
[dir="ltr"] html.dark .theme-switch-knob {
    transform: translateX(20px) !important;
}

/* ==========================================================================
   Mobile UX & Responsive Stabilization (No Layout Shifts / Smooth Viewports)
   ========================================================================== */
html {
    scrollbar-gutter: stable;
    overflow-x: hidden;
    width: 100%;
    -webkit-text-size-adjust: 100%;
}

body {
    overflow-x: hidden;
    width: 100%;
    min-height: 100vh;
}

/* Prevent iOS Safari from auto-zooming and displacing layout on input focus */
@media (max-width: 768px) {
    input, select, textarea {
        font-size: 16px !important;
    }
}

/* Smooth Touch Scrolling on Drawer without Body Jumps */
#cart-drawer {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* Refined Header Cart Badge */
.cart-badge-count {
    min-width: 17px !important;
    height: 17px !important;
    padding: 0 3px !important;
    line-height: 1 !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 9px !important;
    font-weight: 900 !important;
    flex-shrink: 0 !important;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.cart-badge-count:not(.hidden) {
    display: inline-flex !important;
}

.cart-badge-count.hidden {
    display: none !important;
}

/* ==========================================================================
   Compact Catalog Filter Card & Sort Dropdown Lock
   ========================================================================== */
#catalog-sort {
    font-size: 11px !important;
    height: 32px !important;
    line-height: 32px !important;
    padding: 0 8px !important;
    border-radius: 8px !important;
    cursor: pointer !important;
}

@media (max-width: 640px) {
    #catalog-sort {
        font-size: 10px !important;
        height: 30px !important;
        line-height: 30px !important;
        padding: 0 6px !important;
        max-width: 115px !important;
    }
    #catalog-search-input {
        font-size: 11px !important;
        height: 30px !important;
        padding-left: 24px !important;
        padding-right: 8px !important;
    }
}
