:root {
    --primary-color: #007AFF;
    --primary-hover: #0056b3;
    --secondary-color: #8e8e93;
    --accent-color: #5856d6;
    --success-color: #34c759;
    --danger-color: #ff3b30;
    --bg-page: #f5f5f7;
    /* Apple style light gray */
    --navbar-bg: rgba(255, 255, 255, 0.82);
    --navbar-text: #1d1d1f;
    --card-bg: #ffffff;
    --text-main: #1d1d1f;
    --text-muted: #86868b;
    --border-radius-lg: 28px;
    --border-radius-md: 18px;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.12);
    --transition: transform 0.2s ease, box-shadow 0.2s ease;

    /* RGB variants for translucency */
    --primary-color-rgb: 0, 122, 255;
    --text-main-rgb: 29, 29, 31;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--text-main);
    line-height: 1.47059;
    background-color: var(--bg-page);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden !important;
    /* Critical: Prevent horizontal scroll */
    width: 100% !important;
    position: relative;
}

/* Global Content Reset */
.row,
section,
main,
footer {
    max-width: 100vw;
    overflow-x: hidden;
}


/* Navbar Overflow Fix - High Specificity */
body header .container,
body header .row,
body .navbar .container,
body .navbar .row {
    overflow: visible !important;
    height: auto !important;
    min-height: 50px;
    /* Preserve vertical rhythm */
}

/* Ensure dropdowns break out */
.dropdown-menu {
    z-index: 9999 !important;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    color: var(--text-main);
    margin-top: 0;
}

.section-title {
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 1rem;
    text-align: center;
    letter-spacing: -0.02em;
}

.product-name {
    font-size: 1rem;
    /* Base desktop size - elegant and legible */
    font-weight: 600;
    color: var(--text-main);
    line-height: 1.4;
    transition: var(--transition);
}

.product-price {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary-color);
}

/* Glassmorphism utility */
.glass {
    background: var(--navbar-bg);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

/* Buttons */
.btn-premium {
    padding: 12px 24px;
    border-radius: 50px;
    font-weight: 500;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: none;
    cursor: pointer;
    font-size: 0.95rem;
    letter-spacing: -0.01em;
}

.btn-premium-primary {
    background: #000 !important;
    color: white !important;
}

.btn-premium-primary:hover {
    background: var(--primary-hover);
}

/* --- THE PREMIUM CARD OVERHAUL (Absolute Specificity) --- */
body .product-card,
body .product-card.h-100 {
    background: #ffffff !important;
    border: 1px solid rgba(0, 0, 0, 0.08) !important;
    border-radius: var(--card-radius, 24px) !important;
    box-shadow: var(--card-shadow-style, 0 4px 20px rgba(0, 0, 0, 0.04)) !important;
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1) !important;
    overflow: hidden !important;
    min-height: 380px !important;
}

@media (max-width: 767.98px) {
    body .product-card,
    body .product-card.h-100 {
        min-height: 300px !important;
    }
}

body .product-card:hover {
    transform: translateY(-8px) !important;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.12) !important;
    border-color: rgba(0, 0, 0, 0.1) !important;
}

/* Modern & Compact Product Card Actions */
body .product-card .btn-buy-black,
body .product-card button.btn-buy-black {
    background-color: #000000 !important;
    color: #ffffff !important;
    border: none !important;
    border-radius: 50px !important;
    height: 40px !important;
    font-weight: 700 !important;
    font-size: 0.8rem !important;
    text-transform: uppercase !important;
    letter-spacing: 0.03em !important;
    transition: all 0.3s cubic-bezier(0.165, 0.84, 0.44, 1) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 15px !important;
    flex-grow: 1 !important;
    margin: 0 !important;
    white-space: nowrap !important;
}

body .product-card .btn-buy-black:hover {
    background-color: #333333 !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
}

body .product-card .btn-whatsapp-green,
body .product-card a.btn-whatsapp-green {
    background-color: #25D366 !important;
    color: #ffffff !important;
    border: none !important;
    border-radius: 50px !important;
    height: 40px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.3s ease !important;
    padding: 0 20px !important;
    margin: 0 !important;
    text-decoration: none !important;
    font-weight: 700 !important;
    font-size: 0.85rem !important;
}

body .product-card .btn-wa-icon {
    width: 40px !important;
    min-width: 40px !important;
    max-width: 40px !important;
    padding: 0 !important;
}


body .product-card .btn-whatsapp-green:hover {
    background-color: #128c7e !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.2) !important;
}

.product-card-actions {
    display: flex !important;
    gap: 8px !important;
    width: 100% !important;
    align-items: center !important;
    flex-direction: row !important;
    /* Always horizontal */
}



/* Typography Hierarchy in Cards */
body .product-card .product-name {
    color: #000000 !important;
    font-size: 1.1rem !important;
    font-weight: 600 !important;
    line-height: 1.4 !important;
}

body .product-card .product-price {
    color: #000000 !important;
    font-size: 1.5rem !important;
    font-weight: 800 !important;
    letter-spacing: -0.02em !important;
}

.product-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.12) !important;
    border-color: rgba(0, 0, 0, 0.1);
}

.product-image-container {
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background: #fbfbfd;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--card-radius, 28px) var(--card-radius, 28px) 0 0;
}

.product-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform 0.6s cubic-bezier(0.165, 0.84, 0.44, 1);
    padding: 20px;
}

.product-card:hover .product-image {
    transform: scale(1.05);
}

.product-badge {
    position: absolute;
    top: 0.8rem;
    left: 0.8rem;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.65rem;
    font-weight: 700;
    z-index: 10;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.badge-discount {
    background: var(--danger-color);
    color: white;
}

/* --- CONSOLIDATED MOBILE RESET (Under 768px) --- */
@media (max-width: 768px) {

    /* Level 1: Main Page Titles (Product Detail Name, Page H1) */
    h1,
    .display-5,
    .page-title {
        font-size: 1.8rem !important;
        /* ~28.8px - Clearly dominant */
        letter-spacing: -0.02em !important;
        font-weight: 700 !important;
        line-height: 1.2 !important;
        margin-bottom: 1rem !important;
    }

    /* Level 2: Section Titles (Featured, Categories, etc.) */
    .section-title,
    h2,
    .display-6,
    [id^="section-"] h2 {
        font-size: 1.5rem !important;
        /* ~24px */
        font-weight: 700 !important;
        letter-spacing: -0.01em !important;
        margin-bottom: 0.75rem !important;
    }

    /* Level 3: Product Names in Cards, Prices, and Sub-headings */
    .product-name,
    h3,
    h4,
    .price-box .fs-2,
    .product-price {
        font-size: 0.95rem !important;
        /* ~15.2px - Elegant and fits */
        font-weight: 600 !important;
        line-height: 1.3 !important;
    }

    /* Level 4: Muted Text, Badges, Secondary Info */
    .fs-5,
    .text-muted,
    h5,
    h6,
    .product-badge {
        font-size: 0.85rem !important;
        /* ~13.6px */
    }



    /* Product Detail Page Specifics */
    .product-main-view {
        min-height: auto !important;
        padding: 1rem !important;
    }

    .product-main-view img {
        max-height: 320px !important;
        object-fit: contain;
    }

    .product-info-premium {
        padding-left: 0 !important;
        max-width: 100% !important;
    }

    /* EMERGENCY FIX: Typography & Layout */
    .product-info-premium .display-5 {
        font-size: 1.5rem !important;
        /* Force smaller title */
        line-height: 1.2 !important;
        margin-bottom: 0.5rem !important;
        word-wrap: break-word;
    }

    .btn-theme-outline {
        padding: 6px 12px !important;
        /* Smaller size buttons */
        font-size: 0.9rem !important;
        margin: 0 4px 8px 0 !important;
    }

    /* Force Full Width Actions */
    .product-actions .d-grid,
    .product-actions .btn-lg {
        display: block !important;
        width: 100% !important;
        white-space: nowrap;
    }

    .product-gallery.sticky-top {
        position: relative !important;
        top: 0 !important;
    }

    /* Absolute Grid/Layout Protection */
    .container {
        padding-left: 15px !important;
        padding-right: 15px !important;
    }

    .row {
        max-width: 100vw !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    .row {
        --bs-gutter-x: 1rem !important;
    }

    [id^="section-"] {
        padding-top: 2.5rem;
        padding-bottom: 2.5rem;
    }
}

/* Product Detail Page Refinements */
.product-main-view {
    min-height: 500px;
}

.product-main-view img {
    max-height: 500px;
    object-fit: contain;
}

.product-description {
    font-size: 1.1rem;
    line-height: 1.6;
    color: inherit;
}


/* Cart Float Button - Premium Pill */
.cart-float {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: #1d1d1f;
    color: white;
    padding: 12px 24px;
    border-radius: 50px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    z-index: 999;
    transition: var(--transition);
    text-decoration: none;
    font-weight: 600;
}

.cart-float:hover {
    transform: translateY(-5px);
    color: white;
}

.cart-float .badge-count {
    background: var(--primary-color);
    min-width: 24px;
    height: 24px;
    padding: 0 6px;
    border-radius: 50%;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

/* Animations */
@keyframes pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.15);
    }

    100% {
        transform: scale(1);
    }
}

.pulse-animation {
    animation: pulse 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Dynamic Block Themes */
.theme-light {
    background-color: #ffffff !important;
    color: #1d1d1f !important;
}

.theme-dark {
    background-color: #000000 !important;
    color: #f5f5f7 !important;
}

.theme-glass {
    background: rgba(255, 255, 255, 0.4) !important;
    backdrop-filter: blur(20px) saturate(180%) !important;
    -webkit-backdrop-filter: blur(20%) saturate(180%) !important;
    border: 1px solid rgba(0, 0, 0, 0.05) !important;
}

.theme-gradient {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%) !important;
}

/* --- GLOBAL TEXT INHERITANCE (Simplificación Nuclear) --- */
body,
[id^="section-"],
#section-header,
.main-content,
main,
.category-sidebar {
    color: var(--text-main) !important;
}

/* Force standard elements to follow their parent's color (Including Inputs) */
p,
span,
h1,
h2,
h3,
h4,
h5,
h6,
label,
i,
.lead,
.breadcrumb-item,
.breadcrumb-item.active,
.nav-link,
input,
textarea,
select,
.form-control {
    color: inherit;
}

/* Links inherit unless they are premium buttons or product cards */
a:not(.btn):not(.product-card a) {
    color: inherit;
}

/* CARD PROTECTION (Forzar texto oscuro en fondos blancos) */
.product-card,
.card.bg-white,
.bg-white,
.protected-light-bg,
.icon-circle.bg-light,
.product-image-container {
    --internal-text: #1d1d1f !important;
    --internal-muted: #86868b !important;
    background-color: #ffffff !important;
    color: var(--internal-text) !important;
}

/* NUCLEAR SAFETY: Ensure buttons always have correct text color */
.btn-buy-black *,
.btn-buy-black {
    color: #ffffff !important;
}

.btn-whatsapp-green *,
.btn-whatsapp-green {
    color: #ffffff !important;
}

/* CARD PROTECTION (Isolated to text elements to avoid breaking buttons) */
.product-card .product-name,
.product-card .product-price {
    color: #000000 !important;
}

.product-card .text-muted {
    color: #86868b !important;
}

/* THEME-AWARE COMPONENTS */
.btn-theme-outline {
    border: 1px solid var(--text-main) !important;
    color: var(--text-main) !important;
    background: transparent !important;
    transition: all 0.2s ease;
}

.btn-theme-outline:hover {
    background: var(--text-main) !important;
    color: var(--bg-page) !important;
}

/* Hover & Active for Sidebar Links (Dynamic & Soft) */
.hover-bg-theme:hover,
.nav-link.active-theme {
    background: rgba(var(--primary-color-rgb, 0, 122, 255), 0.15) !important;
    color: var(--primary-color) !important;
    backdrop-filter: brightness(1.1);
}

.btn-check:checked+.btn-theme-outline {
    background: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
    color: #ffffff !important;
}

/* Theme Item Colors */
.review-item {
    background: transparent !important;
    color: inherit !important;
    border-color: rgba(var(--text-main-rgb), 0.1) !important;
}

.review-item * {
    color: inherit !important;
}

/* Mobile Navbar Adjustments (Kairex Aesthetic Mapped) */
@media (max-width: 991px) {
    .navbar-collapse {
        background-color: var(--primary-color);
        /* Kairex uses a 98% opacity blue, we use dynamic primary. For backdrop filter to work well, primary should ideally be slightly translucent, but we apply blur anyway */
        backdrop-filter: blur(64px);
        -webkit-backdrop-filter: blur(64px);
        border-radius: 16px;
        margin-top: 10px;
        padding: 20px;
        box-shadow: 0 16px 40px rgba(0, 0, 0, 0.25);
        border: 1px solid rgba(255, 255, 255, 0.15); /* Mapped from border-blue-800/50 for high contrast edge */
    }

    .navbar-collapse .nav-link-custom {
        color: var(--navbar-text) !important;
    }

    .nav-item {
        border-bottom: 1px solid rgba(255, 255, 255, 0.1); /* Mapped from hr border-blue-800/50 */
    }

    .nav-item:last-child {
        border-bottom: none;
    }

    .navbar-brand img {
        max-height: 35px;
    }
}

/* Specific Input Fixes for Dark Themes */
.form-control {
    color: var(--text-main) !important;
}

.form-control::placeholder {
    color: var(--text-main) !important;
    opacity: 0.5;
}

.form-label {
    color: inherit !important;
}

/* Nuclear Slider Spacing Protection */
#section-slider,
#section-slider .container-fluid,
#section-slider .carousel,
#section-slider .carousel-inner,
#section-slider .carousel-item {
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
}

.link-current {
    color: var(--text-main) !important;
    opacity: 0.9;
}

.search-input-group {
    background: rgba(128, 128, 128, 0.1) !important;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(128, 128, 128, 0.2) !important;
}


.search-input-group input {
    background: transparent !important;
    color: inherit !important;
    border: none !important;
}




/* Theme specific overrides */
.theme-dark h1,
.theme-dark h2,
.theme-dark h3,
.theme-dark p,
.theme-dark .text-muted {
    color: #ffffff;
}

.theme-dark .text-muted,
.theme-dark small {
    opacity: 0.7;
}

/* Responsive Table */
.admin-table {
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
    border: none !important;
}

.admin-table thead th {
    background: #f5f5f7;
    border: none;
    color: #86868b;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    padding: 16px;
}

/* Details Page (Refinement) */
.product-gallery .main-image-container {
    background: #fff;
    border-radius: 20px;
    padding: 20px;
}

.breadcrumb-item a {
    color: var(--primary-color);
    font-weight: 500;
}

.lead {
    line-height: 1.6;
    color: inherit;
}

/* Authentication Pages (Login/Register) */
.auth-container {
    background-color: var(--bg-page);
    min-height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}

.auth-card {
    background: var(--card-bg);
    border: 1px solid rgba(0, 0, 0, 0.04);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.08);
    border-radius: 24px;
    padding: 3rem;
    width: 100%;
    max-width: 480px;
}

.auth-title {
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
}

.auth-subtitle {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.form-control-auth {
    background-color: #fbfbfd;
    border: 1px solid #d2d2d7;
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 1rem;
    transition: var(--transition);
}

.form-control-auth:focus {
    background-color: #fff;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.1);
}

.auth-btn {
    width: 100%;
    padding: 14px;
    border-radius: 50px;
    font-weight: 600;
    font-size: 1rem;
    letter-spacing: -0.01em;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.2);
}

.auth-footer {
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.auth-footer a {
    color: var(--primary-color);
    font-weight: 600;
    text-decoration: none;
}

.auth-footer a:hover {
    text-decoration: underline;
}

/* Glassmorphism utility - BLUR REMOVED */
.glass {
    background: var(--navbar-bg);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.product-card:hover .product-image {
    transform: none !important;
}

.category-image-container img,
.hover-shadow img {
    transform: none !important;
}

.theme-glass {
    background: rgba(255, 255, 255, 0.6) !important;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

/* Category Hover Effects - CLEAN */
.card-hover-effect {
    transition: transform 0.3s ease;
}

.card-hover-effect:hover {
    transform: translateY(-5px);
}

.hover-shadow {
    transition: box-shadow 0.3s ease, border-color 0.3s ease;
}

.hover-shadow:hover {
    box-shadow: var(--shadow-md) !important;
    border-color: var(--primary-color) !important;
}

.hover-shadow img {
    transition: none !important;
    transform: none !important;
}

.hover-shadow:hover img {
    transform: none !important;
}