:root {
    /* Color Palette */
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #818cf8;
    --secondary: #ec4899;
    --accent: #f59e0b;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;

    /* Backgrounds */
    --bg-body: #f3f4f6;
    --bg-surface: #ffffff;
    --bg-glass: rgba(255, 255, 255, 0.8);

    /* Text */
    --text-main: #111827;
    --text-muted: #6b7280;
    --text-light: #9ca3af;

    /* Borders & Shadows */
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius-md: 0.5rem;
    --radius-lg: 1rem;
    --radius-full: 9999px;

    /* Transitions */
    --transition: all 0.3s ease;
}

[data-theme="dark"] {
    --bg-body: #111827;
    --bg-surface: #1f2937;
    --bg-glass: rgba(31, 41, 55, 0.8);
    --text-main: #f9fafb;
    --text-muted: #9ca3af;
    --border-color: #374151;
    --shadow-sm: 0 1px 2px 0 rgba(255, 255, 255, 0.05);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg-body: #111827;
        --bg-surface: #1f2937;
        --bg-glass: rgba(31, 41, 55, 0.8);
        --text-main: #f9fafb;
        --text-muted: #9ca3af;
        --border-color: #374151;
    }
}

body {
    background-color: var(--bg-body);
    color: var(--text-main);
    font-family: 'Inter', sans-serif;
    -webkit-font-smoothing: antialiased;
}



/* Variable Mapping to Utilities */
.text-muted {
    color: var(--text-muted) !important;
}

.form-text {
    color: var(--text-muted) !important;
}

.card-header {
    background-color: rgba(0, 0, 0, 0.1);
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
}

[data-theme="dark"] .card-header {
    background-color: rgba(255, 255, 255, 0.05);
}

.bg-light {
    background-color: var(--bg-surface) !important;
}

.card {
    background-color: var(--bg-surface);
    border-color: var(--border-color);
    color: var(--text-main);
}

h1,
h2,
h3,
h4,
h5,
h6,
.h1,
.h2,
.h3,
.h4,
.h5,
.h6 {
    color: var(--text-main);
}

.form-label {
    color: var(--text-main);
}

.input-group-text {
    background-color: var(--bg-surface);
    color: var(--text-main);
    border-color: var(--border-color);
}

.border-bottom {
    border-bottom-color: var(--border-color) !important;
}

.border-top {
    border-top-color: var(--border-color) !important;
}

.border {
    border-color: var(--border-color) !important;
}

.list-group-item {
    background-color: var(--bg-surface);
    color: var(--text-main);
    border-color: var(--border-color);
}

.modal-content {
    background-color: var(--bg-surface);
    color: var(--text-main);
    border-color: var(--border-color);
}

.dropdown-menu {
    background-color: var(--bg-surface);
    border-color: var(--border-color);
}

.dropdown-item {
    color: var(--text-main);
}

.dropdown-item:hover {
    background-color: var(--bg-body);
    color: var(--text-main);
}

/* Product cards & category names - dark theme visibility */
[data-theme="dark"] .product-group-title {
    color: var(--text-main) !important;
    border-bottom-color: var(--primary-light);
}

[data-theme="dark"] .product-group {
    border-bottom-color: var(--border-color);
}

[data-theme="dark"] .single-course,
[data-theme="dark"] .product-card-modern {
    background-color: var(--bg-surface);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .product-card-modern .details h4,
[data-theme="dark"] .product-card-modern .product-card-title-link,
[data-theme="dark"] .product-card-modern .product-card-title-link h4,
[data-theme="dark"] .single-course .details h4,
[data-theme="dark"] .single-course .details h4 a {
    color: var(--text-main) !important;
}

[data-theme="dark"] .product-card-desc,
[data-theme="dark"] .product-card-desc-short,
[data-theme="dark"] .product-card-desc-full {
    color: var(--text-muted) !important;
}

[data-theme="dark"] .product-card-desc-toggle {
    color: var(--primary-light) !important;
}

[data-theme="dark"] .product-card-desc-full {
    border-top-color: var(--border-color);
}

[data-theme="dark"] .single-course .meta,
[data-theme="dark"] .single-course .price {
    color: var(--text-muted) !important;
}

[data-theme="dark"] .single-course .price span:first-child {
    color: var(--primary-light) !important;
}

[data-theme="dark"] .featured-carousel-card {
    background: var(--bg-surface);
    color: var(--text-main);
}

[data-theme="dark"] .featured-carousel-title {
    color: var(--text-main) !important;
}

[data-theme="dark"] .featured-carousel-section {
    border-top-color: var(--border-color);
}

.form-control,
.form-select {
    background-color: var(--bg-surface) !important;
    color: var(--text-main) !important;
    border-color: var(--border-color) !important;
}

.form-control:focus,
.form-select:focus {
    background-color: var(--bg-surface) !important;
    color: var(--text-main) !important;
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 0.25rem rgba(79, 70, 229, 0.25);
}

.form-control::placeholder {
    color: var(--text-muted);
    opacity: 0.7;
}

/* Glassmorphism */
.glass-effect {
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
}

/* Modern Navbar */
.main-header {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.search-box {
    background: var(--bg-body);
    border: 1px solid transparent;
    border-radius: var(--radius-full);
    padding: 0.25rem 0.5rem;
    transition: var(--transition);
}

.search-box:focus-within {
    background: var(--bg-surface);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.search-input {
    background: transparent;
    border: none;
    padding: 0.5rem 1rem;
    width: 100%;
}

.search-btn {
    background: var(--primary);
    color: white;
    border-radius: var(--radius-full);
    padding: 0.5rem 1.25rem;
    transition: var(--transition);
}

.search-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

/* Product Cards */
.product-card {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    overflow: hidden;
    transition: var(--transition);
    height: 100%;
    position: relative;
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.product-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    transition: var(--transition);
}

.product-card:hover .product-image {
    transform: scale(1.05);
}

.product-info {
    padding: 1rem;
}

.product-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-main);
}

.current-price {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--primary);
}

/* Buttons */
.btn-primary {
    background-color: var(--primary);
    border-color: var(--primary);
    padding: 0.6rem 1.5rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    transition: var(--transition);
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.2);
}

/* Mobile Bottom Navigation */
.mobile-bottom-nav {
    display: none;
    /* Hidden by default - will be shown via CSS media queries and JavaScript */
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-surface);
    border-top: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
    z-index: 1000;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.05);
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
    /* Ensure it's always on top and hardware accelerated */
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    /* Ensure visibility */
    visibility: visible;
    opacity: 1;
}

/* Force display when JavaScript adds this class */
.mobile-bottom-nav.mobile-nav-visible {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.75rem;
    gap: 0.25rem;
    flex: 1;
    min-width: 0;
    position: relative;
}

.mobile-nav-item i {
    font-size: 1.25rem;
}

.mobile-nav-item.active {
    color: var(--primary);
}

/* Hero Section Modernization */
.hero-wrapper {
    position: relative;
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-top: 2rem;
    background: linear-gradient(135deg, var(--primary) 0%, #8b5cf6 100%);
    color: white;
    padding: 4rem 2rem;
}

/* Badges */
.badge-custom {
    padding: 0.35em 0.65em;
    font-size: 0.75em;
    font-weight: 600;
    border-radius: 9999px;
}

/* Responsive Overrides */
/* Use multiple breakpoints to ensure mobile detection works on all devices */
@media screen and (max-width: 991.98px) {
    .mobile-bottom-nav {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
}

@media screen and (max-width: 768px) {
    .mobile-bottom-nav {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    .main-header {
        position: relative;
        /* Let it scroll away or keep sticky depending on pref */
    }

    form.search-form {
        margin-top: 0.5rem;
    }

    .chat-widget {
        bottom: 80px;
        /* Move up for bottom nav */
    }

    /* Hide Footer elements on mobile to save space */
    .footer {
        padding-bottom: 80px;
    }

    /* Show header actions in collapsed navbar for account dropdown */
    #navbarNav .header-actions {
        display: flex !important;
        flex-direction: column;
        width: 100%;
        margin-top: 1rem;
        gap: 0.5rem;
    }
    
    #navbarNav .header-actions .dropdown {
        width: 100%;
    }
    
    #navbarNav .header-actions .header-action {
        width: 100%;
        text-align: left;
        padding: 10px 15px;
    }
    
    #navbarNav .header-actions .dropdown-menu {
        position: static !important;
        transform: none !important;
        width: 100%;
        margin-top: 0.5rem;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    }
    
    /* Hide non-essential items on mobile - keep only account dropdown */
    #navbarNav .header-actions .cart-btn {
        display: none !important;
    }
    
    /* Hide wishlist, help, and theme toggle on mobile */
    #navbarNav .header-actions > a:not(.dropdown-toggle),
    #navbarNav .header-actions > button:not(.dropdown-toggle) {
        display: none !important;
    }
    
    /* Show only account dropdown and help dropdown */
    #navbarNav .header-actions .dropdown:first-of-type,
    #navbarNav .header-actions .dropdown:last-of-type {
        display: block !important;
    }
}

/* Additional mobile-specific media queries for better device support */
@media screen and (max-width: 576px) {
    .mobile-bottom-nav {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        padding: 0.5rem 0.5rem;
    }

    .mobile-nav-item {
        font-size: 0.7rem;
        gap: 0.2rem;
    }

    .mobile-nav-item i {
        font-size: 1.1rem;
    }

    /* Ensure proper spacing for mobile bottom nav */
    main {
        padding-bottom: 70px;
    }
}

/* Touch device detection - show on any touch device */
@media (hover: none) and (pointer: coarse) {
    .mobile-bottom-nav {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
}

/* Orientation-based media query for mobile devices */
@media screen and (max-width: 991.98px) and (orientation: portrait) {
    .mobile-bottom-nav {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
}

@media screen and (max-width: 991.98px) and (orientation: landscape) {
    .mobile-bottom-nav {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
}

/* Additional fallback for very small screens */
@media screen and (max-width: 480px) {
    .mobile-bottom-nav {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        padding: 0.5rem 0.25rem;
    }
}