/* Size Selection Table Styles */
.size-selection-wrapper {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
    margin: 20px 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden; /* Prevent content from overflowing */
}

/* Initially hide table content until color is selected */
.size-table-container,
#clear-size-table {
    display: none;
}

/* Quantity input visibility will be controlled by JavaScript based on size table visibility */

.size-selection-wrapper h4 {
    margin: 0 0 15px 0;
    color: #2c3e50;
    font-size: 18px;
    font-weight: 600;
}

/* Scroll container for table */
.size-table-container {
    overflow-x: scroll;
    overflow-y: hidden;
    max-width: 100%;
    width: 100%;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-bottom: 15px;
    box-sizing: border-box;
    /* Force scrollbar to always show */
    scrollbar-width: auto;
    scrollbar-color: #3498db #f1f1f1;
    /* Ensure minimum height for scrollbar visibility */
    min-height: 50px;
}

/* Webkit scrollbar styling - always visible */
.size-table-container::-webkit-scrollbar {
    height: 12px;
    -webkit-appearance: none;
}

.size-table-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
}

.size-table-container::-webkit-scrollbar-thumb {
    background: #3498db;
    border-radius: 6px;
    border: 1px solid #2980b9;
    min-width: 30px;
}

.size-table-container::-webkit-scrollbar-thumb:hover {
    background: #2980b9;
}

.size-quantity-table {
    width: 100%;
    min-width: 450px; /* Reduced to prevent overflow while maintaining usability */
    border-collapse: collapse;
    background: white;
    border-radius: 6px;
    overflow: hidden;
    box-sizing: border-box;
}

.size-quantity-table th {
    background: #2c3e50;
    color: white;
    padding: 10px 12px;
    text-align: center;
    font-weight: 600;
    font-size: 14px;
    min-width: 90px; /* Reduced to prevent overflow */
    white-space: nowrap;
}

.size-quantity-table td {
    padding: 12px;
    text-align: center;
    border-bottom: 1px solid #eee;
    vertical-align: middle;
    min-width: 90px; /* Match header width */
    white-space: nowrap;
}

.size-quantity-table tr:last-child td {
    border-bottom: none;
}

.size-quantity-table thead th:nth-child(even) {
    background: #34495e;
}

.size-quantity-table tbody td:nth-child(even) {
    background: #f8f9fa;
}

.size-header {
    font-weight: 600;
    color: white;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.size-quantity {
    position: relative;
}

.quantity-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 5px;
}

.qty-btn {
    background: #1c61e7;
    color: white;
    border: none;
    width: 35px;
    height: 28px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 20px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.qty-btn:hover {
    background: #a2a2a2;
    transform: translateY(-1px);
}

.qty-btn:active {
    transform: scale(0.95);
}

.qty-input {
    width: 40px !important;
    height: 28px !important;
    text-align: center;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    background: white;
    transition: all 0.2s ease;
    box-sizing: border-box;
    padding: 0;
    margin: 0;
}

.qty-input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.15);
}

.qty-input:not([value="0"]):not([value=""]) {
    background: #e8f5e8;
    border-color: #27ae60;
    color: #27ae60;
}

.size-table-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e0e0e0;
}

#clear-size-table {
    background: #e4405f;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s ease;
}

#clear-size-table:hover {
    background: #c0392b;
}

#total-quantity {
    color: #2c3e50;
    font-size: 16px;
    font-weight: 600;
}

/* Responsive Design */
@media (max-width: 768px) {
    .size-selection-wrapper {
        padding: 10px;
        margin: 15px 0;
    }
    
    .size-selection-wrapper h4 {
        font-size: 16px;
        margin-bottom: 10px;
    }
    
    .size-quantity-table {
        min-width: 320px;
    }
    
    .size-quantity-table th {
        padding: 8px 4px;
        font-size: 12px;
        min-width: 60px;
    }
    
    .size-quantity-table td {
        padding: 10px 4px;
    }
    
    .quantity-controls {
        gap: 6px;
        padding: 3px;
    }
    
    .qty-btn {
        width: 30px;
        height: 24px;
        font-size: 12px;
    }
    
    .qty-input {
        width: 40px;
        height: 24px;
        font-size: 12px;
        border: 1px solid #ddd;
        border-radius: 4px;
        box-sizing: border-box;
        padding: 0;
        margin: 0;
    }
    
    .size-table-actions {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }
    
    .size-table-actions button,
    .size-table-actions span {
        text-align: center;
    }
}

@media (max-width: 480px) {
    .size-selection-wrapper {
        margin: 15px 0;
        padding: 10px;
    }
    
    .size-quantity-table {
        min-width: 320px;
    }
    
    .size-quantity-table th {
        padding: 8px 4px;
        font-size: 12px;
        min-width: 60px;
    }
    
    .size-quantity-table td {
        padding: 10px 4px;
        min-width: 60px;
    }
    
    .qty-btn {
        width: 28px;
        height: 24px;
        font-size: 12px;
    }
    
    .qty-input {
        width: 40px;
        height: 24px;
        font-size: 12px;
        border: 1px solid #ddd;
        border-radius: 4px;
        box-sizing: border-box;
        padding: 0;
        margin: 0;
    }
}

/* RTL Support */
[dir="rtl"] .quantity-controls {
    direction: ltr;
}

[dir="rtl"] .size-table-actions {
    flex-direction: row-reverse;
}

/* Animation for showing/hiding table */
.size-selection-wrapper {
    transition: all 0.3s ease;
}

.size-selection-wrapper[style*="display: none"] {
    opacity: 0;
    transform: translateY(-10px);
}

.size-selection-wrapper[style*="display: block"],
.size-selection-wrapper:not([style*="display: none"]) {
    opacity: 1;
    transform: translateY(0);
}