:root {
    --bg-color: #ffffff;
    --text-color: #1E293B;
    --card-bg: #FFFFFF;
    --navbar-bg: rgba(255, 255, 255, 0.8);
    --border-color: rgba(0, 0, 0, 0.05);
    --subtle-bg: #f8fafc;
    --muted-text: #64748b;
    --footer-bg: #ffffff;
    --accent-color: #10B981;
}

[data-theme="dark"] {
    --bg-color: #0f172a;
    --text-color: #f1f5f9;
    --card-bg: #1e293b;
    --navbar-bg: rgba(15, 23, 42, 0.8);
    --border-color: rgba(255, 255, 255, 0.1);
    --subtle-bg: #1e293b;
    --muted-text: #94a3b8;
    --footer-bg: #0f172a;
    --accent-color: #34D399;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-color);
    background-size: 400% 400%;
    background-attachment: fixed;
    color: var(--text-color);
    position: relative;
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
}

h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 {
    color: var(--text-color) !important;
}

/* Ensure headings inside light-text containers are visible */
.text-white h1, .text-white h2, .text-white h3, .text-white h4, .text-white h5, .text-white h6,
.bg-dark h1, .bg-dark h2, .bg-dark h3, .bg-dark h4, .bg-dark h5, .bg-dark h6 {
    color: #ffffff !important;
}

body.animated-bg {
    background: linear-gradient(-45deg, var(--bg-color), var(--subtle-bg), var(--bg-color), var(--subtle-bg));
    animation: gradientBG 15s ease infinite;
}

@keyframes gradientBG {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Background blobs */
.bg-blob {
    display: block !important;
    pointer-events: none;
}

.opacity-10 { opacity: 0.1; }

.hover-lift {
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

.hover-lift:hover {
    transform: translateY(-5px);
    box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.1) !important;
}

.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.floating-animation {
    animation: floating 3s ease-in-out infinite;
}

@keyframes floating {
    0% { transform: translate(0, 0px); }
    50% { transform: translate(0, 15px); }
    100% { transform: translate(0, -0px); }
}

.btn-success {
    background-color: #10B981;
    border-color: #10B981;
}

.btn-success:hover {
    background-color: #059669;
    border-color: #059669;
}

.text-success {
    color: #10B981 !important;
}

.bg-success {
    background-color: #10B981 !important;
}

.bg-primary {
    background-color: #3B82F6 !important;
}

.bg-warning {
    background-color: #F59E0B !important;
}

.bg-success-subtle {
    background-color: #ECFDF5 !important;
}

[data-theme="dark"] .bg-success-subtle {
    background-color: rgba(16, 185, 129, 0.1) !important;
}

.rounded-4 { border-radius: 1rem !important; }
.rounded-5 { border-radius: 1.5rem !important; }

/* Navbar styling */
.navbar {
    background: var(--navbar-bg) !important;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color) !important;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.navbar-brand {
    font-size: 1.25rem;
}

/* Card styling */
.card {
    border: 1px solid var(--border-color);
    background-color: var(--card-bg);
    color: var(--text-color);
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

.card-title {
    color: var(--text-color);
}

.text-muted {
    color: var(--muted-text) !important;
}

/* Theme toggle button styling */
.theme-toggle-btn {
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
    background: var(--subtle-bg);
    color: var(--text-color);
    position: relative;
    overflow: hidden;
}

.theme-toggle-btn:hover {
    background-color: var(--border-color);
    transform: rotate(15deg) scale(1.05);
}

.theme-toggle-btn i {
    font-size: 1.1rem;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] .theme-toggle-btn {
    box-shadow: 0 0 15px rgba(245, 158, 11, 0.2);
    border-color: rgba(245, 158, 11, 0.3);
}

[data-theme="dark"] .theme-toggle-btn i {
    color: #F59E0B;
}

/* Language selector polish */
.lang-selector-btn {
    background: var(--subtle-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.lang-selector-btn:hover {
    background-color: var(--border-color);
    border-color: var(--muted-text);
}

.lang-selector-btn i {
    color: var(--accent-color);
}

/* Override Bootstrap utilities for dark mode */
[data-theme="dark"] .bg-white,
[data-theme="dark"] .btn-white {
    background-color: var(--card-bg) !important;
    color: var(--text-color) !important;
}

[data-theme="dark"] .bg-light {
    background-color: var(--subtle-bg) !important;
}

[data-theme="dark"] .border-top,
[data-theme="dark"] .border-bottom,
[data-theme="dark"] .border {
    border-color: var(--border-color) !important;
}

[data-theme="dark"] footer.bg-white {
    background-color: var(--footer-bg) !important;
}

[data-theme="dark"] .list-unstyled a.text-muted:hover {
    color: var(--text-color) !important;
}

[data-theme="dark"] .form-control {
    background-color: var(--subtle-bg);
    border-color: var(--border-color);
    color: var(--text-color);
}

[data-theme="dark"] .form-control::placeholder {
    color: var(--muted-text);
}

[data-theme="dark"] .dropdown-menu {
    background-color: var(--card-bg);
    border-color: var(--border-color);
    box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.4) !important;
    padding: 0.5rem;
    border-radius: 1rem;
}

[data-theme="dark"] .dropdown-item {
    color: var(--text-color);
    border-radius: 0.5rem;
}

[data-theme="dark"] .dropdown-item:hover {
    background-color: var(--subtle-bg);
    color: var(--text-color);
}

[data-theme="dark"] .nav-link {
    color: var(--text-color);
}

[data-theme="dark"] .nav-link:hover {
    color: #10B981;
}

[data-theme="dark"] .btn-outline-dark {
    border-color: var(--text-color);
    color: var(--text-color);
}

[data-theme="dark"] .btn-outline-dark:hover {
    background-color: var(--text-color);
    color: var(--bg-color);
}

[data-theme="dark"] .badge.bg-light {
    background-color: rgba(255,255,255,0.1) !important;
    color: var(--text-color) !important;
}

[data-theme="dark"] .breadcrumb-item.active {
    color: var(--muted-text) !important;
}

[data-theme="dark"] .navbar-toggler-icon {
    filter: invert(1) grayscale(1) brightness(2);
}

/* Mobile adjustments */
@media (max-width: 991.98px) {
    .navbar-collapse {
        background-color: var(--card-bg);
        margin: 0 -1rem;
        padding: 1rem;
        border-radius: 0 0 1.5rem 1.5rem;
        border: 1px solid var(--border-color);
        border-top: none;
        box-shadow: 0 1.5rem 3rem rgba(0,0,0,0.1);
    }
    
    [data-theme="dark"] .navbar-collapse {
        box-shadow: 0 1.5rem 3rem rgba(0,0,0,0.4);
    }

    .navbar-nav .nav-item {
        width: 100%;
        padding: 0.15rem 0;
    }

    .navbar-nav .nav-link {
        padding: 0.85rem 1.25rem !important;
        border-radius: 0.75rem;
        font-weight: 500;
    }

    .navbar-nav .nav-link:hover {
        background-color: var(--subtle-bg);
    }

    .navbar-nav .dropdown-menu {
        background-color: var(--subtle-bg);
        border: none;
        box-shadow: none !important;
        margin: 0.5rem 1rem;
        padding: 0.5rem;
    }

    .mobile-controls-row {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 1rem 1.25rem;
        background: var(--subtle-bg);
        border-radius: 1rem;
        margin-top: 0.75rem;
        border: 1px solid var(--border-color);
    }

    .display-4 {
        font-size: 2rem !important;
        line-height: 1.2;
    }
    
    .lead {
        font-size: 1rem;
    }
    
    .btn-lg {
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
    }
}

/* Mobile Bottom Navigation */
.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 65px;
    background: var(--card-bg);
    display: flex;
    align-items: center;
    justify-content: space-around;
    box-shadow: 0 -5px 20px rgba(0,0,0,0.1);
    z-index: 1040;
    border-top: 1px solid var(--border-color);
    padding-bottom: env(safe-area-inset-bottom);
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--muted-text);
    font-size: 0.7rem;
    font-weight: 500;
    transition: all 0.2s ease;
    flex: 1;
}

.mobile-nav-item i {
    font-size: 1.25rem;
    margin-bottom: 4px;
}

.mobile-nav-item.active {
    color: var(--accent-color);
}

.mobile-nav-item.active i {
    transform: translateY(-2px);
}

/* Sticky Download Button for Mobile */
.sticky-download-bar {
    position: fixed;
    bottom: 65px; /* Above mobile-bottom-nav */
    left: 0;
    right: 0;
    background: var(--card-bg);
    padding: 0.75rem 1rem;
    box-shadow: 0 -5px 15px rgba(0,0,0,0.05);
    z-index: 1030;
    border-top: 1px solid var(--border-color);
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.sticky-download-bar.show {
    transform: translateY(0);
}

/* Search Overlay */
.search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-color);
    z-index: 1100;
    display: none;
    padding: 2rem 1.5rem;
}

.search-overlay.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.search-overlay .btn-close-search {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    font-size: 1.5rem;
    color: var(--text-color);
    background: none;
    border: none;
}

/* Share FAB */
.share-fab {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: var(--accent-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
    z-index: 1020;
    text-decoration: none;
    transition: all 0.3s ease;
}

.share-fab:hover {
    color: white;
    transform: scale(1.1);
}

/* WhatsApp FAB */
.whatsapp-fab {
    position: fixed;
    bottom: 80px;
    left: 20px;
    width: 50px;
    height: 50px;
    background: #25D366;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(37, 211, 102, 0.4);
    z-index: 1020;
    text-decoration: none;
    transition: all 0.3s ease;
}

.whatsapp-fab:hover {
    color: white;
    transform: scale(1.1);
}

/* Back to Top */
.back-to-top {
    position: fixed;
    bottom: 140px;
    right: 20px;
    width: 40px;
    height: 40px;
    background: var(--card-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    z-index: 1010;
    text-decoration: none;
    transition: all 0.3s ease;
    opacity: 0;
    visibility: hidden;
}

.back-to-top.show {
    opacity: 1;
    visibility: visible;
}

/* Category Chips Scroll */
.category-scroll .btn {
    border: none;
    transition: all 0.2s ease;
}

.category-scroll .btn-light {
    background: var(--subtle-bg);
    color: var(--muted-text);
}

.category-scroll .btn-light:hover {
    background: var(--border-color);
    color: var(--text-color);
}

/* Featured Scroll Hover */
.featured-scroll .card:hover {
    background: var(--subtle-bg);
}

/* Hide desktop elements on mobile and vice-versa */
@media (min-width: 992px) {
    .mobile-bottom-nav, .sticky-download-bar, .search-overlay, .share-fab, .whatsapp-fab {
        display: none !important;
    }
}

@media (max-width: 991.98px) {
    body {
        padding-bottom: 70px; /* Space for bottom nav */
    }
    
    .navbar-brand {
        font-size: 1.1rem;
    }
    
    .navbar-toggler {
        padding: 0.25rem 0.5rem;
    }
    
    /* Improve card layout on mobile for 3 columns */
    .card-body {
        padding: 0.5rem !important;
    }
    
    .card-title {
        font-size: 0.75rem !important;
        margin-bottom: 0.25rem !important;
    }
    
    .badge {
        padding: 0.2rem 0.4rem !important;
    }

    #ai-chat-wrapper {
        bottom: 75px !important;
    }
}