/**
 * CARRITO PREMIUM — Dark glassmorphism
 * NYXIVO · Paleta idéntica a la página de inicio
 * Usa !important donde sea necesario para vencer Bootstrap.
 */

/* ============================================
   MODAL — BASE
============================================ */
#carritoModal .modal-dialog {
    max-width: 550px;
}

#carritoModal .modal-content {
    background: rgba(8, 13, 26, 0.96) !important;
    -webkit-backdrop-filter: blur(24px) saturate(140%) !important;
            backdrop-filter: blur(24px) saturate(140%) !important;
    border: 1px solid rgba(59, 130, 246, 0.22) !important;
    border-radius: 24px !important;
    box-shadow:
        0 30px 80px -20px rgba(0, 0, 0, 0.85),
        0 0 40px -8px rgba(96, 165, 250, 0.25) !important;
    overflow: hidden;
    color: #e2e8f0 !important;
}

/* ============================================
   HEADER
============================================ */
#carritoModal .modal-header {
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.95) 0%, rgba(8, 13, 26, 0.98) 100%) !important;
    border-bottom: 1px solid rgba(59, 130, 246, 0.18) !important;
    padding: 1.5rem 1.75rem;
    position: relative;
    overflow: hidden;
}

#carritoModal .modal-header::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 0% 0%, rgba(59, 130, 246, 0.15) 0%, transparent 55%),
        radial-gradient(ellipse at 100% 100%, rgba(96, 165, 250, 0.08) 0%, transparent 55%);
    pointer-events: none;
}

#carritoModal .modal-title {
    font-size: 1.2rem;
    font-weight: 800;
    color: #f8fafc !important;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    position: relative;
    z-index: 1;
    letter-spacing: -0.01em;
}

#carritoModal .modal-title i {
    width: 38px;
    height: 38px;
    background: rgba(59, 130, 246, 0.18);
    border: 1px solid rgba(59, 130, 246, 0.30);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    color: #60a5fa;
}

#carritoModal .btn-close {
    position: relative;
    z-index: 1;
    filter: invert(1) brightness(0.6);
    opacity: 0.7;
    transition: all 0.25s ease;
}
#carritoModal .btn-close:hover {
    opacity: 1;
    filter: invert(1) brightness(1);
    transform: rotate(90deg);
}

/* ============================================
   BODY
============================================ */
#carritoModal .modal-body {
    padding: 1.25rem 1.5rem !important;
    max-height: 55vh;
    overflow-y: auto;
    background: rgba(5, 8, 17, 0.70) !important;
}

/* Scrollbar */
#carritoModal .modal-body::-webkit-scrollbar { width: 5px; }
#carritoModal .modal-body::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 3px;
}
#carritoModal .modal-body::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #3b82f6 0%, #1d4ed8 100%);
    border-radius: 3px;
}

/* ============================================
   CARRITO VACÍO
============================================ */
#carrito-vacio {
    padding: 3rem 2rem;
    text-align: center;
}
#carrito-vacio h4 {
    font-size: 1.2rem;
    font-weight: 700;
    color: #f1f5f9 !important;
    margin-bottom: 0.5rem;
}
#carrito-vacio p {
    color: #64748b !important;
    margin-bottom: 1.5rem;
}

.carrito-vacio-icon {
    width: 88px;
    height: 88px;
    margin: 0 auto 1.25rem;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(59, 130, 246, 0.18);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.carrito-vacio-icon i {
    font-size: 2.25rem;
    color: #334155;
}

/* ============================================
   CONTADOR HEADER
============================================ */
.carrito-header-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 7px;
    background: rgba(59, 130, 246, 0.22);
    border: 1px solid rgba(59, 130, 246, 0.35);
    border-radius: 12px;
    font-size: 0.72rem;
    font-weight: 700;
    color: #60a5fa;
}

/* ============================================
   BARRA ENVÍO GRATIS
============================================ */
.carrito-envio-progress {
    padding: 0.875rem 1rem;
    background: rgba(16, 185, 129, 0.07) !important;
    border: 1px solid rgba(16, 185, 129, 0.20) !important;
    border-radius: 12px;
    margin-bottom: 1rem;
}
.carrito-envio-progress.completed {
    background: rgba(16, 185, 129, 0.12) !important;
    border-color: rgba(16, 185, 129, 0.28) !important;
}
.carrito-envio-progress-text {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #86efac !important;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.375rem;
}
.carrito-envio-progress-bar {
    width: 100%;
    height: 6px;
    background: rgba(16, 185, 129, 0.12);
    border-radius: 3px;
    overflow: hidden;
}
.carrito-envio-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #22c55e 0%, #16a34a 100%);
    border-radius: 3px;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   ANIMACIÓN ELIMINAR
============================================ */
.carrito-item.removing {
    opacity: 0;
    transform: translateX(-30px);
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    margin-bottom: 0;
    border-width: 0;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   ITEMS
============================================ */
.carrito-item {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    background: rgba(15, 23, 42, 0.90) !important;
    border: 1px solid rgba(255, 255, 255, 0.07) !important;
    border-radius: 14px;
    margin-bottom: 0.875rem;
    max-height: 200px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 10px -2px rgba(0, 0, 0, 0.45);
}

.carrito-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 3px;
    height: 100%;
    background: linear-gradient(180deg, #60a5fa 0%, #3b82f6 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.carrito-item:hover {
    border-color: rgba(59, 130, 246, 0.28) !important;
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.12), 0 2px 10px -2px rgba(0, 0, 0, 0.45);
    transform: translateX(3px);
}
.carrito-item:hover::before { opacity: 1; }

/* Imagen */
.carrito-item-img {
    width: 78px;
    height: 78px;
    border-radius: 10px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.04) !important;
    border: 1px solid rgba(255, 255, 255, 0.07);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.carrito-item-img img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 0.4rem;
}

/* Info */
.carrito-item-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}

.carrito-item-nombre {
    font-size: 0.9375rem;
    font-weight: 600;
    color: #e2e8f0 !important;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.carrito-item-precio {
    font-size: 1rem;
    font-weight: 700;
    color: #60a5fa !important;
}
.carrito-item-precio-unit {
    font-size: 0.75rem;
    color: #475569 !important;
    font-weight: 400;
}

/* Controles cantidad */
.carrito-item-controles {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
}

.carrito-cantidad-wrapper {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 9px;
    overflow: hidden;
}

.carrito-cantidad-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent !important;
    color: #64748b !important;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}
.carrito-cantidad-btn:hover {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%) !important;
    color: #fff !important;
}
.carrito-cantidad-btn:active { transform: scale(0.92); }

.carrito-cantidad-valor {
    width: 38px;
    text-align: center;
    font-size: 0.875rem;
    font-weight: 600;
    color: #f1f5f9 !important;
    background: rgba(255, 255, 255, 0.04) !important;
    padding: 0.25rem;
    border: none;
}

/* Botón eliminar */
.carrito-item-eliminar {
    width: 32px;
    height: 32px;
    border: 1px solid rgba(239, 68, 68, 0.22) !important;
    background: rgba(239, 68, 68, 0.08) !important;
    color: #f87171 !important;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
}
.carrito-item-eliminar:hover {
    background: #ef4444 !important;
    border-color: #ef4444 !important;
    color: #fff !important;
    transform: scale(1.08);
    box-shadow: 0 4px 14px rgba(239, 68, 68, 0.38);
}

/* ============================================
   RESUMEN
============================================ */
.carrito-resumen {
    background: rgba(15, 23, 42, 0.65) !important;
    border-radius: 14px;
    padding: 1.25rem;
    margin-top: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.07) !important;
}

.carrito-resumen-fila {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.45rem 0;
}
.carrito-resumen-fila.total {
    padding-top: 1rem;
    margin-top: 0.5rem;
    border-top: 1px dashed rgba(255, 255, 255, 0.09);
}

.carrito-resumen-label {
    font-size: 0.9375rem;
    color: #64748b !important;
}
.carrito-resumen-valor {
    font-size: 0.9375rem;
    font-weight: 600;
    color: #cbd5e1 !important;
}

.carrito-resumen-fila.total .carrito-resumen-label {
    font-size: 1.1rem;
    font-weight: 700;
    color: #e2e8f0 !important;
}
.carrito-resumen-fila.total .carrito-resumen-valor {
    font-size: 1.45rem;
    font-weight: 800;
    background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 60%, #1d4ed8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.carrito-envio-gratis {
    color: #86efac !important;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

/* ============================================
   FOOTER
============================================ */
#carritoModal .modal-footer {
    padding: 1.125rem 1.5rem !important;
    background: rgba(8, 13, 26, 0.98) !important;
    border-top: 1px solid rgba(59, 130, 246, 0.13) !important;
    display: flex;
    gap: 0.875rem;
}

/* Botón secundario */
.btn-carrito-secundario {
    flex: 1;
    padding: 0.825rem 1.25rem;
    border: 1px solid rgba(255, 255, 255, 0.11) !important;
    background: rgba(255, 255, 255, 0.04) !important;
    color: #94a3b8 !important;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 11px;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    text-decoration: none !important;
}
.btn-carrito-secundario:hover {
    border-color: rgba(59, 130, 246, 0.40) !important;
    color: #93c5fd !important;
    background: rgba(59, 130, 246, 0.08) !important;
}

/* Botón primario */
.btn-carrito-primario {
    flex: 1.5;
    padding: 0.825rem 1.25rem;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 50%, #1d4ed8 100%) !important;
    color: #fff !important;
    font-size: 0.9rem;
    font-weight: 700;
    border-radius: 11px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    text-decoration: none !important;
    position: relative;
    overflow: hidden;
    box-shadow:
        0 4px 16px -4px rgba(96, 165, 250, 0.55),
        inset 0 1px 0 rgba(255, 255, 255, 0.20);
}
.btn-carrito-primario::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.14), transparent);
    transition: left 0.5s ease;
}
.btn-carrito-primario:hover {
    transform: translateY(-2px) !important;
    box-shadow:
        0 10px 30px -6px rgba(96, 165, 250, 0.70),
        inset 0 1px 0 rgba(255, 255, 255, 0.28) !important;
    color: #fff !important;
}
.btn-carrito-primario:hover::before { left: 100%; }
.btn-carrito-primario:disabled {
    background: rgba(71, 85, 105, 0.45) !important;
    border-color: rgba(255, 255, 255, 0.05) !important;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* ============================================
   BADGE NAVBAR
============================================ */
.cart-badge-premium {
    position: absolute;
    top: -8px;
    right: -8px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: #fff;
    font-size: 0.68rem;
    font-weight: 700;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.45);
    animation: pulsarBadge 2s infinite;
}
@keyframes pulsarBadge {
    0%, 100% { transform: scale(1); }
    50%       { transform: scale(1.12); }
}

/* ============================================
   TOAST
============================================ */
.toast-carrito {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: rgba(8, 13, 26, 0.94) !important;
    -webkit-backdrop-filter: blur(20px) saturate(140%);
            backdrop-filter: blur(20px) saturate(140%);
    border: 1px solid rgba(59, 130, 246, 0.22);
    border-radius: 16px;
    box-shadow: 0 20px 50px -10px rgba(0, 0, 0, 0.70), 0 0 30px -8px rgba(96, 165, 250, 0.18);
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    z-index: 9999;
    transform: translateX(120%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.toast-carrito.show { transform: translateX(0); }

.toast-carrito-icon {
    width: 46px;
    height: 46px;
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.2rem;
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.35);
    flex-shrink: 0;
}
.toast-carrito-content h4 {
    font-size: 0.9375rem;
    font-weight: 600;
    color: #f1f5f9 !important;
    margin-bottom: 0.2rem;
}
.toast-carrito-content p {
    font-size: 0.8125rem;
    color: #64748b !important;
    margin: 0;
}

/* ============================================
   RESPONSIVE
============================================ */
@media (max-width: 576px) {
    #carritoModal .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }
    #carritoModal .modal-content { border-radius: 18px !important; }
    #carritoModal .modal-header  { padding: 1.25rem; }
    #carritoModal .modal-title   { font-size: 1.05rem; }
    #carritoModal .modal-body    { padding: 1rem !important; max-height: 50vh; }
    .carrito-item                { padding: 0.875rem; }
    .carrito-item-img            { width: 60px; height: 60px; }
    .carrito-item-nombre         { font-size: 0.875rem; }
    .carrito-cantidad-btn        { width: 28px; height: 28px; }
    .carrito-cantidad-valor      { width: 32px; }
    #carritoModal .modal-footer  { flex-direction: column; padding: 1rem !important; }
    .btn-carrito-secundario,
    .btn-carrito-primario        { flex: none; width: 100%; }
    .toast-carrito               { left: 1rem; right: 1rem; bottom: 1rem; }
    .carrito-envio-progress      { padding: 0.75rem; }
    .carrito-envio-progress-text { font-size: 0.75rem; }
    .carrito-header-count        { min-width: 20px; height: 20px; font-size: 0.68rem; }
}
