/**
 * Unified Styles for Koval Checkout
 * 
 * Base styles for both delivery (Shopify) and pickup (Square) modes
 * Adapts existing DUO styles for unified system
 * 
 * Version: 1.0.0
 */

/* Widget Container */
.koval-product-widget {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-bottom: 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Mode Switcher */
.mode-switcher {
    display: flex;
    gap: 0;
    margin-bottom: 20px;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid #ddd;
}

.mode-btn {
    flex: 1;
    padding: 12px 20px;
    border: none;
    background: #f8f9fa;
    color: #666;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s ease;
    border-right: 1px solid #ddd;
}

.mode-btn:last-child {
    border-right: none;
}

.mode-btn:hover {
    background: #e9ecef;
}

.mode-btn.active {
    background: #1a1a1a;
    color: white;
}

/* Product Info */
.product-info {
    margin-bottom: 20px;
    text-align: center;
}

.product-name {
    font-size: 1.3em;
    font-weight: 600;
    margin-bottom: 8px;
    color: #333;
}

.product-price {
    font-size: 1.5em;
    font-weight: 700;
    color: #d4a574;
}

/* Form Styles */
.delivery-form,
.pickup-form {
    display: none;
}

.delivery-form.active,
.pickup-form.active {
    display: block;
}

.size-selector,
.quantity-selector {
    margin-bottom: 15px;
}

.size-selector label,
.quantity-selector label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #333;
}

.size-selector select,
.quantity-selector input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    background: white;
}

.size-selector select:focus,
.quantity-selector input:focus {
    outline: none;
    border-color: #d4a574;
    box-shadow: 0 0 0 2px rgba(212, 165, 116, 0.2);
}

/* Add to Cart Buttons */
.add-to-cart {
    width: 100%;
    padding: 15px;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 10px;
}

.delivery-cart-btn {
    background: #d4a574;
    color: white;
}

.delivery-cart-btn:hover {
    background: #c49660;
}

.pickup-cart-btn {
    background: #1a1a1a;
    color: white;
}

.pickup-cart-btn:hover {
    background: #333;
}

.add-to-cart:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Cart Sidebar */
.cart-sidebar {
    position: fixed;
    right: -400px;
    top: 0;
    width: 400px;
    height: 100vh;
    background: white;
    box-shadow: -4px 0 20px rgba(0,0,0,0.15);
    transition: right 0.3s ease;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    visibility: visible;
    pointer-events: auto;
}

.cart-sidebar.open {
    right: 0;
    visibility: visible;
    pointer-events: auto;
}

.cart-header {
    padding: 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fa;
}

.cart-title {
    font-size: 1.4em;
    font-weight: 600;
    margin: 0;
}

.close-cart {
    background: none;
    border: none;
    font-size: 1.5em;
    cursor: pointer;
    color: #666;
    padding: 5px;
    border-radius: 4px;
}

.close-cart:hover {
    background: #e9ecef;
}

.cart-items {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

.cart-item {
    display: flex;
    align-items: center;
    padding: 15px 0;
    border-bottom: 1px solid #eee;
}

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

.item-image {
    width: 60px;
    height: 60px;
    background: #f0f0f0;
    border-radius: 6px;
    margin-right: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    font-size: 1.2em;
}

.item-details {
    flex: 1;
}

.item-name {
    font-weight: 600;
    margin-bottom: 5px;
    color: #333;
}

.item-price {
    color: #d4a574;
    font-weight: 600;
    margin-bottom: 8px;
}

.quantity-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.qty-btn {
    background: #f0f0f0;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    transition: background 0.2s;
}

.qty-btn:hover {
    background: #e0e0e0;
}

.cart-total {
    padding: 20px;
    border-top: 1px solid #eee;
    background: #f8f9fa;
}

.total-line {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 14px;
}

.total-amount {
    font-size: 1.2em;
    font-weight: 700;
    color: #333;
}

.checkout-btn {
    width: 100%;
    background: #d4a574;
    color: white;
    border: none;
    padding: 15px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.1em;
    font-weight: 600;
    margin-top: 15px;
    transition: background 0.2s;
}

.checkout-btn:hover {
    background: #c49660;
}

.empty-cart {
    text-align: center;
    color: #666;
    font-style: italic;
    padding: 40px 0;
}

/* Header Cart Icons */
#header-cart-switcher {
    position: relative;
}

#shopify-cart-header-icon,
#pickup-cart-header-icon {
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    transition: background 0.2s;
    display: none;
}

#shopify-cart-header-icon:hover,
#pickup-cart-header-icon:hover {
    background: rgba(0,0,0,0.1);
}

#shopify-cart-count,
#pickup-cart-count {
    background: #d4a574;
    color: white;
    border-radius: 50%;
    padding: 2px 6px;
    font-size: 12px;
    font-weight: 600;
    margin-left: 5px;
    display: none;
}

/* Status Messages */
#widget-status {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background: #333;
    color: white;
    padding: 10px 20px;
    border-radius: 6px;
    z-index: 1001;
    transform: translateY(100px);
    transition: transform 0.3s ease;
    font-size: 14px;
}

#widget-status.show {
    transform: translateY(0);
}

/* Responsive Design */
@media (max-width: 768px) {
    .cart-sidebar {
        width: 100%;
        right: -100%;
    }
    
    .koval-product-widget {
        margin: 10px;
        padding: 15px;
    }
    
    .mode-switcher {
        flex-direction: column;
    }
    
    .mode-btn {
        border-right: none;
        border-bottom: 1px solid #ddd;
    }
    
    .mode-btn:last-child {
        border-bottom: none;
    }
}

/* Loading States */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #d4a574;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Error States */
.error {
    color: #dc3545;
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    padding: 10px;
    border-radius: 4px;
    margin: 10px 0;
    font-size: 14px;
}

/* Success States */
.success {
    color: #155724;
    background: #d4edda;
    border: 1px solid #c3e6cb;
    padding: 10px;
    border-radius: 4px;
    margin: 10px 0;
    font-size: 14px;
}
