/**
 * Estilos mejorados para el sidebar del carrito
 * 
 * @package YeshuaTech
 */

/* ============================================
   OVERLAY DEL CARRITO
   ============================================ */
.yeshua-cart-overlay {
    z-index: 9998;
    backdrop-filter: blur(4px);
    transition: opacity 0.3s ease-in-out;
}

.yeshua-cart-overlay:not(.hidden) {
    opacity: 1;
}

/* ============================================
   SIDEBAR DEL CARRITO
   ============================================ */
.yeshua-mini-cart-sidebar {
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    max-height: 100vh !important;
    background: #fff;
}

/* ============================================
   HEADER DEL CARRITO
   ============================================ */
.yeshua-mini-cart-sidebar > .flex-none:first-child {
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    z-index: 10;
}

/* ============================================
   CONTENIDO SCROLLEABLE
   ============================================ */
.yeshua-mini-cart-sidebar > .flex-1 {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    -webkit-overflow-scrolling: touch;
}

/* Scrollbar personalizado */
.yeshua-mini-cart-sidebar > .flex-1::-webkit-scrollbar {
    width: 6px;
}

.yeshua-mini-cart-sidebar > .flex-1::-webkit-scrollbar-track {
    background: #f3f4f6;
}

.yeshua-mini-cart-sidebar > .flex-1::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 10px;
}

.yeshua-mini-cart-sidebar > .flex-1::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* ============================================
   LISTA DE PRODUCTOS
   ============================================ */
.yeshua-mini-cart-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.yeshua-mini-cart-item {
    transition: all 0.2s ease;
    padding: 0.5rem 0;
}

.yeshua-mini-cart-item:hover {
    background-color: #f9fafb;
    border-radius: 0.5rem;
    padding: 0.75rem;
    margin: 0 -0.75rem;
}

/* Imagen del producto */
.yeshua-mini-cart-item img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 0.75rem;
    border: 1px solid #e5e7eb;
    transition: transform 0.2s ease;
}

.yeshua-mini-cart-item:hover img {
    transform: scale(1.05);
}

/* Título del producto */
.yeshua-mini-cart-item h4,
.yeshua-mini-cart-item a {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Botón eliminar */
.yeshua-mini-cart-item .remove_from_cart_button {
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.yeshua-mini-cart-item .remove_from_cart_button:hover {
    transform: scale(1.1);
    background-color: #fee2e2 !important;
}

/* ============================================
   CONTROLES DE CANTIDAD
   ============================================ */
.yeshua-mini-cart-item .qty-input {
    -moz-appearance: textfield;
    background: transparent;
    font-weight: 600;
}

.yeshua-mini-cart-item .qty-input::-webkit-outer-spin-button,
.yeshua-mini-cart-item .qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.yeshua-mini-cart-item .qty-minus,
.yeshua-mini-cart-item .qty-plus {
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.yeshua-mini-cart-item .qty-minus:hover,
.yeshua-mini-cart-item .qty-plus:hover {
    background-color: #e5e7eb;
}

.yeshua-mini-cart-item .qty-minus:active,
.yeshua-mini-cart-item .qty-plus:active {
    transform: scale(0.95);
}

/* ============================================
   RESUMEN DEL CARRITO (FOOTER FIJO)
   ============================================ */
#yeshua-cart-summary {
    position: sticky !important;
    bottom: 0 !important;
    background: #fff !important;
    border-top: 2px solid #e5e7eb !important;
    flex-shrink: 0 !important;
    overflow: visible !important;
    max-height: none !important;
    padding: 1.5rem 1.5rem !important;
    margin-top: auto !important;
    box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.05);
    z-index: 20;
}

/* ============================================
   BOTÓN PROCEDER AL PAGO
   ============================================ */
.yeshua-checkout-button,
#yeshua-proceed-checkout {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    text-align: center !important;
    text-decoration: none !important;
    transition: all 0.2s ease !important;
    position: relative !important;
    z-index: 10000 !important;
    width: 100% !important;
    max-width: 100% !important;
    margin-top: 1rem !important;
    margin-bottom: 0 !important;
    padding: 1rem 1.5rem !important;
    background: linear-gradient(to right, #f97316, #ea580c) !important;
    background-color: #f97316 !important;
    color: #fff !important;
    border-radius: 0.75rem !important;
    font-weight: 700 !important;
    font-size: 1rem !important;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06) !important;
    border: none !important;
    min-height: 48px !important;
    line-height: 1.5 !important;
    cursor: pointer !important;
    pointer-events: auto !important;
}

.yeshua-checkout-button:hover,
#yeshua-proceed-checkout:hover {
    transform: translateY(-2px) !important;
    color: #fff !important;
    background: linear-gradient(to right, #ea580c, #c2410c) !important;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05) !important;
}

.yeshua-checkout-button:active,
#yeshua-proceed-checkout:active {
    transform: translateY(0) !important;
}

/* ============================================
   ESTADO DE ACTUALIZACIÓN
   ============================================ */
.yeshua-mini-cart-sidebar.updating {
    opacity: 0.7;
    pointer-events: none;
    position: relative;
}

.yeshua-mini-cart-sidebar.updating::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 3px solid #f3f4f6;
    border-top-color: #f97316;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    z-index: 100;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============================================
   CARRITO VACÍO
   ============================================ */
.yeshua-mini-cart-sidebar .flex.flex-col.items-center {
    min-height: 300px;
    justify-content: center;
}

/* ============================================
   ANIMACIONES
   ============================================ */
@keyframes slideInRight {
    from {
        transform: translateX(100%);
    }
    to {
        transform: translateX(0);
    }
}

.yeshua-mini-cart-sidebar:not(.translate-x-full) {
    animation: slideInRight 0.3s ease-out;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 640px) {
    .yeshua-mini-cart-sidebar {
        width: 100% !important;
        max-width: 100% !important;
        max-height: 100vh !important;
    }
    
    .yeshua-mini-cart-item img {
        width: 60px;
        height: 60px;
    }
    
    #yeshua-cart-summary {
        padding: 1rem !important;
        padding-bottom: max(1rem, env(safe-area-inset-bottom)) !important;
    }
    
    .yeshua-mini-cart-sidebar > .flex-1 {
        max-height: calc(100vh - 350px) !important;
        padding-bottom: 1rem !important;
    }
}

/* ============================================
   ESTILOS ADICIONALES
   ============================================ */
.yeshua-mini-cart-item .line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Precio del producto */
#yeshua-cart-summary .text-amber-600 {
    color: #f97316;
}

/* Enlace ver carrito completo */
#yeshua-cart-summary a:not(.yeshua-checkout-button) {
    transition: color 0.2s ease;
}

#yeshua-cart-summary a:not(.yeshua-checkout-button):hover {
    color: #1f2937;
}
