@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --primary: #081621;
    --accent: #ff6b00;
    --sale: #E74C3C;
    --bg-light: #F7F8FA;
    --text-main: #222222;
    --text-muted: #777777;
    --border: #EEEEEE;
    --white: #FFFFFF;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--white);
    color: var(--text-main);
    overflow-x: hidden;
}

ul {
    list-style: none;
}

a {
    text-decoration: none;
    color: inherit;
    transition: var(--transition);
}

button {
    cursor: pointer;
    border: none;
    background: none;
    outline: none;
    transition: var(--transition);
}

/* Layout Utilities */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Typography */
h1, h2, h3, h4 {
    font-weight: 700;
}

/* Header Styles */
header {
    background: var(--white);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 2000;
}


.main-header {
    padding: 20px 0;
}

.main-header .container {
    display: grid;
    grid-template-columns: 320px 1fr 250px;
    align-items: center;
    gap: 30px;
}

/* --- LOGO --- */
.logo {
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo .electro, .logo .cba {
    font-weight: 800;
    font-size: 24px;
    color: var(--primary);
    letter-spacing: -0.5px;
}

.logo .market {
    font-weight: 800;
    font-size: 24px;
    color: #ff6b00;
    letter-spacing: -0.5px;
}

.search-bar {
    display: flex;
    position: relative;
}

.search-bar input {
    background: #F1F1F1;
    border: none;
    padding: 12px 20px;
    border-radius: 6px;
    width: 100%;
}

.search-btn {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--primary);
    color: var(--white);
    padding: 8px 15px;
    border-radius: 4px;
}

.action-buttons {
    display: flex;
    gap: 20px;
    justify-content: flex-end;
}

.action-btn {
    position: relative;
    font-size: 20px;
}

.badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--accent);
    color: var(--white);
    font-size: 10px;
    padding: 2px 5px;
    border-radius: 50%;
}

/* Navbar */
.navbar {
    background: var(--white);
    padding: 15px 0;
    border-bottom: 1px solid var(--border);
}

.navbar .container {
    display: flex;
    align-items: center;
    gap: 40px;
}

.cat-dropdown-btn {
    background: var(--primary);
    color: var(--white);
    padding: 10px 20px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
}

.nav-links {
    display: flex;
    gap: 30px;
    font-weight: 500;
}

.nav-links a:hover {
    color: var(--accent);
}

/* --- MEGA MENU STYLES --- */
.cat-dropdown {
    position: relative;
}

.mega-menu {
    position: absolute;
    top: calc(100% + 1px);
    left: 0;
    width: 800px;
    background: var(--white);
    box-shadow: 0 15px 40px rgba(0,0,0,0.15);
    border: 1px solid var(--border);
    border-radius: 0 0 12px 12px;
    padding: 30px;
    z-index: 1500;
    opacity: 0;
    visibility: hidden;
    transform: translateY(15px);
    transition: var(--transition);
}

.cat-dropdown:hover .mega-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.mega-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 30px;
}

.mega-col h5 {
    color: var(--primary);
    font-size: 15px;
    margin-bottom: 15px;
    border-bottom: 2px solid var(--accent);
    padding-bottom: 5px;
    display: inline-block;
}

.mega-col a {
    display: block;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 8px;
    transition: var(--transition);
}

.mega-col a:hover {
    color: var(--accent);
    padding-left: 5px;
}

/* --- SIDEBAR SUBRUBROS --- */
.sub-filter-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    padding: 6px 0;
    cursor: pointer;
    color: var(--text-main);
}

.sub-filter-item input {
    accent-color: var(--accent);
}

.sub-filter-item:hover {
    color: var(--accent);
}

/* Hero Section */
.hero {
    margin-top: 30px;
}

.hero-grid {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 30px;
}

.side-categories {
    border-radius: 8px;
    position: relative;
    z-index: 1100;
}

.category-list {
    border: 1px solid var(--border);
    border-radius: 8px;
    position: relative;
    /* Eliminamos overflow: hidden para que los menús desplegables se vean */
    overflow: visible;
}

.side-categories ul li {
    border-bottom: 1px solid var(--border);
    transition: var(--transition);
}

.side-categories ul li:last-child {
    border-bottom: none;
}

.side-categories ul li a {
    display: flex;
    justify-content: space-between;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 500;
}

.side-categories ul li:hover {
    background: #f8f8f8;
}

.side-categories ul li a:hover {
    color: var(--accent);
}

.side-categories ul li a:hover i {
    color: var(--primary) !important;
}

.side-categories ul li.has-rubro, .rubro-menu li.has-subrubro {
    position: relative;
}

/* Nivel 2: RUBRO MENU */
.rubro-menu {
    position: absolute;
    top: -1px;
    left: 100%;
    width: 260px;
    background: var(--white);
    box-shadow: 10px 0 30px rgba(0,0,0,0.1);
    border: 1px solid var(--border);
    border-radius: 0 8px 8px 8px;
    z-index: 1001;
    display: none;
    padding: 0;
    animation: slideInLeft 0.3s ease-out;
}

.has-rubro:hover > .rubro-menu {
    display: block;
}

/* Nivel 3: SUBRUBRO MENU */
.subrubro-menu {
    position: absolute;
    top: -1px;
    left: 100%;
    width: 260px;
    background: var(--white);
    box-shadow: 10px 0 30px rgba(0,0,0,0.1);
    border: 1px solid var(--border);
    border-radius: 0 8px 8px 8px;
    z-index: 1002;
    display: none;
    padding: 0;
    animation: slideInLeft 0.2s ease-out;
}

.has-subrubro:hover > .subrubro-menu {
    display: block;
}

/* Menu Items Styles */
.rubro-menu li, .subrubro-menu li {
    border-bottom: none !important;
}

.rubro-menu li a, .subrubro-menu li a {
    padding: 12px 20px;
    font-weight: 500;
    color: var(--text-muted);
    font-size: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.rubro-menu li a:hover, .subrubro-menu li a:hover {
    background: #fdfdfd;
    color: var(--accent) !important;
    padding-left: 30px !important;
}

.category-list a:hover i, 
.rubro-menu a:hover i, 
.subrubro-menu a:hover i {
    color: var(--primary) !important;
}

@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
}

.filter-box {
    background: var(--white);
    animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.hero-slider {
    position: relative;
    height: 480px;
    border-radius: 12px;
    overflow: hidden;
    background: #e0e0e0;
}

.slide {
    position: absolute;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    display: flex;
    align-items: center;
    padding: 60px;
    transition: opacity 0.5s ease-in-out;
    opacity: 0;
}

.slide.active {
    opacity: 1;
}

.slide-content h4 {
    color: var(--accent);
    font-size: 18px;
    margin-bottom: 10px;
}

.slide-content h2 {
    font-size: 48px;
    max-width: 500px;
    line-height: 1.1;
    margin-bottom: 20px;
}

.slide-content p {
    font-size: 18px;
    color: var(--text-muted);
    margin-bottom: 30px;
}

.hero-btn {
    background: var(--primary);
    color: var(--white);
    padding: 15px 35px;
    border-radius: 6px;
    font-weight: 600;
    display: inline-block;
}

/* Promo Boxes */
.promo-section {
    margin: 50px 0;
}

.promo-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.promo-box {
    background: var(--bg-light);
    padding: 30px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 20px;
}

.promo-icon {
    font-size: 30px;
    color: var(--accent);
}

/* Product Section */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 30px;
}

.section-header h2 {
    font-size: 28px;
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 25px;
}

.product-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 15px;
    transition: var(--transition);
    position: relative;
}

.product-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-5px);
}

.product-badge {
    position: absolute;
    top: 15px;
    left: 15px;
    padding: 6px 12px; /* Un pequeño ajuste al padding para que respire mejor */
    border-radius: 4px;
    font-size: 12px;
    font-weight: 700;
    color: var(--white);
    z-index: 10;
}

.badge-sale { background: var(--sale); }
.badge-new { background: var(--accent); }

.product-image {
    width: 100%;
    aspect-ratio: 1/1;
    background: #fcfcfc;
    margin-bottom: 15px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.product-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: transform 0.5s ease;
}

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

.product-code {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.product-info h3 {
    font-size: 16px;
    margin-bottom: 8px;
    height: 44px; /* Un poco más para el código */
    overflow: hidden;
}

.price-box {
    display: flex;
    align-items: center;
    gap: 10px;
}

.current-price {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
}

.old-price {
    text-decoration: line-through;
    color: var(--text-muted);
    font-size: 14px;
}

.product-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 15px;
}

.add-btn {
    width: 100%;
    background: #F1F1F1;
    padding: 10px;
    border-radius: 6px;
    font-weight: 600;
}

.product-card:hover .add-btn {
    background: var(--accent);
    color: var(--white);
}

.view-btn {
    width: 100%;
    background: var(--primary);
    color: var(--white);
    padding: 10px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 14px;
}

.view-btn:hover {
    background: #1a2a35;
}

/* --- MODAL STYLES --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    backdrop-filter: blur(5px);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--white);
    width: 90%;
    max-width: 900px;
    border-radius: 12px;
    position: relative;
    padding: 40px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 50px rgba(0,0,0,0.3);
    transform: scale(0.9);
    transition: var(--transition);
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: 24px;
    color: var(--text-muted);
    background: #f1f1f1;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: var(--sale);
    color: white;
}

.modal-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
}

.carousel-main {
    width: 100%;
    aspect-ratio: 1/1;
    background: #f8f8f8;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.carousel-main img {
    max-width: 80%;
    max-height: 80%;
    object-fit: contain;
}

.carousel-prev, .carousel-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,0.8);
    width: 35px;
    height: 35px;
    border-radius: 50%;
    box-shadow: var(--shadow-sm);
}

.carousel-prev { left: 10px; }
.carousel-next { right: 10px; }

.modal-title {
    font-size: 24px;
    margin-bottom: 10px;
}

.modal-price {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 20px;
}

.stock-status {
    color: var(--accent);
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 25px;
}

.modal-highlight {
    border-top: 1px solid var(--border);
    padding-top: 20px;
    margin-bottom: 25px;
}

.modal-highlight h4 {
    margin-bottom: 10px;
    color: var(--text-main);
}

.modal-highlight p {
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.6;
}

.modal-purchase {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 30px;
}

.purchase-btns {
    display: flex;
    gap: 15px;
}

.modal-add-btn {
    flex: 1;
    padding: 15px;
    border-radius: 6px;
    font-weight: 700;
    background: var(--accent);
    color: white;
    width: 100%;
}

.modal-meta {
    border-top: 1px solid var(--border);
    padding-top: 20px;
    font-size: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.modal-meta a {
    color: var(--text-muted);
}

.modal-meta a:hover {
    color: var(--accent);
}

.modal-share {
    display: flex;
    align-items: center;
    gap: 15px;
}

.modal-share a {
    font-size: 16px;
}

.carousel-thumbs {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    justify-content: center;
}

.thumb {
    width: 60px;
    height: 60px;
    border: 2px solid transparent;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    background: #f8f8f8;
    transition: var(--transition);
}

.thumb.active {
    border-color: var(--accent);
}

.thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Responsive Utilities (Restored) */
@media (max-width: 1200px) {
    .main-header .container {
        grid-template-columns: 150px 1fr 150px;
    }
    .hero-grid {
        grid-template-columns: 1fr;
    }
    .side-categories {
        display: none;
    }
}

@media (max-width: 768px) {
    .promo-grid {
        grid-template-columns: 1fr;
    }
    .modal-content {
        padding: 20px;
    }
    .purchase-btns {
        flex-direction: column;
    }
}

/* --- CART DRAWER STYLES --- */
.cart-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 400px;
    height: 100%;
    background: var(--white);
    z-index: 2000;
    box-shadow: -5px 0 30px rgba(0,0,0,0.1);
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
}

.cart-drawer.active {
    transform: translateX(0);
}

.cart-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1999;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    backdrop-filter: blur(4px);
}

.cart-overlay.active {
    opacity: 1;
    visibility: visible;
}

.cart-header {
    padding: 25px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cart-header h3 {
    font-size: 20px;
    color: var(--primary);
}

#close-cart {
    font-size: 22px;
    color: var(--text-muted);
}

#close-cart:hover {
    color: var(--sale);
    transform: rotate(90deg);
}

.cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.cart-item {
    display: flex;
    gap: 15px;
    padding-bottom: 20px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
    position: relative;
}

.item-img {
    width: 80px;
    height: 80px;
    background: #f8f8f8;
    border-radius: 8px;
    padding: 10px;
}

.item-img img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.item-details h4 {
    font-size: 15px;
    margin-bottom: 5px;
    padding-right: 25px;
}

.item-details p {
    color: var(--accent);
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 10px;
}

.qty-control {
    display: flex;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 4px;
    width: fit-content;
}

.qty-control button {
    padding: 2px 10px;
    font-weight: 700;
}

.qty-control span {
    padding: 0 10px;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    font-size: 13px;
}

.remove-item {
    position: absolute;
    top: 0;
    right: 0;
    color: #ccc;
    font-size: 16px;
}

.remove-item:hover {
    color: var(--sale);
}

.cart-footer {
    padding: 25px;
    background: #fafafa;
    border-top: 1px solid var(--border);
}

.subtotal {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 18px;
    font-weight: 700;
}

.subtotal .price {
    color: var(--primary);
}

.shipping-info {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.cart-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cart-actions a {
    text-align: center;
    padding: 14px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 0.5px;
}

.view-cart {
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);
}

.view-cart:hover {
    background: var(--primary);
    color: var(--white);
}

.checkout {
    background: var(--accent);
    color: var(--white);
}

.checkout:hover {
    background: #4ea536;
    transform: translateY(-2px);
}

/* --- MOBILE OPTIMIZATION (Catálogo Digital App) --- */
@media (max-width: 991px) {
    .main-header .container {
        grid-template-columns: 1fr auto;
        gap: 15px;
    }
    .search-bar { grid-column: 1 / 3; order: 3; }
    .hero-grid { grid-template-columns: 1fr; gap: 20px; }
    .side-categories { display: none; } /* Ocultar sidebar tradicional en mobile */
    .navbar .container { overflow-x: auto; padding-bottom: 5px; }
    .nav-links { gap: 15px; }
    .nav-links li a { white-space: nowrap; font-size: 13px; }
}

@media (max-width: 768px) {
    .section-header h2 { font-size: 20px; }
    .product-grid { 
        grid-template-columns: 1fr 1fr; 
        gap: 10px; 
    }
    .product-card { padding: 10px; }
    .product-info h3 { font-size: 13px; height: 32px; overflow: hidden; }
    .product-price .current-price { font-size: 16px; }
    .product-price .old-price { font-size: 12px; }
    
    /* PWA/Mobile feel */
    .modal-content { 
        width: 100%; 
        height: 100vh; 
        max-height: 100vh; 
        border-radius: 0; 
        padding: 20px; 
    }
    .modal-grid { grid-template-columns: 1fr; gap: 20px; }
}

@media (max-width: 480px) {
    .container { padding: 0 10px; }
    .cart-drawer { width: 100%; }
}

/* --- INSTALLMENTS SELECT --- */
.installments-select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background-color: #fff;
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    outline: none;
    transition: border-color 0.3s, box-shadow 0.3s;
    cursor: pointer;
    margin-top: 5px;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
}

.installments-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(96, 187, 70, 0.1);
}
