/* ------------------------------- MODAL DEL CARRITO ------------------------------- */

.cart-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.cart-modal-overlay.active {
    display: block;
    opacity: 1;
}

.cart-modal {
    position: fixed;
    top: 0;
    right: -100%;
    width: 100%;
    max-width: 350px;
    height: 100%;
    background: white;
    z-index: 2001;
    display: flex;
    flex-direction: column;
    transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -5px 0 30px rgba(0, 0, 0, 0.15);
}

.cart-modal.active {
    right: 0;
}

.cart-modal-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--light-gray);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--primary-color);
    color: white;
    flex-shrink: 0;
}

.cart-modal-header h3 {
    margin: 0;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.cart-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    color: white;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.cart-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.cart-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    overflow-x: hidden;
}

.cart-items {
    padding: 15px;
    min-height: 200px;
}

.cart-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--medium-gray);
}

.cart-empty i {
    font-size: 3rem;
    margin-bottom: 15px;
    opacity: 0.3;
}

.cart-empty p {
    font-size: 1rem;
    margin-bottom: 15px;
}

.btn-primary {
    display: inline-block;
    background: var(--primary-color);
    color: white;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    text-decoration: none;
    font-size: 0.9rem;
    transition: var(--transition);
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
}

/* Productos más compactos */
.cart-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--light-gray);
    transition: var(--transition);
    position: relative;
}

.cart-item:hover {
    background: rgba(26, 86, 219, 0.03);
}

.cart-item:last-child {
    border-bottom: none;
}

.cart-item-image {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
    border: 1px solid var(--light-gray);
}

.cart-item-details {
    flex: 1;
    min-width: 0;
}

.cart-item-title {
    font-weight: 600;
    margin-bottom: 5px;
    font-size: 0.85rem;
    color: var(--dark-color);
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cart-item-price {
    color: var(--primary-color);
    font-weight: 700;
    font-size: 0.95rem;
    margin-bottom: 5px;
}

.cart-item-stock{
    font-size: .8rem;
    color: var(--dark-color);
    margin-bottom: 5px;
}

.cart-item-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.quantity-control {
    display: flex;
    align-items: center;
    border: 1px solid var(--light-gray);
    border-radius: var(--radius-sm);
    overflow: hidden;
    width: fit-content;
}

.quantity-btn {
    width: 28px;
    height: 28px;
    background: white;
    border: none;
    color: var(--dark-color);
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.quantity-btn:hover {
    background: var(--light-gray);
}

.quantity-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.quantity-input {
    width: 35px;
    height: 28px;
    border: none;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 600;
    background: white;
    padding: 0;
    -moz-appearance: textfield;
}

.quantity-input::-webkit-outer-spin-button,
.quantity-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.cart-item-remove {
    background: none;
    border: none;
    color: var(--danger-color);
    cursor: pointer;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    margin-left: auto;
}

.cart-item-remove:hover {
    background: var(--danger-color);
    color: white;
}

.cart-item-remove i {
    font-size: 0.8rem;
}

.cart-modal-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--light-gray);
    background: white;
    flex-shrink: 0;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

.cart-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    font-size: 1rem;
}

.cart-total span:first-child {
    font-weight: 600;
    color: var(--dark-color);
}

.cart-total-amount {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary-color);
}

.cart-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.btn-view-cart,
.btn-checkout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-align: center;
    padding: 10px;
    border-radius: var(--radius-md);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: var(--transition);
    border: 2px solid transparent;
}

.btn-view-cart {
    background: var(--medium-gray);
    color: white;
}

.btn-view-cart:hover {
    background: var(--secondary-dark);
    transform: translateY(-2px);
}

.btn-checkout {
    background: var(--primary-color);
    color: white;
}

.btn-checkout:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(26, 86, 219, 0.2);
}

/* Toast notifications */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--success-color);
    color: white;
    padding: 12px 20px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 3000;
    animation: slideIn 0.3s ease;
    box-shadow: var(--shadow-lg);
}

.toast.error {
    background: var(--danger-color);
}

.toast.info {
    background: var(--info-color);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Animaciones del contador del carrito */
@keyframes cartItemIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.cart-item {
    animation: cartItemIn 0.3s ease-out;
}

@keyframes cartBounce {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
    }
}

.cart-count.pulse {
    animation: cartBounce 0.3s ease;
}

/* ------------------------------- MEDIA QUERIES PARA EL CARRITO ------------------------------- */

@media (max-width: 768px) {
    .cart-modal {
        max-width: 90%;
    }
    
    .cart-item {
        padding: 10px 0;
    }
    
    .cart-item-image {
        width: 50px;
        height: 50px;
    }
    
    .cart-item-title {
        font-size: 0.8rem;
    }
    
    .cart-item-price {
        font-size: 0.9rem;
    }
    
    .quantity-btn {
        width: 25px;
        height: 25px;
        font-size: 0.8rem;
    }
    
    .quantity-input {
        width: 30px;
        height: 25px;
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .cart-modal-header {
        padding: 12px 15px;
    }
    
    .cart-modal-header h3 {
        font-size: 1.1rem;
    }
    
    .cart-items {
        padding: 12px 15px;
    }
    
    .cart-modal-footer {
        padding: 12px 15px;
    }
    
    .cart-total {
        font-size: 0.95rem;
    }
    
    .cart-total-amount {
        font-size: 1.1rem;
    }
    
    .btn-view-cart,
    .btn-checkout {
        font-size: 0.85rem;
        padding: 8px;
    }
}

/* ------ toasts de mensajes ------ */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--dark-color);
    color: white;
    padding: 18px 30px;
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 30px rgba(0,0,0,0.25);
    z-index: 10000;
    display: flex;
    align-items: center;
    gap: 15px;
    max-width: 400px;
    width: 90%;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast i {
    font-size: 1.5rem;
}

.toast.success {
    background: var(--success-color);
}

.toast.error {
    background: var(--danger-color);
}

.toast.info {
    background: var(--info-color);
}

.toast.warning {
    background: var(--warning-color);
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 700;
    margin-bottom: 4px;
    font-size: 1.1rem;
}

.toast-message {
    font-size: 0.95rem;
    opacity: 0.9;
}

.toast-close {
    background: transparent;
    border: none;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    opacity: 0.7;
    transition: var(--transition);
    padding: 5px;
}

.toast-close:hover {
    opacity: 1;
    transform: scale(1.1);
}

.btn-add-cart:hover:not(:disabled) {
    background: var(--primary-dark);
    color: #fff;
}

.btn-add-cart:disabled {
    background: var(--medium-gray);
    cursor: not-allowed;
    color: #fff;
}