/* =============================================
   Nentoplay — carrito.css
   TODO el carrito compartido (js/carrito.js) vive aquí: ventana lateral (escritorio) u hoja inferior
   (celular), filas, pie, aviso al agregar y botón del encabezado. Ninguna otra hoja define .cart-*,
   .qty-* ni .btn-full. Es autosuficiente: no usa variables de otras hojas (index.html y el resto de
   las páginas tienen paletas distintas), así se ve igual en las tres páginas.
   Apertura: JS agrega la clase «open» al .cart-sidebar y al .cart-overlay (un solo mecanismo).
   Solo el globito de cantidad (.cart-badge / .mob-cart-badge) sigue en la hoja de cada encabezado.
   ============================================= */

.cart-sidebar, .cart-overlay {
    --c-primary: #1E3A5F;
    --c-orange: #FF6B35;
    --c-orange-bg: #FFF7F4;
    --c-border: #E2E8F0;
    --c-g50: #F8FAFC;
    --c-g100: #F1F5F9;
    --c-g200: #E2E8F0;
    --c-g300: #CBD5E1;
    --c-g400: #94A3B8;
    --c-g500: #64748B;
    --c-g600: #475569;
    --c-g700: #334155;
    --c-g800: #1E293B;
    --c-red: #EF4444;
    --c-ease: .25s cubic-bezier(.4, 0, .2, 1);
}

/* ── Fondo oscuro y ventana ── */
.cart-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .55);
    z-index: 1999;
    opacity: 0;
    pointer-events: none;
    transition: opacity .3s ease;
    backdrop-filter: blur(3px);
}
.cart-overlay.open { opacity: 1; pointer-events: all; }

.cart-sidebar {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: 400px;
    max-width: 100vw;
    background: #fff;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform .38s cubic-bezier(.4, 0, .2, 1), box-shadow .38s ease;
    font-family: 'Inter', system-ui, sans-serif;
}
/* La sombra solo existe con la ventana abierta: cerrada, se filtraría por el borde de la pantalla. */
.cart-sidebar.open { transform: translateX(0); box-shadow: 0 20px 60px rgba(0, 0, 0, .16); }

/* ── Encabezado ── */
.cart-hd {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid var(--c-border);
    flex-shrink: 0;
}
.cart-hd-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: 'Nunito', system-ui, sans-serif;
    font-size: 17px;
    font-weight: 900;
    color: var(--c-primary);
}
.cart-hd-title i { color: var(--c-orange); }
.cart-hd-count {
    background: var(--c-orange-bg);
    color: var(--c-orange);
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 11px;
    font-weight: 800;
    padding: 3px 8px;
    border-radius: 20px;
}
.cart-close {
    width: 34px; height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 10px;
    background: none;
    color: var(--c-g400);
    font-size: 16px;
    cursor: pointer;
    transition: all var(--c-ease);
}
.cart-close:hover { background: var(--c-g100); color: var(--c-g700); }

/* ── Cuerpo ── */
.cart-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 22px;
}
.cart-body::-webkit-scrollbar { width: 4px; }
.cart-body::-webkit-scrollbar-track { background: transparent; }
.cart-body::-webkit-scrollbar-thumb { background: var(--c-g200); border-radius: 4px; }

.cart-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    height: 100%;
    min-height: 260px;
    padding: 32px;
    color: var(--c-g400);
    text-align: center;
}
.cart-empty i { font-size: 52px; }
.cart-empty strong { display: block; margin-bottom: 4px; font-family: 'Nunito', system-ui, sans-serif; font-size: 16px; color: var(--c-g600); }
.cart-empty p { font-size: 13px; line-height: 1.5; }

/* ── Fila de producto ── */
.cart-item {
    display: flex;
    gap: 12px;
    padding: 14px 0;
    border-bottom: 1px solid var(--c-border);
    animation: npCartItemIn .25s ease;
}
.cart-item:last-child { border-bottom: none; }
@keyframes npCartItemIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.cart-item-img {
    width: 68px; height: 68px;
    flex-shrink: 0;
    border-radius: 10px;
    object-fit: cover;
    background: var(--c-g100);
}
.cart-item-info { flex: 1; min-width: 0; }
.cart-item-cat {
    margin-bottom: 3px;
    font-family: 'Nunito', system-ui, sans-serif;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--c-g400);
}
.cart-item-name {
    margin-bottom: 10px;
    font-family: 'Nunito', system-ui, sans-serif;
    font-size: 13.5px;
    font-weight: 700;
    line-height: 1.3;
    color: var(--c-g800);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cart-item-var {
    margin: -6px 0 8px;
    font-size: 12px;
    color: var(--c-g400);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cart-item-foot { display: flex; align-items: center; justify-content: space-between; }
.cart-item-price {
    font-family: 'Nunito', system-ui, sans-serif;
    font-size: 15px;
    font-weight: 900;
    color: var(--c-primary);
}
.cart-item-remove {
    width: 26px; height: 26px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 8px;
    border: none;
    border-radius: 6px;
    background: none;
    color: var(--c-g300);
    font-size: 12px;
    cursor: pointer;
    transition: all var(--c-ease);
}
.cart-item-remove:hover { color: var(--c-red); background: #FEF2F2; }

/* Cantidad */
.qty-controls {
    display: flex;
    align-items: center;
    overflow: hidden;
    border: 1px solid var(--c-border);
    border-radius: 6px;
}
.qty-btn {
    width: 28px; height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: var(--c-g50);
    color: var(--c-g500);
    font-family: 'Nunito', system-ui, sans-serif;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--c-ease);
}
.qty-btn:hover { background: #EFF6FF; color: var(--c-primary); }
.qty-val {
    width: 30px;
    border-left: 1px solid var(--c-border);
    border-right: 1px solid var(--c-border);
    background: #fff;
    font-family: 'Nunito', system-ui, sans-serif;
    font-size: 13px;
    font-weight: 700;
    line-height: 28px;
    text-align: center;
    color: var(--c-g800);
}

/* ── Pie ── */
.cart-ft {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex-shrink: 0;
    padding: 18px 22px;
    border-top: 1px solid var(--c-border);
}
.cart-ft-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    color: var(--c-g500);
}
.cart-ft-row.total {
    padding-top: 10px;
    border-top: 2px solid var(--c-border);
    font-family: 'Nunito', system-ui, sans-serif;
    font-size: 18px;
    font-weight: 900;
    color: var(--c-primary);
}
.cart-ft-row.total span:last-child { color: var(--c-orange); }
.cart-ft .btn-full { width: 100%; justify-content: center; }
.cart-wa-icon { font-size: 17px; }
.cart-lock-icon { font-size: 10px; }
.cart-wa-note { font-size: 11px; line-height: 1.4; text-align: center; color: var(--c-g400); }
.cart-clear-btn {
    border: none;
    background: none;
    font-family: 'Nunito', system-ui, sans-serif;
    font-size: 11px;
    font-weight: 600;
    color: var(--c-g400);
    text-decoration: underline;
    cursor: pointer;
    transition: color var(--c-ease);
}
.cart-clear-btn:hover { color: var(--c-red); }

/* ── Celular: el carrito sube desde abajo, por encima de la barra inferior ── */
@media (max-width: 768px) {
    .cart-sidebar {
        top: auto; left: 0; right: 0; bottom: 0;
        width: 100%;
        max-height: 85vh;
        transform: translateY(100%);
        border-radius: 20px 20px 0 0;
        padding-bottom: env(safe-area-inset-bottom);
    }
    .cart-sidebar.open { transform: translateY(0); box-shadow: 0 -10px 25px rgba(0, 0, 0, .15); }
    /* Manija visual de la hoja */
    .cart-sidebar::before {
        content: "";
        display: block;
        flex-shrink: 0;
        width: 40px; height: 4px;
        margin: 12px auto 0;
        border-radius: 4px;
        background: var(--c-g300);
    }
    .cart-hd, .cart-ft { padding: 14px 16px; }
    .cart-body { padding: 10px 16px; }
    .cart-item { padding: 12px 0; gap: 12px; }
    .cart-item-img { width: 65px; height: 65px; border-radius: 8px; }
    .cart-item-name {
        margin-bottom: 6px;
        font-size: 13px;
        white-space: normal;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        -webkit-box-orient: vertical;
    }
    .cart-item-foot { margin-top: auto; }
    .cart-item-price { font-size: 14px; }
    .qty-controls { transform: scale(.95); transform-origin: left center; }
}

/* El encabezado muestra el carrito solo en pantallas anchas; en celular ya está en la barra inferior. */
@media (max-width: 768px) {
    .btn-carrito-header { display: none !important; }
}

/* Botón de agregar con el producto ya agregado */
.np-agregado { background: #10B981 !important; }

/* Aviso «agregado al carrito» */
.np-toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translate(-50%, 20px);
    max-width: min(92vw, 420px);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 12px;
    background: #1F2937;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
    box-shadow: 0 10px 28px rgba(0, 0, 0, .25);
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease, transform .25s ease;
    z-index: 9000;
}
.np-toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.np-toast.ok i { color: #34D399; }
.np-toast.error { background: #B91C1C; }
.np-toast-btn {
    flex-shrink: 0;
    border: 0;
    border-radius: 8px;
    padding: 6px 10px;
    background: rgba(255, 255, 255, .18);
    color: #fff;
    font: inherit;
    font-size: 13px;
    cursor: pointer;
}
.np-toast-btn:hover { background: rgba(255, 255, 255, .3); }

/* En celular el aviso queda encima de la barra inferior */
@media (max-width: 768px) {
    .np-toast { bottom: 78px; }
}

@media (prefers-reduced-motion: reduce) {
    .np-toast { transition: none; }
}
