:root {
    --bg-color: #ffffff;
    --text-color: #000000;
    --secondary-bg: #f5f5f5; 
    --border-color: #e5e5e5;
    --gray: #cccccc;
    --btn-bg: #000000;
    --btn-text: #ffffff;
    --cart-bg: #ffffff;
    --modal-bg: #ffffff;
    --modal-overlay: rgba(0,0,0,0.8);
    --input-bg: #ffffff;
}

body.dark-mode {
    --bg-color: #000000;
    --text-color: #ffffff;
    --secondary-bg: #1e1e1e;
    --border-color: #333333;
    --gray: #333333;
    --btn-bg: #ffffff;
    --btn-text: #000000;
    --cart-bg: #1a1a1a;
    --modal-bg: #1a1a1a;
    --modal-overlay: rgba(255,255,255,0.1); /* Ligero tinte en dark */
    --input-bg: #2d2d2d;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Helvetica', 'Arial', sans-serif; transition: background-color 0.3s, color 0.3s; }
body { background-color: var(--bg-color); color: var(--text-color); display: flex; flex-direction: column; align-items: center; min-height: 100vh; }

.container { width: 100%; max-width: 480px; padding: 20px; position: relative; transition: opacity 0.3s; }

/* HEADER */
header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; position: relative;}
.theme-toggle { font-size: 1.2rem; cursor: pointer; background: none; border: none; color: var(--text-color); padding: 5px; transition: transform 0.3s ease; }
.theme-toggle:hover { transform: rotate(20deg); }
.logo-container { flex-grow: 1; display: flex; justify-content: center; }
.logo { height: 50px; width: auto; object-fit: contain; }
.cart-icon { background-color: var(--btn-text); color: var(--btn-bg); width: 35px; height: 35px; display: flex; justify-content: center; align-items: center; border-radius: 4px; cursor: pointer; position: relative; transition: transform 0.2s; }
.cart-icon:hover { transform: scale(1.05); }
.cart-count { position: absolute; top: -5px; right: -5px; background: #ff0000; color: white; font-size: 10px; width: 15px; height: 15px; border-radius: 50%; display: none; justify-content: center; align-items: center; }

/* NAV */
nav.main-nav { display: flex; justify-content: center; gap: 30px; margin-bottom: 40px; }
.nav-link { position: relative; color: var(--text-color); text-decoration: none; font-size: 0.9rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; padding-bottom: 5px; }
.nav-link::after { content: ''; position: absolute; width: 0; height: 2px; bottom: 0; left: 50%; background: var(--text-color); transition: all 0.3s ease; transform: translateX(-50%); }
.nav-link:hover::after, .nav-link.active::after { width: 100%; }

/* PRODUCTOS GRID */
.products-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-bottom: 40px; }
.product-card { display: flex; flex-direction: column; cursor: pointer; transition: transform 0.3s ease; }
.product-card:hover { transform: translateY(-5px); }
.image-container { overflow: hidden; border-radius: 8px; width: 100%; aspect-ratio: 3/4; background-color: var(--gray); position: relative; margin-bottom: 10px; }
.product-img-slide { width: 100%; height: 100%; object-fit: cover; position: absolute; top: 0; left: 0; opacity: 0; transition: opacity 1s ease-in-out; }
.product-img-slide.active { opacity: 1; }
.product-title { font-size: 0.75rem; font-weight: bold; line-height: 1.2; color: var(--text-color); }

/* FOOTER */
footer { display: flex; justify-content: center; gap: 20px; margin-top: auto; padding-bottom: 40px; }
.social-icon { color: var(--text-color); font-size: 2rem; text-decoration: none; display: flex; align-items: center; transition: transform 0.3s; }
.social-icon:hover { transform: scale(1.1); }
.vinted-icon { width: 40px; height: 40px; fill: currentColor; background: var(--bg-color); color: var(--text-color); border-radius: 100px; }

.modal-overlay {
    position: fixed; 
    top: 0; left: 0; 
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.9); 
    backdrop-filter: blur(10px);
    z-index: 9999; 
    display: none; 
    align-items: center; 
    justify-content: center;
}

.modal-content {
    background: var(--modal-bg);
    color: var(--text-color);
    width: 95%; 
    max-width: 900px;
    max-height: 90vh; /* No permite que se salga de la pantalla */
    border-radius: 20px;
    position: relative;
    overflow-y: auto; /* Permite scroll si el contenido es largo */
    display: flex;
    flex-direction: column;
}

.modal-header-actions {
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    background: var(--modal-bg);
    position: sticky;
    top: 0;
    z-index: 10;
}

.modal-main-title { font-size: 1.5rem; font-weight: bold; }
.close-btn { font-size: 1.5rem; background: none; border: none; color: var(--text-color); cursor: pointer; transition: color 0.2s; }
.close-btn:hover { color: #ef4444; /* Rojo al pasar el mouse */ }

.modal-body-grid {
    display: grid;
    grid-template-columns: 1fr 1fr; 
    gap: 30px;
    padding: 20px;
}

.modal-left-col {
    width: 100%;
    min-height: 300px; 
}

/* Carrusel Izquierdo */
.modal-left-col { position: relative; }
.modal-carousel-container {
    position: relative;
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    aspect-ratio: 3/4;
    background: #1a1a1a;
    border-radius: 12px;
    overflow: hidden;
}
.modal-carousel-track {
    display: flex;
    height: 100%;
    transition: transform 0.4s ease-in-out;
}
.modal-img-full {
    min-width: 100%;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block; 
}

.carousel-nav {
    position: absolute; top: 50%; transform: translateY(-50%);
    background: rgba(0,0,0,0.5); color: white; border: none;
    width: 40px; height: 40px; border-radius: 50%;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    z-index: 10;
}
.carousel-nav:hover { background: rgba(0,0,0,0.8); }
.carousel-nav.prev { left: 10px; }
.carousel-nav.next { right: 10px; }

.carousel-dots {
    position: absolute; bottom: 15px; left: 0; width: 100%;
    display: flex; justify-content: center; gap: 8px;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,0.5); border: none; cursor: pointer; padding: 0;}
.dot.active { background: white; transform: scale(1.2); }

/* Detalles Derecho */
.modal-right-col { display: flex; flex-direction: column; }
.modal-product-name { font-size: 1.4rem; font-weight: bold; margin-bottom: 8px; line-height: 1.2; }
.modal-price { font-size: 1.6rem; font-weight: 800; margin-bottom: 20px; }

.size-section { margin-bottom: 25px; }
.size-label { font-weight: 600; display: block; margin-bottom: 12px; font-size: 0.95rem; }
.size-selector { display: flex; gap: 10px; margin-bottom: 20px; }
.size-btn {
    flex: 1; /* Que todos los botones midan lo mismo */
    padding: 12px; border: 1px solid var(--border-color); background: transparent;
    color: var(--text-color); border-radius: 8px; cursor: pointer; font-weight: bold;
}
.size-btn.selected { background: var(--text-color); color: var(--bg-color); }
.size-btn:hover { border-color: var(--text-color); transform: scale(1.02); }

.desc-section { margin-bottom: 30px; }
.modal-desc-label { font-weight: 600; display: block; margin-bottom: 8px; font-size: 0.95rem; }
.modal-desc-text { opacity: 0.7; line-height: 1.6; font-size: 0.9rem; color: var(--text-color); }

.add-cart-btn {
    width: 100%; padding: 18px;
    background: var(--text-color); color: var(--bg-color);
    border: none; border-radius: 12px;
    font-weight: bold; font-size: 1rem; cursor: pointer;
    margin-top: 20px;
}
.add-cart-btn:hover { opacity: 0.9; transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }

/* Responsive Modal (Móvil) */
@media (max-width: 768px) {
    .modal-overlay {
        padding: 0; /* En móvil pegado a los bordes */
    }

    .modal-content {
        width: 100%;
        height: 100%; /* Ocupa toda la pantalla en móvil vertical */
        max-height: 100vh;
        border-radius: 0; /* Pantalla completa */
    }

    .modal-body-grid {
        grid-template-columns: 1fr; /* 1 sola columna obligatoria */
        padding: 15px;
        gap: 20px;
    }

    .modal-carousel-container {
        max-width: 100%; /* Imagen a todo lo ancho */
        height: auto;
        aspect-ratio: 3/4;
    }

    .modal-right-col {
        padding-bottom: 40px; /* Espacio para no chocar con el final */
    }

    .modal-product-name {
        font-size: 1.5rem;
    }

    /* Botones de talla más grandes para dedos */
    .size-btn {
        padding: 15px;
        font-size: 1.1rem;
    }

    .add-cart-btn {
        padding: 20px;
        font-size: 1.1rem;
        border-radius: 0;
        position: sticky;
        bottom: 0;
        margin-top: 30px;
    }
}

/* Arreglo para cuando el teléfono está en horizontal */
@media (max-height: 500px) and (orientation: landscape) {
    .modal-body-grid {
        grid-template-columns: 1fr 1fr;
    }
    .modal-carousel-container {
        max-width: 200px;
    }
}

.cart-sidebar-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 2500; display: none; }
.cart-sidebar-overlay.open { display: block; }
.cart-sidebar {
    position: fixed; top: 0; right: -100%; width: 100%; max-width: 400px; height: 100%;
    background: var(--cart-bg); color: var(--text-color);
    z-index: 2600; transition: right 0.3s ease; display: flex; flex-direction: column;
}
.cart-sidebar.open { right: 0; }

.cart-header { padding: 20px; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; }
.cart-title { font-weight: bold; font-size: 1.2rem; text-transform: uppercase; }
.cart-close { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--text-color); }

.cart-items { flex-grow: 1; overflow-y: auto; padding: 20px; }
.empty-msg { text-align: center; margin-top: 50px; opacity: 0.6; }

.cart-item { display: flex; gap: 15px; margin-bottom: 20px; border-bottom: 1px solid var(--border-color); padding-bottom: 15px; }
.cart-item-img { width: 70px; height: 90px; object-fit: cover; border-radius: 4px; background: var(--gray); }
.cart-item-details { flex-grow: 1; display: flex; flex-direction: column; justify-content: space-between; }
.cart-item-title { font-size: 0.9rem; font-weight: bold; }
.cart-item-info { font-size: 0.8rem; opacity: 0.8; }

.cart-controls { display: flex; justify-content: space-between; align-items: center; margin-top: 5px; }
.qty-control { display: flex; align-items: center; border: 1px solid var(--border-color); border-radius: 4px; }
.qty-btn { background: none; border: none; color: var(--text-color); width: 25px; height: 25px; cursor: pointer; }
.qty-val { width: 30px; text-align: center; font-size: 0.9rem; }
.remove-btn { color: #ff4444; background: none; border: none; cursor: pointer; font-size: 0.8rem; }

.cart-footer { padding: 20px; border-top: 1px solid var(--border-color); background: var(--secondary-bg); }
.cart-total { display: flex; justify-content: space-between; margin-bottom: 15px; font-weight: bold; font-size: 1.2rem; }
.checkout-btn { width: 100%; background: #28a745; color: white; padding: 15px; border: none; font-weight: bold; border-radius: 8px; cursor: pointer; text-transform: uppercase; }
.checkout-btn:hover { background: #218838; }

/* =========================================
   FORMULARIO DE PAGO (Replica)
   ========================================= */
.payment-form-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: var(--bg-color); z-index: 3000;
    overflow-y: auto; display: none;
}
.payment-container { max-width: 800px; margin: 0 auto; padding: 20px; color: var(--text-color); }
.payment-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; border-bottom: 1px solid var(--border-color); padding-bottom: 15px; }
.back-cart-btn { background: none; border: none; font-size: 1.5rem; color: var(--text-color); cursor: pointer; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media(max-width: 600px) { .form-row { grid-template-columns: 1fr; gap: 0; } }

.form-group { margin-bottom: 15px; }
.form-group label { display: block; margin-bottom: 5px; font-weight: 600; font-size: 0.9rem; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 12px; border: 1px solid var(--border-color);
    background: var(--input-bg); color: var(--text-color);
    border-radius: 8px; font-size: 1rem;
}

.section-title { font-size: 1.2rem; font-weight: bold; margin: 25px 0 15px 0; border-bottom: 1px solid var(--border-color); padding-bottom: 5px; }
.order-summary-box { background: var(--secondary-bg); padding: 15px; border-radius: 8px; margin: 20px 0; }
.summary-item { display: flex; justify-content: space-between; font-size: 0.9rem; margin-bottom: 5px; border-bottom: 1px dashed var(--border-color); padding-bottom: 5px;}
.summary-total-line { display: flex; justify-content: space-between; font-weight: bold; font-size: 1.1rem; margin-top: 10px; }

.payment-methods { text-align: center; margin-top: 30px; }
.pay-link {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    padding: 14px; margin: 10px 0; border-radius: 8px;
    color: white; text-decoration: none; font-weight: bold; transition: transform 0.2s;
}
.pay-link:hover { transform: translateY(-2px); }
.pay-link.revolut { background: linear-gradient(135deg, #0070ba, #00c6ff); }
.pay-link.paypal { background: linear-gradient(135deg, #003087, #009cde); }

.confirm-order-btn {
    width: 100%; padding: 15px; background: #28a745; color: white;
    border: none; border-radius: 8px; font-size: 1.1rem; font-weight: bold;
    cursor: pointer; margin-top: 20px;
}
.confirm-order-btn:hover { background: #218838; }

/* =========================================
   CONFIRMACIÓN / FACTURA
   ========================================= */
.confirmation-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: var(--bg-color); z-index: 3100;
    overflow-y: auto; display: none; text-align: center; padding: 20px;
}
.confirmation-container { max-width: 700px; margin: 0 auto; padding-bottom: 50px; }
.success-icon { font-size: 4rem; color: #28a745; margin: 20px 0; }

.invoice-box {
    background: var(--secondary-bg); border-radius: 12px;
    padding: 20px; margin: 30px auto; text-align: left;
    border: 1px solid var(--border-color);
}
.invoice-title { font-size: 1.2rem; font-weight: bold; text-align: center; margin-bottom: 20px; border-bottom: 2px solid var(--border-color); padding-bottom: 10px; }
.invoice-section { margin-bottom: 20px; }
.invoice-label { font-weight: bold; font-size: 0.9rem; margin-bottom: 5px; color: var(--gray); }
.status-processing { color: #28a745; font-weight: bold; }
.invoice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media(max-width: 600px) { .invoice-grid { grid-template-columns: 1fr; } }

.invoice-products-list { border-top: 1px dashed var(--border-color); margin-top: 5px; }
.inv-prod-item { display: flex; justify-content: space-between; padding: 5px 0; border-bottom: 1px dashed var(--border-color); font-size: 0.9rem; }

.invoice-totals { margin-top: 20px; background: rgba(0,0,0,0.05); padding: 10px; border-radius: 5px; }
.summary-line { display: flex; justify-content: space-between; margin-bottom: 5px; }
.summary-line.total { font-weight: bold; font-size: 1.2rem; margin-top: 10px; border-top: 1px solid var(--border-color); padding-top: 5px; }

.invoice-footer-msg { font-size: 0.8rem; text-align: center; margin-top: 20px; opacity: 0.7; }

.continue-shopping-btn {
    background: var(--text-color); color: var(--bg-color);
    padding: 15px 30px; border: none; border-radius: 8px;
    font-weight: bold; cursor: pointer;
}