/**
 * Product Variations Styling - Enhanced Version
 */

/* Color Tags Container */
.color-tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 20px 0;
}

.color-tag {
    padding: 5px 10px;
    border: 2px solid #ddd;
    background: #fff;
    color: #333;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
    border-radius: 4px;
    width: 100px;
    line-height: 10px;
}

.color-tag:hover {
    border-color: #999;
    background: #f5f5f5;
}

.color-tag.active {
    border-color: #000;
    background: #000;
    color: #fff;
}

.color-tag.has-selections {
    position: relative;
}

.color-tag.has-selections::after {
    content: '';
    position: absolute;
    top: -4px;
    right: -4px;
    width: 12px;
    height: 12px;
    background: #4CAF50;
    border: 2px solid #fff;
    border-radius: 50%;
}

/* Loading and Error States */
.loading-variations,
.error-message,
.custom-success-message,
.custom-error-message {
    padding: 20px;
    margin: 20px 0;
    text-align: center;
    background: #f5f5f5;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
}

.error-message,
.custom-error-message {
    background: #ffebee;
    color: #c62828;
}

.custom-success-message {
    background: #e8f5e9;
    color: #2e7d32;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Sizes Container */
.sizes-container {
    margin: 30px 0;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 8px;
}

.sizes-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 20px 0;
    color: #333;
}

/* Sizes Grid */
.sizes-grid {
        gap: 12px;
    margin-bottom: 20px;
    display: flex;
    flex-wrap: wrap;
}

/* Individual Size Item */
.size-item {
    background: #fff;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    padding: 15px;
    transition: all 0.3s ease;
    max-width: 140px;
}

.size-item:not(.out-of-stock):hover {
    border-color: #999;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.size-item.out-of-stock {
    opacity: 0.5;
    background: #f5f5f5;
    cursor: not-allowed;
}

/* Size Header */
.size-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.size-name {
    font-size: 16px;
    font-weight: 700;
    color: #333;
}

.size-price {
    font-size: 16px;
    font-weight: 600;
    color: #2196F3;
}

/* Size Stock */
.size-stock {
    font-size: 12px;
    color: #666;
    margin-bottom: 12px;
}

.out-of-stock .size-stock {
    color: #c62828;
    font-weight: 600;
}

/* Quantity Controls */
.size-quantity {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
}

.qty-btn {
    width: 32px;
    height: 32px;
    border: 1px solid #ddd;
    background: #fff;
    color: #333;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
}

.qty-btn:hover {
    background: #f5f5f5;
    border-color: #999;
}

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

.qty-input {
    width: 60px;
    height: 32px;
    text-align: center;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    padding: 0;
}

.qty-input:focus {
    outline: none;
    border-color: #2196F3;
}

/* Remove spinner arrows from number input */
.qty-input::-webkit-inner-spin-button,
.qty-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.qty-input[type=number] {
    -moz-appearance: textfield;
}

/* Cart Summary */
.cart-summary {
    background: #fff;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    padding: 20px;
    margin-top: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 15px;
}

.summary-info {
    display: flex;
    gap: 30px;
    flex-wrap: wrap;
}

.total-items,
.total-price {
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.total-qty,
.total-amount {
    color: #2196F3;
    font-size: 18px;
}

.add-selected-to-cart {
    padding: 12px 30px;
    background: #000;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    white-space: nowrap;
}

.add-selected-to-cart:hover:not(:disabled) {
    background: #333;
}

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

/* Responsive Design */
@media (max-width: 1024px) {
    .sizes-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    }
}

@media (max-width: 768px) {
    .sizes-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 10px;
    }
    
    .size-item {
        padding: 12px;
    }
    
    .size-name,
    .size-price {
        font-size: 14px;
    }
    
    .cart-summary {
        flex-direction: column;
        align-items: stretch;
    }
    
    .summary-info {
        justify-content: space-between;
        width: 100%;
        gap: 15px;
    }
    
    .add-selected-to-cart {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .color-tags-container {
        gap: 8px;
    }
    
    .color-tag {
        padding: 8px 15px;
        font-size: 12px;
    }
    
    .sizes-grid {
        grid-template-columns: 1fr;
    }
    
    .sizes-container {
        padding: 15px;
    }
    
    .summary-info {
        flex-direction: column;
        gap: 10px;
    }
    
    .total-items,
    .total-price {
        font-size: 14px;
    }
    
    .qty-btn {
        width: 28px;
        height: 28px;
        font-size: 16px;
    }
    
    .qty-input {
        width: 50px;
        height: 28px;
        font-size: 12px;
    }
}

/* Hide original WooCommerce elements */
.variations_form .reset_variations {
    display: none;
}

.woocommerce-variation-add-to-cart {
    display: none !important;
}

/* Print styles */
@media print {
    .color-tags-container,
    .sizes-container,
    .cart-summary {
        page-break-inside: avoid;
    }
}

/* Accessibility improvements */
.color-tag:focus,
.qty-btn:focus,
.qty-input:focus,
.add-selected-to-cart:focus {
    outline: 2px solid #2196F3;
    outline-offset: 2px;
}

/* Dark mode support (if your theme supports it) */
@media (prefers-color-scheme: dark) {
    .sizes-container {
        background: #1e1e1e;
    }
    
    .size-item {
        background: #2a2a2a;
        border-color: #404040;
        color: #fff;
    }
    
    .size-name {
        color: #fff;
    }
    
    .size-stock {
        color: #aaa;
    }
    
    .cart-summary {
        background: #2a2a2a;
        border-color: #404040;
    }
    
    .total-items,
    .total-price {
        color: #fff;
    }
}
