/* ========================================
   PORTAL LAMARQUE - STYLES.CSS v3.1
   Correcciones: Reset, Temas, Mobile, Carrito
   ======================================== */

/* 1. RESET GLOBAL (CORREGIDO) */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* 2. VARIABLES DE TEMA */
:root {
    --pdp-blue: #3483fa;
    --pdp-green: #00a650;
    --bg: #f5f7fa;
    --card-bg: #ffffff;
    --text: #333333;
    --text-muted: #666666;
    --border: #eeeeee;
    --vs-accent: #ffc107;
    --vs-glow: rgba(255, 193, 7, 0.3);
    --shadow: 0 2px 5px rgba(0,0,0,0.1);
    --overlay-bg: rgba(0,0,0,0.5);
}

[data-theme="dark"] {
    --bg: #121212;
    --card-bg: #1e1e1e;
    --text: #f0f0f0;
    --text-muted: #aaaaaa;
    --border: #333333;
    --shadow: 0 4px 10px rgba(0,0,0,0.5);
    --overlay-bg: rgba(0,0,0,0.7);
}

/* 3. BASE */
body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    transition: background 0.3s ease, color 0.3s ease;
    line-height: 1.5;
}

/* 4. NAVBAR */
.navbar {
    background: var(--card-bg);
    padding: 10px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
    gap: 10px;
    flex-wrap: wrap;
}

.logo {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--pdp-blue);
}

.search-container {
    flex: 1;
    max-width: 500px;
    min-width: 200px;
}

.search-input {
    width: 100%;
    padding: 10px 15px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    outline: none;
    transition: border-color 0.2s;
}

.search-input:focus {
    border-color: var(--pdp-blue);
}

/* Botones de navbar */
.theme-toggle,
.cart-icon-btn,
.menu-trigger {
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    color: var(--text);
    padding: 8px;
    border-radius: 50%;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle:hover,
.cart-icon-btn:hover,
.menu-trigger:hover {
    background: var(--border);
}

.cart-icon-btn {
    position: relative;
}

#cart-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background: var(--pdp-green);
    color: white;
    font-size: 0.65rem;
    font-weight: bold;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 5. LAYOUT PRINCIPAL */
.main-layout {
    display: flex;
    min-height: calc(100vh - 60px);
}

/* Sidebar de navegación */
aside {
    width: 250px;
    background: var(--card-bg);
    padding: 20px;
    border-right: 1px solid var(--border);
    transition: width 0.3s ease, padding 0.3s ease, opacity 0.3s ease;
    overflow: hidden;
    white-space: nowrap;
    flex-shrink: 0;
}

aside.collapsed {
    width: 0;
    padding: 0;
    opacity: 0;
    border: none;
}

.sidebar-title {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 15px;
    letter-spacing: 1px;
}

.category-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cat-btn {
    background: none;
    border: none;
    padding: 12px 15px;
    text-align: left;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text);
    font-size: 0.95rem;
    transition: background 0.2s, transform 0.1s;
    display: flex;
    align-items: center;
    gap: 10px;
}

.cat-btn:hover {
    background: var(--border);
}

.cat-btn.active {
    background: var(--pdp-blue);
    color: white;
    font-weight: 600;
}

.cat-btn:active {
    transform: scale(0.98);
}

/* 6. GRID DE PRODUCTOS */
.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
    padding: 20px;
    width: 100%;
}

/* Cards de producto */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 15px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow);
}

.card img {
    width: 100%;
    height: 160px;
    object-fit: contain;
    border-radius: 8px;
    background: white;
}

.card .title {
    font-size: 0.9rem;
    font-weight: 600;
    margin: 10px 0;
    height: 2.8em;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.4;
}

.card .price {
    color: var(--pdp-green);
    font-size: 1.3rem;
    font-weight: bold;
    margin: 5px 0;
}

/* Badge de producto local */
.badge-local {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--pdp-green);
    color: white;
    font-size: 0.7rem;
    padding: 3px 8px;
    border-radius: 4px;
    font-weight: 600;
    z-index: 1;
}

/* 7. SECCIÓN COMPARADOR VS */
#sec-vs {
    padding: 20px;
    width: 100%;
}

.vs-grid {
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-width: 800px;
    margin: 0 auto;
}

.vs-banner {
    border: 2px solid var(--vs-accent);
    border-radius: 12px;
    overflow: hidden;
    background: var(--card-bg);
    animation: glow 2s infinite ease-in-out;
}

@keyframes glow {
    0%, 100% { box-shadow: 0 0 5px var(--vs-glow); }
    50% { box-shadow: 0 0 20px var(--vs-glow); }
}

.vs-header {
    background: var(--vs-accent);
    color: #000;
    padding: 10px 15px;
    font-weight: bold;
    text-align: center;
    font-size: 0.9rem;
}

.vs-comparison {
    display: flex;
    align-items: center;
    padding: 15px;
    background: var(--card-bg);
    gap: 10px;
}

.vs-option {
    flex: 1;
    text-align: center;
    padding: 8px;
}

.vs-option.winner {
    background: #e6ffed;
    border-radius: 8px;
    color: var(--pdp-green);
}

.vs-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.vs-divider {
    font-weight: bold;
    font-style: italic;
    color: var(--text-muted);
    padding: 0 10px;
}

.vs-savings {
    display: block;
    font-size: 0.8rem;
    color: var(--pdp-green);
    font-weight: 600;
    margin-top: 4px;
}

.vs-title {
    text-align: center;
    padding: 8px 15px;
    font-size: 0.9rem;
    background: var(--bg);
    border-top: 1px solid var(--border);
}

/* 8. CARRITO SIDEBAR (NUEVO - FALTABA) */
#cart-sidebar {
    position: fixed;
    top: 0;
    right: -400px;
    width: 320px;
    max-width: 90vw;
    height: 100vh;
    background: var(--card-bg);
    border-left: 1px solid var(--border);
    box-shadow: var(--shadow);
    z-index: 2000;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
    padding: 20px;
}

#cart-sidebar.open {
    right: 0;
}

.cart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 15px;
}

.cart-header h3 {
    font-size: 1.2rem;
}

.cart-header button {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text);
    padding: 5px;
    border-radius: 50%;
}

.cart-header button:hover {
    background: var(--border);
}

#cart-items {
    flex: 1;
    overflow-y: auto;
    padding-right: 5px;
}

.cart-item {
    display: flex;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.cart-item img {
    width: 50px;
    height: 50px;
    object-fit: contain;
    border-radius: 6px;
    background: white;
}

.cart-item-info {
    flex: 1;
    min-width: 0;
}

.cart-item-title {
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cart-item-price {
    color: var(--pdp-green);
    font-weight: bold;
    font-size: 0.9rem;
}

.cart-item .btn {
    padding: 4px 10px;
    font-size: 0.75rem;
    margin-top: 5px;
    border-radius: 6px;
}

.cart-footer {
    padding-top: 15px;
    border-top: 1px solid var(--border);
}

#total-carrito {
    font-size: 1.2rem;
    font-weight: bold;
    margin-bottom: 10px;
    text-align: right;
}

/* Overlay para cerrar carrito */
#cart-overlay {
    position: fixed;
    inset: 0;
    background: var(--overlay-bg);
    z-index: 1999;
    display: none;
}

#cart-overlay.visible {
    display: block;
}

/* 9. REFERENCIAS Y CONTACTO */
.ref-box {
    margin: 0 20px 20px;
    padding: 15px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.ref-box h4 {
    margin-bottom: 10px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.link-ref {
    display: inline-block;
    margin: 3px 8px 3px 0;
    padding: 5px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--pdp-blue);
    text-decoration: none;
    font-size: 0.85rem;
    transition: background 0.2s;
}

.link-ref:hover {
    background: var(--border);
}

/* Formulario de contacto */
#sec-contacto iframe {    
    border-radius: 12px;    
    background: var(--card-bg);
}

/* 10. ESTADOS VACÍOS Y MENSAJES */
.empty-msg {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    grid-column: 1 / -1;
}

.empty-msg p {
    margin-bottom: 15px;
}

/* 11. BOTONES GLOBALES */
.btn {
    display: block;
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    margin-top: 10px;
    transition: filter 0.2s, transform 0.1s;
    font-size: 0.95rem;
}

.btn:active {
    transform: scale(0.98);
}

.btn:hover {
    filter: brightness(1.05);
}

.btn-ml {
    background: var(--pdp-blue);
    color: white;
}

.btn-wa {
    background: var(--pdp-green);
    color: white;
}

/* 12. ANIMACIONES */
.fade-in {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 13. MEDIA QUERIES - MOBILE */
@media (max-width: 768px) {
    /* Layout principal */
    .main-layout {
        flex-direction: column;
    }
    
    /* Sidebar colapsable en móvil */
    aside {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border);
        height: auto;
        padding: 10px;
    }
    
    aside.collapsed {
        height: 0;
        padding: 0;
        overflow: hidden;
        border: none;
    }
    
    /* Grid más compacto */
    .grid-container {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 12px;
        padding: 10px;
    }
    
    .card img {
        height: 130px;
    }
    
    .card .title {
        font-size: 0.85rem;
        height: 2.4em;
    }
    
    .card .price {
        font-size: 1.1rem;
    }
    
    /* Navbar compacta */
    .navbar {
        padding: 8px 12px;
        gap: 8px;
    }
    
    .search-container {
        order: 3;
        width: 100%;
        max-width: 100%;
        margin-top: 10px;
    }
    
    .logo {
        font-size: 1rem;
    }
    
    /* OCULTAR VS EN MÓVIL (estructura.md) */
    #sec-vs {
        display: none !important;
    }
    
    /* Carrito a pantalla completa en móvil */
    #cart-sidebar {
        width: 100vw;
        right: -100vw;
    }
    
    #cart-sidebar.open {
        right: 0;
    }
}

/* 14. ACCESIBILIDAD */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus visible para navegación por teclado */
:focus-visible {
    outline: 2px solid var(--pdp-blue);
    outline-offset: 2px;
}

/* Scroll suave */
html {
    scroll-behavior: smooth;
}
/* ========================================
   ANIMACIÓN BOTÓN COMPARADOR VS
   Transición entre Verde, Amarillo y Rojo
   ======================================== */

.cat-btn[data-cat="comparador"] {
    animation: vsColorTransition 5s ease infinite;
    position: relative;
    overflow: hidden;
}

@keyframes vsColorTransition {
    0% {
        background: linear-gradient(135deg, #00a650 0%, #00c853 100%);
        color: white;
        box-shadow: 0 4px 15px rgba(0, 166, 80, 0.4);
    }
    33% {
        background: linear-gradient(135deg, #ffc107 0%, #ffeb3b 100%);
        color: #000;
        box-shadow: 0 4px 15px rgba(255, 193, 7, 0.4);
    }
    66% {
        background: linear-gradient(135deg, #f44336 0%, #ff5252 100%);
        color: white;
        box-shadow: 0 4px 15px rgba(244, 67, 54, 0.4);
    }
    100% {
        background: linear-gradient(135deg, #00a650 0%, #00c853 100%);
        color: white;
        box-shadow: 0 4px 15px rgba(0, 166, 80, 0.4);
    }
}

/* Efecto pulse adicional */
.cat-btn[data-cat="comparador"]::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    transform: translate(-50%, -50%) scale(0);
    animation: pulseEffect 2s ease-out infinite;
}

@keyframes pulseEffect {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(1.5);
        opacity: 0;
    }
}

/* Asegurar que el texto se vea bien sobre los colores */
.cat-btn[data-cat="comparador"]:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
}

/* Versión móvil: mantener animación pero más suave */
@media (max-width: 768px) {
    .cat-btn[data-cat="comparador"] {
        animation: vsColorTransition 4s ease infinite;
    }
}

/* ========================================
   CARRITO - MEJORAS VISUALES
   ======================================== */

.cart-item {
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.cart-actions button:active {
    transform: scale(0.98);
}

/* Modal de compartir */
#share-modal {
    animation: fadeIn 0.2s ease;
}

/* Botón de tema - animación suave */
.theme-toggle {
    transition: transform 0.3s ease;
}

.theme-toggle:active {
    transform: rotate(180deg);
}
/* ESTILOS PARA RESULTADO GANADOR VS EN BÚSQUEDA */
.card-vs-highlight {
    border: 2px solid var(--vs-accent);
    box-shadow: 0 0 15px var(--vs-glow);
    background: #fffff0; /* Fondo sutil amarillo claro en modo luz */
}
[data-theme="dark"] .card-vs-highlight {
    background: #2a2a1a;
}

.card-badges {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    display: flex;
    justify-content: space-between;
    z-index: 2;
}

.badge-vs-winner {
    background: linear-gradient(135deg, #ffc107 0%, #ff9800 100%);
    color: #000;
    font-size: 0.7rem;
    font-weight: bold;
    padding: 4px 8px;
    border-radius: 6px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    animation: pulseVS 2s infinite;
}

@keyframes pulseVS {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}


/* ========================================
   SELECTOR DE ORDENAMIENTO (Paso 3)
   ======================================== */
.sort-select {
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--card-bg);
    color: var(--text);
    font-size: 0.9rem;
    cursor: pointer;
    min-width: 200px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.sort-select:focus {
    outline: none;
    border-color: var(--pdp-blue);
    box-shadow: 0 0 0 3px rgba(52, 131, 250, 0.2);
}

.sort-select:hover {
    border-color: var(--pdp-blue);
}

/* En modo oscuro, mejorar contraste del dropdown */
[data-theme="dark"] .sort-select {
    background: var(--bg);
}

/* Animación sutil al cambiar opción */
.sort-select:active {
    transform: scale(0.99);
}

/* Badge de "ordenado por" */
#sort-info {
    font-style: italic;
}

/* Responsive: selector a ancho completo en móvil */
@media (max-width: 768px) {
    .sort-controls {
        margin: 0 10px 15px !important;
    }
    .sort-select {
        width: 100%;
        min-width: auto;
    }
    #sort-info {
        margin-left: 0 !important;
        margin-top: 5px;
        display: block;
        width: 100%;
        text-align: center;
    }
}

