/* Floating Cart Button - Always Visible */
.floating-cart-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background: var(--vino-tinto-medio);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 2px 4px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    transition: all 0.3s ease;
    border: none;
    font-size: 1.3rem;
}

.floating-cart-button:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(138, 0, 40, 0.25), 0 3px 6px rgba(0, 0, 0, 0.1);
    background: var(--vino-tinto-oscuro);
}

.floating-cart-button:active {
    transform: scale(0.95);
}

/* Cart Icon Animation */
.floating-cart-button .cart-icon {
    position: relative;
    transition: transform 0.3s ease;
}

.floating-cart-button:hover .cart-icon {
    transform: translateY(-2px);
}

/* Item Count Badge */
.floating-cart-count {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--dorado-acento);
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    min-width: 22px;
    height: 22px;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    animation: bounceIn 0.3s ease;
}

.floating-cart-count.pulse {
    animation: pulse 0.6s ease;
}

/* Total Price Display */
.floating-cart-total {
    position: absolute;
    bottom: -30px;
    right: 0;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 4px 12px;
    border-radius: 16px;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease;
    pointer-events: none;
}

.floating-cart-button:hover .floating-cart-total {
    opacity: 1;
    transform: translateY(0);
}

/* Quick Cart Preview */
.floating-cart-preview {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 320px;
    max-height: 400px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    z-index: 999;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s ease;
    pointer-events: none;
    overflow: hidden;
}

.floating-cart-preview.show {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.preview-header {
    background: var(--vino-tinto-medio);
    color: white;
    padding: 16px;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.close-preview {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
}

.close-preview:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.close-preview i {
    font-size: 16px;
}

.preview-items {
    max-height: 250px;
    overflow-y: auto;
    padding: 12px;
}

.preview-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    margin-bottom: 8px;
    background: var(--crema-claro);
    border-radius: 8px;
    font-size: 0.9rem;
}

.preview-item-name {
    flex: 1;
    font-weight: 500;
    color: var(--vino-tinto-oscuro);
}

.preview-item-details {
    display: flex;
    align-items: center;
    gap: 12px;
}

.preview-item-qty {
    color: var(--texto-oscuro);
    font-size: 0.85rem;
}

.preview-item-price {
    font-weight: 600;
    color: var(--vino-tinto-medio);
}

.preview-footer {
    padding: 16px;
    border-top: 1px solid var(--crema-oscuro);
    background: var(--crema-claro);
}

.preview-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--vino-tinto-medio);
}

.preview-actions {
    display: flex;
    gap: 8px;
}

.preview-actions button {
    flex: 1;
    padding: 12px 16px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-view-full-cart {
    background: var(--vino-tinto-medio);
    color: white;
    font-weight: 600;
    border: 1px solid var(--vino-tinto-claro);
    box-shadow: 0 2px 8px rgba(138, 0, 40, 0.2);
}

.btn-view-full-cart:hover {
    background: var(--vino-tinto-oscuro);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(138, 0, 40, 0.3);
}

.btn-checkout {
    background: #25D366; /* WhatsApp Green */
    color: white;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(37, 211, 102, 0.3);
}

.btn-checkout:hover {
    background: #128C7E; /* Darker WhatsApp Green */
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.4);
}

.btn-checkout i {
    font-size: 1rem;
    margin-right: 4px;
}

/* Ensure no X icon appears in checkout button */
.btn-checkout .fa-times {
    display: none !important;
}

/* Empty Cart State */
.preview-empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--texto-oscuro);
}

.preview-empty i {
    font-size: 3rem;
    color: var(--crema-oscuro);
    margin-bottom: 12px;
}

/* Mobile Adjustments */
@media (max-width: 768px) {
    .floating-cart-button {
        bottom: 70px; /* Above mobile navigation if exists */
        right: 15px;
        width: 56px;
        height: 56px;
    }
    
    .floating-cart-preview {
        width: calc(100vw - 30px);
        right: 15px;
        bottom: 140px;
        max-height: 60vh;
    }
    
    .preview-items {
        max-height: calc(60vh - 180px);
    }
}

/* Animations */
@keyframes bounceIn {
    0% {
        transform: scale(0);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    }
    50% {
        transform: scale(1.15);
        box-shadow: 0 4px 8px rgba(212, 175, 55, 0.4);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    }
}

/* Add to Cart Animation */
@keyframes flyToCart {
    0% {
        opacity: 1;
        transform: translate(0, 0) scale(1);
    }
    50% {
        opacity: 0.8;
        transform: translate(var(--fly-x, 100px), var(--fly-y, -100px)) scale(0.5);
    }
    100% {
        opacity: 0;
        transform: translate(var(--fly-x, 100px), var(--fly-y, -100px)) scale(0.1);
    }
}

.product-flying {
    position: fixed;
    pointer-events: none;
    z-index: 1001;
    animation: flyToCart 0.8s ease-in-out;
}

/* Scroll Behavior */
.floating-cart-button.scrolled {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2), 0 3px 8px rgba(0, 0, 0, 0.15);
}

/* Hide when main cart is open */
body.cart-open .floating-cart-button {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.8);
}

/* Notification Integration */
.floating-cart-notification {
    position: absolute;
    top: -60px;
    right: 0;
    background: var(--vino-tinto-oscuro);
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.85rem;
    white-space: nowrap;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.floating-cart-notification.show {
    opacity: 1;
    transform: translateY(0);
}

.floating-cart-notification::after {
    content: '';
    position: absolute;
    bottom: -6px;
    right: 20px;
    width: 12px;
    height: 12px;
    background: var(--vino-tinto-oscuro);
    transform: rotate(45deg);
}

/* Loading State */
.floating-cart-button.loading {
    pointer-events: none;
}

.floating-cart-button.loading .cart-icon {
    animation: spin 1s linear infinite;
}

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

/* Success State */
.floating-cart-button.success {
    background: #27ae60;
}

.floating-cart-button.success .cart-icon::before {
    content: '\f00c';
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
}

/* Highlight on Add */
.floating-cart-button.highlight {
    animation: cartHighlight 0.6s ease;
}

@keyframes cartHighlight {
    0%, 100% {
        transform: scale(1);
        background: var(--vino-tinto-medio);
    }
    50% {
        transform: scale(1.1);
        background: var(--dorado-acento);
    }
}