/**
 * Carnes Carmegar — Sistema de Carrito Premium
 * =============================================
 * Estilos para Drawer, Modal Ticket, y componentes
 */

/* ====================================
   CSS VARIABLES ADICIONALES
   ==================================== */

:root {
    --cart-drawer-width: 380px;
    --ticket-bg: #FFFEF7;
    --ticket-text: #1a1a1a;
    --ticket-border: #e0ddd5;
}

/* ====================================
   BOTÓN FLOTANTE (FAB)
   ==================================== */

.cart-fab {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(230, 57, 70, 0.4);
    z-index: var(--z-sticky);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.cart-fab:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(230, 57, 70, 0.5);
}

.cart-fab.pulse {
    animation: cartPulse 0.6s ease;
}

@keyframes cartPulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.2);
    }
}

.cart-fab svg {
    width: 28px;
    height: 28px;
}

.cart-fab__badge {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 24px;
    height: 24px;
    background: var(--color-gold);
    color: var(--color-text-dark);
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 700;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    animation: badgePop 0.3s ease;
}

@keyframes badgePop {
    0% {
        transform: scale(0);
    }

    70% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(1);
    }
}

.cart-fab__pulse {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: var(--color-primary);
    opacity: 0;
    pointer-events: none;
}

.cart-fab.has-items .cart-fab__pulse {
    animation: fabPulseRing 2s ease-out infinite;
}

@keyframes fabPulseRing {
    0% {
        transform: scale(1);
        opacity: 0.5;
    }

    100% {
        transform: scale(1.8);
        opacity: 0;
    }
}

/* Desktop: ajustar posición */
@media (min-width: 1024px) {
    .cart-fab {
        bottom: 30px;
        right: 30px;
        width: 70px;
        height: 70px;
    }

    .cart-fab svg {
        width: 32px;
        height: 32px;
    }
}

/* ====================================
   DRAWER (PANEL LATERAL)
   ==================================== */

.cart-drawer {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal);
    visibility: hidden;
    pointer-events: none;
}

.cart-drawer.active {
    visibility: visible;
    pointer-events: auto;
}

.cart-drawer__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.cart-drawer.active .cart-drawer__backdrop {
    opacity: 1;
}

.cart-drawer__panel {
    position: absolute;
    top: 0;
    right: 0;
    width: 100%;
    max-width: var(--cart-drawer-width);
    height: 100%;
    background: var(--color-bg-card);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.5);
}

.cart-drawer.active .cart-drawer__panel {
    transform: translateX(0);
}

.cart-drawer__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-lg);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: var(--color-bg-elevated);
}

.cart-drawer__title {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: var(--fs-lg);
    font-weight: 700;
    color: var(--color-text);
}

.cart-drawer__title svg {
    color: var(--color-primary);
}

.cart-drawer__close {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: var(--color-text);
    font-size: 1.25rem;
    cursor: pointer;
    transition: background 0.2s ease;
}

.cart-drawer__close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.cart-drawer__body {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-md);
}

/* Empty state */
.cart-drawer__empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    padding: var(--space-xl);
}

.cart-drawer__empty-icon {
    font-size: 4rem;
    margin-bottom: var(--space-lg);
    opacity: 0.5;
}

.cart-drawer__empty-text {
    font-size: var(--fs-lg);
    font-weight: 600;
    margin-bottom: var(--space-sm);
}

.cart-drawer__empty-hint {
    color: var(--color-text-muted);
    font-size: var(--fs-sm);
}

/* Footer */
.cart-drawer__footer {
    padding: var(--space-lg);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: var(--color-bg-elevated);
}

.cart-drawer__total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: var(--fs-lg);
    font-weight: 600;
    margin-bottom: var(--space-md);
}

.cart-drawer__total-value {
    font-size: var(--fs-2xl);
    color: var(--color-gold);
    font-weight: 700;
}

.cart-drawer__checkout {
    width: 100%;
    margin-bottom: var(--space-sm);
}

.cart-drawer__hint {
    text-align: center;
    font-size: var(--fs-xs);
    color: var(--color-text-muted);
    margin: 0;
}

/* ====================================
   CART ITEMS
   ==================================== */

.cart-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    background: var(--color-bg-elevated);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-sm);
    transition: transform 0.2s ease;
}

.cart-item:hover {
    transform: translateX(-4px);
}

.cart-item__info {
    flex: 1;
    min-width: 0;
}

.cart-item__name {
    font-size: var(--fs-base);
    font-weight: 600;
    margin: 0 0 2px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cart-item__meta {
    font-size: var(--fs-xs);
    color: var(--color-text-muted);
    margin: 0 0 4px 0;
}

.cart-item__price {
    font-size: var(--fs-sm);
    color: var(--color-gold);
    font-weight: 600;
    margin: 0;
}

.cart-item__controls {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-full);
    padding: 4px;
}

.cart-item__btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--color-bg-card);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--color-text);
    font-size: 1.25rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.cart-item__btn:hover {
    background: var(--color-primary);
    border-color: var(--color-primary);
}

.cart-item__qty {
    min-width: 24px;
    text-align: center;
    font-weight: 700;
    font-size: var(--fs-base);
}

.cart-item__remove {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, color 0.2s ease;
}

.cart-item__remove:hover {
    background: rgba(244, 67, 54, 0.2);
    color: var(--color-error);
}

/* ====================================
   MODAL TICKET
   ==================================== */

.cart-modal {
    position: fixed;
    inset: 0;
    z-index: var(--z-overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg);
    visibility: hidden;
    pointer-events: none;
}

.cart-modal.active {
    visibility: visible;
    pointer-events: auto;
}

.cart-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.cart-modal.active .cart-modal__backdrop {
    opacity: 1;
}

.cart-modal__container {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    opacity: 0;
    transform: scale(0.9) translateY(20px);
    transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1), transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.cart-modal.active .cart-modal__container {
    opacity: 1;
    transform: scale(1) translateY(0);
}

@media (min-width: 768px) {
    .cart-modal__container {
        flex-direction: row;
        overflow: visible;
    }
}

/* ====================================
   TICKET SKEUOMÓRFICO
   ==================================== */

.cart-ticket {
    flex: 1;
    background: var(--ticket-bg);
    color: var(--ticket-text);
    font-family: 'Courier New', Courier, monospace;
    padding: var(--space-xl) var(--space-lg);
    position: relative;
    box-shadow:
        0 10px 40px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(0, 0, 0, 0.05);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.cart-ticket::before {
    content: '';
    position: absolute;
    top: 0;
    left: var(--space-lg);
    right: var(--space-lg);
    height: 3px;
    background: repeating-linear-gradient(90deg,
            var(--color-primary) 0,
            var(--color-primary) 8px,
            transparent 8px,
            transparent 12px);
}

.cart-ticket__header {
    text-align: center;
    margin-bottom: var(--space-md);
}

.cart-ticket__logo {
    font-size: 2.5rem;
    margin-bottom: var(--space-xs);
}

.cart-ticket__title {
    font-size: var(--fs-lg);
    font-weight: 700;
    margin: 0;
    letter-spacing: 2px;
}

.cart-ticket__subtitle {
    font-size: var(--fs-xs);
    color: #666;
    margin: var(--space-xs) 0 0 0;
}

.cart-ticket__date {
    font-size: var(--fs-xs);
    color: #888;
    margin: var(--space-sm) 0 0 0;
}

.cart-ticket__divider {
    text-align: center;
    color: #ccc;
    margin: var(--space-md) 0;
    letter-spacing: -1px;
    font-size: var(--fs-sm);
}

.cart-ticket__items {
    margin-bottom: var(--space-md);
}

.cart-ticket__item {
    display: flex;
    align-items: baseline;
    margin-bottom: var(--space-sm);
    font-size: var(--fs-sm);
}

.cart-ticket__item-name {
    flex-shrink: 0;
    max-width: 60%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cart-ticket__item-dots {
    flex: 1;
    border-bottom: 1px dotted #ccc;
    margin: 0 var(--space-xs);
    position: relative;
    top: -4px;
}

.cart-ticket__item-price {
    flex-shrink: 0;
    font-weight: 700;
}

.cart-ticket__total {
    display: flex;
    justify-content: space-between;
    font-size: var(--fs-xl);
    font-weight: 700;
    padding: var(--space-md) 0;
    border-top: 2px dashed #ccc;
    border-bottom: 2px dashed #ccc;
}

.cart-ticket__footer {
    text-align: center;
    margin-top: var(--space-lg);
    font-size: var(--fs-xs);
    color: #666;
}

.cart-ticket__footer p {
    margin: var(--space-xs) 0;
}

/* Efecto papel arrancado (zigzag) */
.cart-ticket__tear {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 20px;
    background: var(--ticket-bg);
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 10'%3E%3Cpolygon points='0,0 10,10 20,0 30,10 40,0 50,10 60,0 70,10 80,0 90,10 100,0 100,10 0,10' fill='white'/%3E%3C/svg%3E");
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 10'%3E%3Cpolygon points='0,0 10,10 20,0 30,10 40,0 50,10 60,0 70,10 80,0 90,10 100,0 100,10 0,10' fill='white'/%3E%3C/svg%3E");
    mask-size: 30px 100%;
    -webkit-mask-size: 30px 100%;
    transform: translateY(100%);
}

/* ====================================
   TARJETA DE INSTRUCCIONES
   ==================================== */

.cart-instructions {
    flex: 1;
    background: var(--color-bg-card);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    position: relative;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.cart-instructions__close {
    position: absolute;
    top: var(--space-md);
    right: var(--space-md);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: var(--color-text);
    font-size: 1.25rem;
    cursor: pointer;
    transition: background 0.2s ease;
}

.cart-instructions__close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.cart-instructions__title {
    font-size: var(--fs-xl);
    font-weight: 700;
    margin: 0 0 var(--space-xs) 0;
}

.cart-instructions__subtitle {
    color: var(--color-text-muted);
    margin: 0 0 var(--space-xl) 0;
}

.cart-instructions__list {
    list-style: none;
    margin: 0 0 var(--space-xl) 0;
    padding: 0;
}

.cart-instructions__list li {
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    padding: var(--space-md);
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-sm);
    font-size: var(--fs-base);
    line-height: 1.5;
}

.cart-instructions__list li.cart-instructions__important {
    background: rgba(255, 193, 7, 0.1);
    border: 1px solid rgba(255, 193, 7, 0.3);
}

.cart-instructions__icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.cart-instructions__confirm {
    width: 100%;
    padding: var(--space-lg) var(--space-xl);
    font-size: var(--fs-lg);
    font-weight: 700;
    background: linear-gradient(135deg, #25D366, #128C7E);
    color: white;
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-md);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 20px rgba(37, 211, 102, 0.3);
}

.cart-instructions__confirm:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 30px rgba(37, 211, 102, 0.4);
}

.cart-instructions__confirm svg {
    width: 28px;
    height: 28px;
}

.cart-instructions__back {
    display: block;
    width: 100%;
    margin-top: var(--space-md);
    padding: var(--space-md);
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    font-size: var(--fs-sm);
    cursor: pointer;
    text-align: center;
    transition: color 0.2s ease;
}

.cart-instructions__back:hover {
    color: var(--color-text);
}

/* ====================================
   TOAST NOTIFICATIONS
   ==================================== */

.cart-toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--color-bg-card);
    color: var(--color-text);
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: var(--fs-sm);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    z-index: var(--z-toast);
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.cart-toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.cart-toast__icon {
    width: 24px;
    height: 24px;
    background: var(--color-whatsapp);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 700;
}

.cart-toast--success .cart-toast__icon {
    background: var(--color-gold);
    color: var(--color-text-dark);
}

@media (min-width: 1024px) {
    .cart-toast {
        bottom: 40px;
    }
}

/* ====================================
   BOTONES "AÑADIR AL CARRITO"
   ==================================== */

.btn--add-cart {
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
    color: white;
    position: relative;
    overflow: hidden;
}

.btn--add-cart::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.4s ease, height 0.4s ease;
}

.btn--add-cart:active::before {
    width: 200%;
    height: 200%;
}

.btn--add-cart:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

/* ====================================
   RESPONSIVE ADJUSTMENTS
   ==================================== */

@media (max-width: 767px) {
    .cart-drawer__panel {
        max-width: 100%;
    }

    .cart-modal__container {
        flex-direction: column;
        max-height: 95vh;
    }

    .cart-ticket {
        border-radius: var(--radius-md);
    }

    .cart-instructions {
        border-radius: var(--radius-md);
    }
}

/* Evitar superposición con mobile bar */
@media (max-width: 1023px) {
    .cart-fab {
        bottom: calc(var(--mobile-bar-height) + 20px);
    }
}