/**
 * Developer PWA - WooCommerce Styles
 */

/* CSS Variables */
:root {
    --pwa-cart-width: 380px;
    --pwa-cart-button-size: 56px;
}

/* Floating Cart Button */
.pwa-cart-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: var(--pwa-cart-button-size);
    height: var(--pwa-cart-button-size);
    background: var(--pwa-primary);
    color: #fff;
    border: none;
    border-radius: 50%;
    box-shadow: 0 4px 15px var(--pwa-shadow);
    cursor: pointer;
    z-index: 999990;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--pwa-transition);
}

.pwa-cart-button:hover {
    background: var(--pwa-primary-hover);
    transform: scale(1.05);
}

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

.pwa-cart-button svg {
    width: 24px;
    height: 24px;
}

.pwa-cart-count {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 22px;
    height: 22px;
    background: var(--pwa-error);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
}

.pwa-cart-count:empty,
.pwa-cart-count[data-count="0"] {
    display: none;
}

/* Cart Drawer */
.pwa-cart-drawer {
    position: fixed;
    top: 0;
    right: -100%;
    width: var(--pwa-cart-width);
    max-width: 100%;
    height: 100%;
    background: var(--pwa-background);
    box-shadow: -4px 0 20px var(--pwa-shadow);
    z-index: 999999;
    display: flex;
    flex-direction: column;
    transition: right var(--pwa-transition);
}

.pwa-cart-drawer.pwa-open {
    right: 0;
}

.pwa-cart-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    border-bottom: 1px solid var(--pwa-border);
    flex-shrink: 0;
}

.pwa-cart-drawer-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--pwa-text);
}

.pwa-cart-close {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--pwa-text-light);
    cursor: pointer;
    padding: 0;
    line-height: 1;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all var(--pwa-transition);
}

.pwa-cart-close:hover {
    background: #f0f0f1;
    color: var(--pwa-text);
}

.pwa-cart-drawer-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.pwa-cart-items {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.pwa-cart-item {
    display: flex;
    gap: 12px;
    padding: 12px;
    background: #f6f7f7;
    border-radius: var(--pwa-radius);
    position: relative;
}

.pwa-cart-item-image {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
}

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

.pwa-cart-item-details h4 {
    margin: 0 0 5px;
    font-size: 14px;
    font-weight: 500;
    color: var(--pwa-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pwa-cart-item-price {
    font-size: 14px;
    font-weight: 600;
    color: var(--pwa-primary);
}

.pwa-cart-item-qty {
    font-size: 13px;
    color: var(--pwa-text-light);
    margin-left: 8px;
}

.pwa-cart-item-remove {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    background: #fff;
    border: 1px solid var(--pwa-border);
    border-radius: 4px;
    color: var(--pwa-text-light);
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--pwa-transition);
}

.pwa-cart-item-remove:hover {
    background: var(--pwa-error);
    border-color: var(--pwa-error);
    color: #fff;
}

.pwa-cart-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--pwa-text-light);
}

.pwa-cart-empty svg {
    width: 64px;
    height: 64px;
    opacity: 0.3;
    margin-bottom: 15px;
}

.pwa-cart-drawer-footer {
    padding: 20px;
    border-top: 1px solid var(--pwa-border);
    flex-shrink: 0;
}

.pwa-cart-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    font-size: 16px;
}

.pwa-cart-total span:first-child {
    color: var(--pwa-text-light);
}

.pwa-cart-total-amount {
    font-weight: 700;
    color: var(--pwa-text);
}

.pwa-view-cart-button,
.pwa-checkout-button {
    display: block;
    width: 100%;
    padding: 14px;
    text-align: center;
    border-radius: var(--pwa-radius);
    font-size: 15px;
    font-weight: 500;
    text-decoration: none;
    transition: all var(--pwa-transition);
    margin-bottom: 10px;
}

.pwa-view-cart-button {
    background: #f0f0f1;
    color: var(--pwa-text);
    border: 1px solid var(--pwa-border);
}

.pwa-view-cart-button:hover {
    background: #e0e0e0;
    color: var(--pwa-text);
}

.pwa-checkout-button {
    background: var(--pwa-primary);
    color: #fff;
    border: none;
}

.pwa-checkout-button:hover {
    background: var(--pwa-primary-hover);
    color: #fff;
}

.pwa-cart-drawer-footer .pwa-checkout-button {
    margin-bottom: 0;
}

/* Cart Backdrop */
.pwa-cart-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999998;
    opacity: 0;
    visibility: hidden;
    transition: all var(--pwa-transition);
}

.pwa-cart-backdrop.pwa-visible {
    opacity: 1;
    visibility: visible;
}

/* Body scroll lock when cart is open */
body.pwa-cart-open {
    overflow: hidden;
}

/* Add to Cart Button States */
.add_to_cart_button.pwa-loading,
.single_add_to_cart_button.pwa-loading {
    position: relative;
    color: transparent !important;
}

.add_to_cart_button.pwa-loading::after,
.single_add_to_cart_button.pwa-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 18px;
    height: 18px;
    margin: -9px 0 0 -9px;
    border: 2px solid #fff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: pwa-spin 0.8s linear infinite;
}

.add_to_cart_button.pwa-added,
.single_add_to_cart_button.pwa-added {
    background: var(--pwa-success) !important;
    border-color: var(--pwa-success) !important;
}

/* Product Data Attributes (for offline access) */
[data-pwa-product-id] {
    /* Products with offline data */
}

/* Offline Add to Cart Notice */
.pwa-offline-notice {
    display: none;
    background: var(--pwa-warning);
    color: var(--pwa-text);
    padding: 10px 15px;
    border-radius: var(--pwa-radius);
    margin-bottom: 15px;
    font-size: 14px;
}

body.pwa-offline .pwa-offline-notice {
    display: block;
}

/* Quantity Selector Enhancement */
.pwa-quantity-selector {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--pwa-border);
    border-radius: var(--pwa-radius);
    overflow: hidden;
}

.pwa-quantity-btn {
    width: 36px;
    height: 36px;
    background: #f6f7f7;
    border: none;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--pwa-transition);
}

.pwa-quantity-btn:hover {
    background: #e0e0e0;
}

.pwa-quantity-btn:active {
    background: #d0d0d0;
}

.pwa-quantity-input {
    width: 50px;
    height: 36px;
    border: none;
    text-align: center;
    font-size: 14px;
    -moz-appearance: textfield;
}

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

/* Quick View Modal */
.pwa-quick-view-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 999999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.pwa-quick-view-overlay.pwa-active {
    display: flex;
}

.pwa-quick-view-modal {
    background: var(--pwa-background);
    border-radius: var(--pwa-radius);
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    overflow: auto;
    position: relative;
}

.pwa-quick-view-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 36px;
    height: 36px;
    background: #fff;
    border: 1px solid var(--pwa-border);
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.pwa-quick-view-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    padding: 30px;
}

.pwa-quick-view-image img {
    width: 100%;
    height: auto;
    border-radius: 4px;
}

/* Wishlist Button */
.pwa-wishlist-btn {
    width: 40px;
    height: 40px;
    background: #fff;
    border: 1px solid var(--pwa-border);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--pwa-transition);
}

.pwa-wishlist-btn:hover {
    border-color: var(--pwa-error);
}

.pwa-wishlist-btn.pwa-wishlisted {
    background: var(--pwa-error);
    border-color: var(--pwa-error);
    color: #fff;
}

.pwa-wishlist-btn svg {
    width: 20px;
    height: 20px;
}

/* Mobile Specific Styles */
@media (max-width: 480px) {
    .pwa-cart-drawer {
        width: 100%;
    }

    .pwa-cart-button {
        bottom: 15px;
        right: 15px;
        width: 52px;
        height: 52px;
    }

    .pwa-quick-view-content {
        grid-template-columns: 1fr;
        gap: 20px;
        padding: 20px;
    }
}

/* Tablet and Desktop */
@media (min-width: 768px) {
    .pwa-cart-button {
        bottom: 30px;
        right: 30px;
    }

    .pwa-offline-cart-indicator {
        bottom: 100px;
        right: 30px;
    }
}

/* Hide cart button on cart/checkout pages */
body.woocommerce-cart .pwa-cart-button,
body.woocommerce-checkout .pwa-cart-button {
    display: none;
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .pwa-cart-item {
        background: #2c3338;
    }

    .pwa-cart-close:hover {
        background: #3c434a;
    }

    .pwa-view-cart-button {
        background: #3c434a;
        border-color: #4c535a;
    }

    .pwa-view-cart-button:hover {
        background: #4c535a;
    }

    .pwa-quantity-btn {
        background: #3c434a;
    }

    .pwa-quantity-btn:hover {
        background: #4c535a;
    }

    .pwa-cart-item-remove {
        background: #2c3338;
        border-color: #4c535a;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .pwa-cart-drawer,
    .pwa-cart-backdrop,
    .add_to_cart_button.pwa-loading::after {
        transition: none;
        animation: none;
    }
}

/* Print Styles - Hide PWA elements */
@media print {
    .pwa-cart-button,
    .pwa-cart-drawer,
    .pwa-cart-backdrop,
    .pwa-offline-cart-indicator {
        display: none !important;
    }
}
