/**
 * Floating Basket Styles
 *
 * @package Gerrards_Utilities
 */

/* ===================================
   FLOATING BASKET ICON
   =================================== */

.floating-basket-icon {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 999;
    cursor: pointer;
    transition: all 0.3s ease;
}

.floating-basket-icon:hover {
    transform: scale(1.1);
}

.basket-icon-container {
    position: relative;
    width: 60px;
    height: 60px;
    background: #16284f;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(22, 40, 79, 0.3);
    transition: all 0.3s ease;
}

.basket-icon-container:hover {
    background: #1a2d56;
    box-shadow: 0 6px 25px rgba(22, 40, 79, 0.4);
}

.basket-icon {
    width: 24px;
    height: 24px;
    filter: brightness(0) invert(1);
    flex-shrink: 0;
}

.basket-count {
    position: absolute;
    top: -8px;
    right: -8px;
    min-width: 20px;
    height: 20px;
    background: #dc2626;
    color: #ffffff;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    padding: 0 6px;
    animation: bounceIn 0.3s ease;
}

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

/* ===================================
   FLOATING BASKET OVERLAY
   =================================== */

.floating-basket-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.floating-basket-overlay.open {
    opacity: 1;
    visibility: visible;
}

.floating-basket-panel {
    position: absolute;
    top: 0;
    right: 0;
    width: 450px;
    height: 100%;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    overflow: hidden;
}

/* Admin bar adjustment */
.admin-bar .floating-basket-panel {
    top: 32px;
    height: calc(100% - 32px);
}

/* Admin bar adjustment for mobile */
@media screen and (max-width: 782px) {
    .admin-bar .floating-basket-panel {
        top: 46px;
        height: calc(100% - 46px);
    }
}

.floating-basket-overlay.open .floating-basket-panel {
    transform: translateX(0);
}

/* ===================================
   BASKET HEADER
   =================================== */

.basket-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #e5e7eb;
    background: #ffffff;
    z-index: 1;
}

.basket-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #16284f;
}

.close-basket {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    margin: -8px;
    border-radius: 6px;
    transition: all 0.2s ease;
    color: #6b7280;
}

.close-basket:hover {
    background: #f3f4f6;
    color: #374151;
}

.close-basket svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* ===================================
   BASKET CONTENT
   =================================== */

.basket-content {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    position: relative;
}

.basket-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: #6b7280;
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e5e7eb;
    border-top: 3px solid #16284f;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 12px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.basket-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: #6b7280;
    text-align: center;
    padding: 24px;
}

.basket-empty p {
    margin: 0;
    font-size: 16px;
}

/* ===================================
   BASKET ITEMS
   =================================== */

.basket-items {
    padding: 12px 0;
}

.basket-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 24px;
    border-bottom: 1px solid #f3f4f6;
    transition: background 0.2s ease;
}

.basket-item:hover {
    background: #f9fafb;
}

.basket-item:last-child {
    border-bottom: none;
}

.item-image {
    flex-shrink: 0;
    width: 60px;
    height: 60px;
    overflow: hidden;
    border-radius: 8px;
    background: #f3f4f6;
}

.item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.item-details {
    flex: 1;
    min-width: 0;
}

.item-name {
    font-size: 14px;
    font-weight: 500;
    color: #16284f;
    margin: 0 0 4px 0;
    line-height: 1.4;
}

.item-name a {
    color: inherit;
    text-decoration: none;
}

.item-name a:hover {
    color: #1a2d56;
}

.item-variations {
    font-size: 12px;
    color: #6b7280;
    margin: 0 0 8px 0;
}

.item-variation {
    display: inline-block;
    margin-right: 8px;
}

.item-variation:last-child {
    margin-right: 0;
}

.item-price {
    font-size: 14px;
    font-weight: 600;
    color: #16284f;
    margin: 0;
}

/* Ensure subtotal matches price styling when shown alone */
.item-subtotal {
    font-size: 14px;
    font-weight: 600;
    color: #16284f;
    margin: 0;
}

/* Per-unit price display (shown when qty > 1) */
.floating-basket-panel .item-unit-price {
    font-size: 0.85em;
    font-weight: 400;
    color: #6b7280;
    margin-left: 4px;
}

.item-controls {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

.quantity-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    border-radius: 6px;
    overflow: visible;
}

.quantity-btn {
    width: 28px;
    height: 28px;
    border: 1px solid #e5e7eb;
    background: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
    transition: all 0.2s ease;
    font-size: 14px;
    font-weight: 500;
    border-radius: 4px;
}

.quantity-btn:hover {
    background: #f3f4f6;
    color: #374151;
    border-color: #d1d5db;
}

.quantity-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.quantity-input {
    width: 50px;
    height: 32px;
    border: 1px solid #e5e7eb;
    background: #ffffff;
    text-align: center;
    font-size: 14px;
    font-weight: 500;
    color: #16284f;
    border-radius: 4px;
    -moz-appearance: textfield;
}

.quantity-input::-webkit-outer-spin-button,
.quantity-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.remove-item {
    background: none;
    border: none;
    cursor: pointer;
    color: #dc2626;
    font-size: 12px;
    text-decoration: underline;
    padding: 4px 0;
}

.remove-item:hover {
    color: #b91c1c;
}

/* ===================================
   BASKET FOOTER
   =================================== */

.basket-footer {
    padding: 24px;
    border-top: 1px solid #e5e7eb;
    background: #ffffff;
    z-index: 1;
}

.basket-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 16px 0;
    border-top: 2px solid #16284f;
}

.total-label {
    font-size: 16px;
    font-weight: 600;
    color: #16284f;
}

.total-amount {
    font-size: 18px;
    font-weight: 700;
    color: #16284f;
}

.basket-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.basket-actions .btn-primary,
.basket-actions .btn-secondary {
    width: 100%;
    padding: 14px 24px;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-block;
}

.btn-primary {
    background: #16284f;
    color: #ffffff;
}

.btn-primary:hover {
    background: #1a2d56;
    color: #ffffff;
}

.btn-secondary {
    background: #f3f4f6;
    color: #16284f;
    border: 1px solid #e5e7eb;
}

.btn-secondary:hover {
    background: #e5e7eb;
    color: #16284f;
}

.continue-shopping {
    order: 3;
}

.view-basket {
    order: 2;
}

.checkout {
    order: 1;
}

/* ===================================
   RESPONSIVE DESIGN
   =================================== */

@media (max-width: 768px) {
    .floating-basket-icon {
        bottom: 20px;
        right: 20px;
    }
    
    .basket-icon-container {
        width: 50px;
        height: 50px;
    }
    
    .basket-icon {
        width: 20px;
        height: 20px;
    }
    
    .basket-count {
        top: -6px;
        right: -6px;
        min-width: 18px;
        height: 18px;
        font-size: 11px;
    }
    
    .floating-basket-panel {
        width: 100%;
        max-width: 400px;
    }
    
    .basket-header {
        padding: 16px 20px;
    }
    
    .basket-item {
        padding: 12px 20px;
    }
    
    .item-image {
        width: 50px;
        height: 50px;
    }
    
    .basket-footer {
        padding: 20px;
    }
}

@media (max-width: 480px) {
    .floating-basket-panel {
        width: 100%;
        max-width: none;
    }
    
    .item-details {
        min-width: 0;
    }
    
    .item-name {
        font-size: 13px;
    }
    
    .item-price {
        font-size: 13px;
    }
    
    .item-subtotal {
        font-size: 13px;
    }
    
    .basket-actions {
        gap: 8px;
    }
    
    .basket-actions .btn-primary,
    .basket-actions .btn-secondary {
        padding: 12px 20px;
        font-size: 13px;
    }
}

/* ===================================
   UTILITIES
   =================================== */

.hidden {
    display: none !important;
}

.loading {
    pointer-events: none;
    opacity: 0.7;
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ===================================
   PRICE UPDATE ANIMATIONS
   =================================== */

/* Price animation classes for live updates */
.price-updating {
    transition: all 0.3s ease;
    opacity: 0.7;
}

/* Price change animations - scope to floating basket only to avoid overriding site-wide animations */
/* Global rules removed; see scoped rules below for .floating-basket-panel */

/* Basket item specific price animations */
.basket-item .item-price.gbpm-price-animation,
.basket-item .item-subtotal.gbpm-price-animation {
    padding: 2px 4px;
    border-radius: 2px;
}

/* Animation for basket total updates */
.basket-total .total-amount.gbpm-price-animation {
    font-weight: bold;
    border-radius: 2px;
    padding: 2px 4px;
}

/* Ensure animations work on light backgrounds */
.floating-basket-panel .gbpm-price-animation.price-up {
    background-color: rgba(76, 175, 80, 0.2) !important;
}

.floating-basket-panel .gbpm-price-animation.price-down {
    background-color: rgba(244, 67, 54, 0.2) !important;
}

/* Loading states for price updates */
.basket-items.updating-prices {
    position: relative;
}

.basket-items.updating-prices::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    z-index: 10;
    pointer-events: none;
}

.basket-items.updating-prices::after {
    content: 'Updating prices...';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 11;
    font-size: 12px;
    color: #666;
    font-weight: 500;
}