:root {
    /* Nueva Paleta Modern/Tech */
    --primary-color: #6E64C5;
    /* Indigo Custom Brand */
    --primary-hover: #5a51a3;
    --secondary-color: #10B981;
    /* Emerald Fresh */
    --secondary-hover: #059669;
    --accent-color: #F59E0B;
    /* Amber Warning/Highlight */
    --text-color: #1F2937;
    /* Gray 800 */
    --text-light: #6B7280;
    /* Gray 500 */
    --light-bg: #F3F4F6;
    /* Gray 100 */
    --white: #ffffff;

    /* Gradientes */
    --gradient-primary: linear-gradient(135deg, #6E64C5 0%, #5a51a3 100%);
    --gradient-hover: linear-gradient(135deg, #5a51a3 0%, #6E64C5 100%);
    --gradient-success: linear-gradient(135deg, #10B981 0%, #34d399 100%);
    --gradient-insta: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
}

.bg-custom-brand {
    background-color: #6E64C5 !important;
}

/* Override Bootstrap Defaults globally */
.btn-primary {
    background-color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
}

.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active {
    background-color: var(--primary-hover) !important;
    border-color: var(--primary-hover) !important;
}

.bg-primary {
    background-color: var(--primary-color) !important;
}

.text-primary {
    color: var(--primary-color) !important;
}

body {
    font-family: 'Poppins', 'Segoe UI', sans-serif;
    /* Poppins principal */
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
    /* background properties handled in backgrounds.css */
    display: flex;
    flex-direction: column;
}

/* Asegurar que el main ocupe el espacio disponible */
main {
    flex: 1 0 auto;
}

/* --- FOOTER STYLES --- */
.footer {
    flex-shrink: 0;
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    color: #e2e8f0;
    margin-top: auto;
    width: 100%;
}

.footer a {
    color: #94a3b8;
    transition: color 0.3s ease;
}

.footer a:hover {
    color: #fff;
    text-decoration: none;
}

.footer-banner {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.footer-banner:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.footer-copyright {
    color: #94a3b8;
    font-size: 0.875rem;
}

/* --- HERO SECTION --- */
.hero-section {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    padding: 4rem 2rem;
    border-radius: 24px;
    margin-bottom: 2rem;
    box-shadow: 0 10px 40px rgba(102, 126, 234, 0.3);
    position: relative;
    overflow: hidden;
}

.hero-section::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
    animation: pulse 4s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 0.5;
    }

    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
}

.hero-content {
    position: relative;
    z-index: 1;
}

.hero-content h1 {
    font-size: 3.5rem;
    font-weight: 800;
    text-shadow: 2px 4px 8px rgba(0, 0, 0, 0.3);
    margin-bottom: 1.5rem;
    color: #fff !important;
    letter-spacing: -0.5px;
}

.hero-content .lead {
    font-size: 1.35rem;
    font-weight: 500;
    color: #fff !important;
    text-shadow: 1px 2px 4px rgba(0, 0, 0, 0.2);
    max-width: 900px;
    margin: 0 auto;
    line-height: 1.8;
}

/* Efecto Glassmorphism General */
.glass-effect {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

/* --- CARDS DE PRODUCTOS --- */
.card {
    border: none;
    border-radius: 20px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    background: white;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}



.card-title {
    font-weight: 700;
    font-size: 1.15rem;
    margin-bottom: 0.75rem;
    color: var(--text-color);
    line-height: 1.4;

    /* Text Clamp Logic */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    height: 2.8em;
    /* 1.4 line-height * 2 lines */
}

.card-img-container {
    position: relative;
    overflow: hidden;
    height: 250px;
    /* Fixed height for consistency */
    width: 100%;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.card-img-container img,
.product-carousel .carousel-item img,
.single-product-image {
    max-height: 100%;
    max-width: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    transition: transform 0.3s ease;
}

.card-body {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    padding: 1.25rem;
    justify-content: space-between;
}

/* Utilities for text description */
.text-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 4.5em;
    /* approximate for 3 lines */
}

.price-container {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid aliceblue;
}

/* Section Headings */
h2 {
    font-weight: 800;
    font-size: 2.5rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 2rem;
}

h3 {
    font-weight: 700;
    font-size: 1.5rem;
    color: var(--text-color);
}

/* Navbar Improvements */
.navbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
}

.navbar-brand img {
    height: 45px;
    width: auto;
}

.nav-link {
    font-weight: 600;
    color: var(--text-color) !important;
    transition: color 0.2s;
}

.nav-link:hover {
    color: var(--primary-color) !important;
}

/* Dropdown Menu Z-Index Fix */
.dropdown-menu {
    z-index: 1050 !important;
    position: absolute !important;
}

.nav-item.dropdown {
    position: relative;
}

/* Floating Cart Button */
.floating-cart {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background: var(--gradient-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
    z-index: 1000;
    transition: all 0.3s ease;
    text-decoration: none;
    color: white;
}

.floating-cart:hover {
    transform: scale(1.1) rotate(-10deg);
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.6);
    color: white;
}

.floating-cart .cart-count {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: bold;
    border: 2px solid white;
}

/* --- BADGES --- */
.badge {
    padding: 0.5em 0.8em;
    border-radius: 8px;
    font-weight: 600;
}

.badge.bg-warning {
    background: #FEF3C7 !important;
    color: #D97706 !important;
    box-shadow: none;
}

.badge.text-bg-warning {
    background: #FEF3C7 !important;
    color: #D97706 !important;
    border: 1px solid rgba(217, 119, 6, 0.2);
    transition: all 0.2s;
}

a.badge:hover {
    background: #FDE68A !important;
    transform: translateY(-1px);
}

/* --- OTROS COMPONENTES --- */
.input-group .form-control {
    border-radius: 12px 0 0 12px;
    border: 2px solid #E5E7EB;
    padding: 0.75rem 1rem;
}

.input-group .form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.input-group-text {
    border-radius: 0 12px 12px 0;
    background: var(--primary-color);
    color: white;
    border: none;
}

/* Animaciones de entrada (Scroll) */
.fade-in-up {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.fade-in-up.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Responsividad y Mobile Optimization */
@media (max-width: 768px) {
    .hero-content h1 {
        font-size: 2rem !important;
    }

    .hero-content .lead {
        font-size: 1.1rem !important;
    }

    .hero-section {
        padding: 2.5rem 1.5rem;
        border-radius: 16px;
        margin-left: 0;
        margin-right: 0;
    }

    h2 {
        font-size: 1.75rem;
    }

    h3 {
        font-size: 1.25rem;
    }

    .card-img-container {
        height: 180px;
    }

    .card-title {
        font-size: 1.1rem;
    }

    /* Mejora de Touch Targets (mínimo 44px) */
    .btn,
    .nav-link,
    .dropdown-item {
        min-height: 48px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .nav-link {
        justify-content: flex-start;
        padding: 12px 16px;
    }

    /* Espaciado en menú móvil */
    .navbar-collapse {
        padding: 1rem 0;
        max-height: 80vh;
        overflow-y: auto;
    }

    .nav-item.dropdown {
        background: transparent !important;
    }

    .dropdown-menu {
        border: none;
        background: rgba(243, 244, 246, 0.5);
        box-shadow: none;
        padding-left: 1rem;
        margin-top: 0;
    }

    .dropdown-item {
        background: white;
        margin-bottom: 8px;
        border-radius: 12px;
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
        justify-content: flex-start;
        padding-left: 20px;
    }

    .dropdown-item:active {
        background-color: var(--primary-color);
        color: white;
    }

    /* Espaciado de tarjetas */
    .col-md-4 {
        margin-bottom: 2rem;
    }

    .product-card,
    .category-card {
        margin-bottom: 1rem;
    }

    /* Footer responsive */
    .footer-banner {
        font-size: 0.85rem !important;
    }

    .footer-banner span[style*="font-size: 1.7rem"] {
        font-size: 1.3rem !important;
    }
}

/* Tablet optimization */
@media (min-width: 769px) and (max-width: 1024px) {
    .hero-content h1 {
        font-size: 2.75rem !important;
    }

    .hero-content .lead {
        font-size: 1.2rem !important;
    }

    h2 {
        font-size: 2rem;
    }
}

/* ==================== IMAGE OPTIMIZATION STYLES ==================== */

/* Aspect Ratio Container for Images */
.product-carousel,
.single-product-image {
    aspect-ratio: 1 / 1;
    object-fit: contain;
}

/* Image Loading Placeholder */
img[loading="lazy"] {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

/* Fade-in animation when image loads */
img {
    opacity: 0;
    transition: opacity 0.3s ease-in;
}

img.loaded,
img[loading="lazy"]:not([src=""]) {
    opacity: 1;
}

/* Skeleton loader for image containers */
.card-img-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    z-index: 1;
    opacity: 0;
    transition: opacity 0.3s;
}

.card-img-container.loading::before {
    opacity: 1;
}

.card-img-container img {
    position: relative;
    z-index: 2;
}

/* Prevent layout shift with explicit dimensions */
.product-carousel .carousel-item img,
.single-product-image {
    width: 100%;
    height: auto;
    max-height: 200px;
}

/* Optimize carousel images */
.carousel-item {
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Performance: will-change for animations */
.card:hover,
.card:hover img {
    will-change: transform;
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    img[loading="lazy"] {
        animation: none;
    }
}

/* Animación de cambio de producto */
@keyframes productFade {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.product-fade {
    animation: productFade 0.5s ease-out;
}