/**
 * Floating Cart Button - Minimal Design
 * Fully responsive for iOS, Android, and Desktop
 */

.floating-cart-btn {
    position: fixed;
    bottom: calc(20px + env(safe-area-inset-bottom));
    right: calc(20px + env(safe-area-inset-right));
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1a237e 0%, #283593 100%);
    color: #ffffff;
    border: none;
    display: flex;
    justify-content: center;
    align-items: center;
    /* z-index: above navbar (101) but below modals/menus (102+) */
    z-index: 1000;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(26, 35, 126, 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
    padding: 0;
    margin: 0;
    touch-action: manipulation;
}

.floating-cart-btn:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 6px 20px rgba(26, 35, 126, 0.5);
}

.floating-cart-btn:active {
    transform: translateY(0) scale(0.98);
    box-shadow: 0 2px 8px rgba(26, 35, 126, 0.3);
}

.floating-cart-btn:focus {
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

.floating-cart-btn .cart-icon {
    width: 24px;
    height: 24px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
    transition: transform 0.2s ease;
}

.floating-cart-btn:active .cart-icon {
    transform: scale(0.9);
}

.floating-cart-btn .cart-count {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: #ffffff;
    width: 22px;
    height: 22px;
    font-size: 11px;
    font-weight: 700;
    border-radius: 50%;
    display: none;
    justify-content: center;
    align-items: center;
    border: 2px solid #ffffff;
    min-width: 22px;
    padding: 0;
    box-sizing: border-box;
    line-height: 1;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
    animation: pulse 0.3s ease;
}

@keyframes pulse {
    0% {
        transform: scale(0.8);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

.floating-cart-btn .cart-count[data-count]:not([data-count="0"]):not(:empty) {
    display: flex;
}

/* Desktop - Top Right Position (below navbar/hamburger menu) */
@media (min-width: 992px) {
    .floating-cart-btn {
        /* Position below navbar - navbar has 2.7rem (38px) padding + hamburger button (~30px) + margin */
        /* Using 90px to ensure clear separation from hamburger menu */
        top: calc(90px + env(safe-area-inset-top));
        right: calc(20px + env(safe-area-inset-right));
        bottom: auto;
        width: 52px;
        height: 52px;
        box-shadow: 0 3px 12px rgba(26, 35, 126, 0.35);
        /* Ensure it's above navbar (z-index: 101) but below modals/menus (z-index: 102+) */
        z-index: 1000;
    }
    
    .floating-cart-btn .cart-icon {
        width: 22px;
        height: 22px;
    }
    
    .floating-cart-btn .cart-count {
        width: 20px;
        height: 20px;
        font-size: 10px;
        top: -3px;
        right: -3px;
        border-width: 2px;
    }
}

/* Tablet Adjustments */
@media (min-width: 768px) and (max-width: 991px) {
    .floating-cart-btn {
        width: 54px;
        height: 54px;
        bottom: calc(18px + env(safe-area-inset-bottom));
        right: calc(18px + env(safe-area-inset-right));
    }
    
    .floating-cart-btn .cart-icon {
        width: 23px;
        height: 23px;
    }
}

/* Mobile - Bottom Right (Default) */
@media (max-width: 767px) {
    .floating-cart-btn {
        width: 56px;
        height: 56px;
        bottom: calc(20px + env(safe-area-inset-bottom));
        right: calc(20px + env(safe-area-inset-right));
        /* Ensure it's above other content */
        z-index: 1000;
    }
    
    /* Prevent accidental taps on scroll */
    .floating-cart-btn {
        touch-action: manipulation;
        -webkit-touch-callout: none;
    }
}

/* Small Mobile Devices */
@media (max-width: 360px) {
    .floating-cart-btn {
        width: 52px;
        height: 52px;
        bottom: calc(16px + env(safe-area-inset-bottom));
        right: calc(16px + env(safe-area-inset-right));
    }
    
    .floating-cart-btn .cart-icon {
        width: 22px;
        height: 22px;
    }
    
    .floating-cart-btn .cart-count {
        width: 20px;
        height: 20px;
        font-size: 10px;
        border-width: 1.5px;
    }
}

/* iOS Safe Area Support */
@supports (padding: env(safe-area-inset-bottom)) {
    .floating-cart-btn {
        bottom: calc(20px + env(safe-area-inset-bottom));
        right: calc(20px + env(safe-area-inset-right));
    }
    
    @media (min-width: 992px) {
        .floating-cart-btn {
            top: calc(90px + env(safe-area-inset-top));
            right: calc(20px + env(safe-area-inset-right));
            bottom: auto;
        }
    }
}

/* Android Chrome Address Bar Handling */
@media (max-width: 767px) {
    .floating-cart-btn {
        /* Use viewport units that account for address bar */
        bottom: max(20px, calc(20px + env(safe-area-inset-bottom)));
    }
}

/* Landscape Mode Adjustments */
@media (max-width: 767px) and (orientation: landscape) {
    .floating-cart-btn {
        width: 50px;
        height: 50px;
        bottom: calc(15px + env(safe-area-inset-bottom));
        right: calc(15px + env(safe-area-inset-right));
    }
    
    .floating-cart-btn .cart-icon {
        width: 20px;
        height: 20px;
    }
    
    .floating-cart-btn .cart-count {
        width: 18px;
        height: 18px;
        font-size: 9px;
        top: -2px;
        right: -2px;
    }
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .floating-cart-btn {
        box-shadow: 0 4px 16px rgba(26, 35, 126, 0.35);
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .floating-cart-btn {
        transition: none;
    }
    
    .floating-cart-btn:hover {
        transform: none;
    }
    
    .floating-cart-btn:active {
        transform: none;
    }
    
    .floating-cart-btn .cart-count {
        animation: none;
    }
}

/* Dark Mode Support (if needed) */
@media (prefers-color-scheme: dark) {
    .floating-cart-btn {
        box-shadow: 0 4px 16px rgba(26, 35, 126, 0.5);
    }
}

/* Accessibility - Focus Visible */
.floating-cart-btn:focus-visible {
    outline: 3px solid rgba(255, 255, 255, 0.8);
    outline-offset: 3px;
}

/* Prevent text selection on button */
.floating-cart-btn * {
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
}

/* Loading State (if cart is initializing) */
.floating-cart-btn.loading {
    opacity: 0.7;
    pointer-events: none;
}

.floating-cart-btn.loading .cart-icon {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}
