/* =========================================================
   ELEMENTOS FLOTANTES GLOBALES (Preloader, Modales, Paneles)
========================================================= */

/* ================== PRELOADER ================== */
#preloader { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background-color: #ffffff; display: flex; justify-content: center; align-items: center; z-index: 99999; transition: opacity 0.5s ease, visibility 0.5s ease; }
#preloader.oculto { opacity: 0; visibility: hidden; }
.loader-circulo { width: 50px; height: 50px; border: 5px solid #f3f3f3; border-top: 5px solid var(--color-primario, #000); border-radius: 50%; animation: girar 1s linear infinite; }
@keyframes girar { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* ================== LIGHTBOX (LEGADO) ================== */
.lightbox-overlay { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background-color: rgba(0, 0, 0, 0.9); display: flex; justify-content: center; align-items: center; z-index: 10000; opacity: 0; visibility: hidden; transition: opacity 0.3s ease, visibility 0.3s ease; cursor: zoom-out; }
.lightbox-overlay.activo { opacity: 1; visibility: visible; }
.lightbox-overlay img { max-width: 90%; max-height: 90vh; border-radius: 5px; border: 5px solid #fff; box-shadow: 0 10px 30px rgba(0,0,0,0.5); transform: scale(0.8); transition: transform 0.3s ease; }
.lightbox-overlay.activo img { transform: scale(1); }

/* ================== PANELES DESLIZANTES (BASE COMPARTIDA) ================== */
.overlay-global, .overlay-carrito { position: fixed; top: 0; left: 0; width: 100%; height: 100vh; background: rgba(0,0,0,0.6); z-index: 105000; opacity: 0; visibility: hidden; transition: all 0.3s; }
.overlay-global.activo, .overlay-carrito.activo { opacity: 1; visibility: visible; }
body.overlay-activo { overflow: hidden; } 

.panel-usuario, .panel-carrito { position: fixed; background: #fff; z-index: 105001; transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1), opacity 0.3s; display: flex; flex-direction: column; top: 0; right: 0; height: 100vh; box-shadow: -5px 0 25px rgba(0,0,0,0.15); transform: translateX(100%); }
.panel-usuario { width: 100%; max-width: 450px; opacity: 0; visibility: hidden; }
.panel-carrito { width: 100%; max-width: 400px; }
.panel-usuario.activo, .panel-carrito.activo { transform: translateX(0); opacity: 1; visibility: visible; }

/* --- CABECERAS DE PANELES --- */
.panel-header, .carrito-header { display: flex; justify-content: space-between; align-items: center; padding: 20px 25px; border-bottom: 1px solid #eee; }
.panel-header h3, .carrito-header h2 { font-size: 1.1rem; font-weight: 800; text-transform: uppercase; color: var(--color-primario, #000); margin: 0; }
.btn-cerrar-panel, .btn-cerrar-carrito, #btn-cerrar-carrito { font-size: 2rem; color: #888; background: none; border: none; cursor: pointer; transition: color 0.3s, transform 0.2s;}
.btn-cerrar-panel:hover, .btn-cerrar-carrito:hover, #btn-cerrar-carrito:hover { color: var(--color-acento, #e66b3b); transform: scale(1.1); }

/* ================== PANEL DE USUARIO (LOGIN) ================== */
.panel-body { padding: 30px; overflow-y: auto; flex: 1;}
.user-form { display: flex; flex-direction: column; gap: 15px; }
.subtitulo-acceso { font-size: 0.9rem; color: #777; margin-bottom: 10px; }
.subtitulo-acceso a, .link-olvido { color: var(--color-acento, #e66b3b); font-weight: 600; }
.input-group { width: 100%; position: relative; }
.input-group input { width: 100%; padding: 12px 15px; border: 1px solid #ddd; border-radius: 6px; font-size: 0.95rem; outline: none; transition: all 0.3s; box-sizing: border-box; }
.input-group input:focus { border-color: #555; box-shadow: 0 0 5px rgba(0,0,0,0.1); }
.input-icono-derecha { display: flex; align-items: center; }
.btn-show-password { position: absolute; right: 15px; color: #aaa; font-size: 1rem; background: none; border: none; cursor: pointer; top: 50%; transform: translateY(-50%);}
.btn-show-password:hover { color: #555; }
.btn-submit { background: var(--color-primario, #000); color: #fff; padding: 14px; border-radius: 6px; font-weight: 700; text-transform: uppercase; font-size: 0.95rem; margin-top: 15px; border: none; cursor: pointer; transition: background 0.3s;}
.btn-submit:hover { background: #333; }

/* ================== PANEL DE CARRITO (NUEVO) ================== */
.carrito-body { flex: 1; overflow-y: auto; padding: 25px; display: flex; flex-direction: column; gap: 20px; }
.carrito-item { display: flex; gap: 15px; border-bottom: 1px solid #eee; padding-bottom: 20px; }
.carrito-item img { width: 85px; height: 85px; object-fit: cover; border-radius: 8px; border: 1px solid #eee; }
.carrito-item-info { flex: 1; display: flex; flex-direction: column; justify-content: space-between; }
.carrito-item-titulo { font-size: 0.9rem; font-weight: 700; color: #111; line-height: 1.3; margin-bottom: 5px;}
.carrito-item-precio { font-size: 1rem; font-weight: 800; color: var(--color-acento, #e66b3b); }

/* Controles de Cantidad en el Panel */
.carrito-item-acciones { display: flex; justify-content: space-between; align-items: center; margin-top: 10px;}
.carrito-cant-box { display: flex; align-items: center; border: 1px solid #ccc; border-radius: 6px; overflow: hidden; height: 32px;}
.carrito-cant-box button { background: #f9f9f9; border: none; width: 32px; cursor: pointer; font-weight: bold; font-size: 1.1rem; color: #555; transition: 0.2s;}
.carrito-cant-box button:hover { background: #eee; }
.carrito-cant-box input { width: 35px; border: none; text-align: center; font-weight: bold; pointer-events: none; background: #fff;}
.btn-eliminar-item { background: none; border: none; color: #aaa; cursor: pointer; transition: 0.2s; font-size: 1.1rem;}
.btn-eliminar-item:hover { color: #dc3545; }

/* Pie del Panel (Totales y Botón Pagar) */
.carrito-footer { padding: 25px; border-top: 1px solid #eee; background: #fafafa; }
.carrito-total { display: flex; justify-content: space-between; font-size: 1.3rem; font-weight: 800; margin-bottom: 10px; color: #000; }
.carrito-impuestos { font-size: 0.8rem; color: #888; text-align: center; margin-bottom: 20px; }
.btn-checkout { width: 100%; background: #000; color: #fff; padding: 15px; border: none; border-radius: 30px; font-weight: 800; font-size: 1rem; cursor: pointer; text-transform: uppercase; transition: 0.3s; font-family: inherit; }
.btn-checkout:hover { background: var(--color-acento, #e66b3b); }

/* Estado Vacío */
.carrito-vacio { text-align: center; margin-top: 50px; color: #888; display:flex; flex-direction: column; align-items: center; gap:15px;}
.carrito-vacio i { font-size: 4rem; color: #ddd; }
.btn-volver-tienda { background: var(--color-primario, #000); color: #fff; padding: 12px 30px; font-weight: 700; text-transform: uppercase; font-size: 0.9rem; border: none; border-radius: 30px; cursor: pointer; transition: background 0.3s;}
.btn-volver-tienda:hover { background: var(--color-acento, #e66b3b); }

/* ================== RESPONSIVE MÓVIL ================== */
@media (max-width: 768px) {
    /* Panel de Usuario Centrado en Móvil */
    .panel-usuario { width: 90%; max-width: 400px; height: fit-content; max-height: 90vh; top: 50%; left: 50%; right: auto; transform: translate(-50%, -50%) scale(0.9); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.3); }
    .panel-usuario.activo { transform: translate(-50%, -50%) scale(1); }
    
    /* Panel Carrito 100% de la pantalla */
    .panel-carrito { max-width: 100%; }
}