/**
 * REM Toppers Addon - Frontend Styles
 * Primary Color: #D68777
 */

/* Main Topper Selection Container */
.rem-topper-selection {
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border: 2px solid #D68777;
    border-radius: 12px;
    padding: 20px;
    margin: 15px 0;
    box-shadow: 0 4px 15px rgba(214, 135, 119, 0.1);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.rem-topper-selection::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #D68777 0%, #E8A87C 50%, #D68777 100%);
}

.rem-topper-selection:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(214, 135, 119, 0.15);
}

/* Header Section */
.rem-topper-header {
    text-align: center;
    margin-bottom: 20px;
}

.rem-topper-header h4 {
    color: #D68777;
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 8px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.rem-topper-header p {
    color: #666;
    font-size: 14px;
    margin: 0;
    font-style: italic;
}

/* Options Container */
.rem-topper-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
}

@media (max-width: 768px) {
    .rem-topper-options {
        grid-template-columns: 1fr;
        gap: 15px;
    }
}

/* Selector Styles */
.rem-topper-selector,
.rem-color-selector {
    position: relative;
}

.rem-topper-selector label,
.rem-color-selector label {
    display: block;
    color: #333;
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 14px;
}

.rem-topper-dropdown,
.rem-color-dropdown {
    width: 100% !important;
    padding: 12px 15px !important;
    border: 2px solid #e1e5e9 !important;
    border-radius: 8px !important;
    background: #ffffff !important;
    color: #333 !important;
    font-size: 14px !important;
    transition: all 0.3s ease;
    appearance: auto !important;
    -webkit-appearance: menulist !important;
    -moz-appearance: menulist !important;
    background-image: none !important;
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 15px !important;
    z-index: 999 !important;
    position: relative;
    height: auto !important;
    margin-bottom: 10px !important;
}

/* Ensure dropdown options are visible */
.rem-topper-dropdown option,
.rem-color-dropdown option {
    background: #ffffff !important;
    color: #333 !important;
    padding: 8px 12px !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    font-size: 14px !important;
    line-height: 1.4 !important;
}

/* Override any theme styles that might hide dropdown options */
.rem-topper-selection select.rem-topper-dropdown,
.rem-topper-selection select.rem-color-dropdown {
    background-color: #ffffff !important;
    color: #333 !important;
    border: 2px solid #e1e5e9 !important;
}

.rem-topper-selection select.rem-topper-dropdown:focus,
.rem-topper-selection select.rem-color-dropdown:focus {
    background-color: #ffffff !important;
    color: #333 !important;
    border-color: #D68777 !important;
}

/* Force override for cart page specifically */
.woocommerce-cart .rem-topper-dropdown,
.woocommerce-cart .rem-color-dropdown {
    appearance: auto !important;
    -webkit-appearance: menulist !important;
    -moz-appearance: menulist !important;
    background-color: #ffffff !important;
    color: #333 !important;
    border: 2px solid #e1e5e9 !important;
    background-image: none !important;
    height: 45px !important;
    padding: 8px 12px !important;
    font-size: 14px !important;
    z-index: 99999 !important;
    position: relative !important;
    display: block !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

/* CRITICAL: Force dropdown list to show */
.woocommerce-cart .rem-color-dropdown:focus,
.woocommerce-cart .rem-color-dropdown:active,
.woocommerce-cart .rem-color-dropdown[size],
.woocommerce-cart .rem-color-dropdown[multiple] {
    height: auto !important;
    min-height: 120px !important;
}

.woocommerce-cart .rem-topper-dropdown option,
.woocommerce-cart .rem-color-dropdown option {
    background-color: #ffffff !important;
    color: #333 !important;
    padding: 8px 12px !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Override Elementor cart lightbox conflicts */
.elementor-menu-cart__container .rem-topper-dropdown,
.elementor-menu-cart__container .rem-color-dropdown {
    appearance: auto !important;
    -webkit-appearance: menulist !important;
    -moz-appearance: menulist !important;
    background-color: #ffffff !important;
    color: #333 !important;
    border: 2px solid #e1e5e9 !important;
    background-image: none !important;
    height: auto !important;
    padding: 12px 15px !important;
    font-size: 14px !important;
    z-index: 9999 !important;
    position: relative !important;
}

.elementor-menu-cart__container .rem-topper-dropdown option,
.elementor-menu-cart__container .rem-color-dropdown option {
    background-color: #ffffff !important;
    color: #333 !important;
    padding: 8px 12px !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Ensure dropdown works even with aria-hidden */
[aria-hidden="true"] .rem-topper-dropdown,
[aria-hidden="true"] .rem-color-dropdown {
    appearance: auto !important;
    -webkit-appearance: menulist !important;
    -moz-appearance: menulist !important;
    background-color: #ffffff !important;
    color: #333 !important;
    border: 2px solid #e1e5e9 !important;
    background-image: none !important;
    height: auto !important;
    padding: 12px 15px !important;
    font-size: 14px !important;
    z-index: 9999 !important;
    position: relative !important;
}

[aria-hidden="true"] .rem-topper-dropdown option,
[aria-hidden="true"] .rem-color-dropdown option {
    background-color: #ffffff !important;
    color: #333 !important;
    padding: 8px 12px !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.rem-topper-dropdown:focus,
.rem-color-dropdown:focus {
    outline: none;
    border-color: #D68777;
    box-shadow: 0 0 0 3px rgba(214, 135, 119, 0.1);
}

.rem-topper-dropdown:hover,
.rem-color-dropdown:hover {
    border-color: #D68777;
}

/* Preview Section */
.rem-topper-preview {
    grid-column: 1 / -1;
    text-align: center;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px dashed #D68777;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.topper-preview-image {
    position: relative;
}

.topper-preview-image img {
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
}

.topper-preview-image img:hover {
    transform: scale(1.05);
}

/* Price Display */
.rem-topper-price {
    grid-column: 1 / -1;
    text-align: center;
    padding: 12px;
    background: linear-gradient(135deg, #D68777 0%, #E8A87C 100%);
    color: white;
    border-radius: 8px;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(214, 135, 119, 0.3);
}

.rem-topper-price strong {
    font-size: 16px;
}

/* Update Notice */
.rem-update-notice {
    grid-column: 1 / -1;
    text-align: center;
    padding: 10px;
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 6px;
    color: #856404;
    font-size: 13px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.7; }
    100% { opacity: 1; }
}

/* Topper Info in Cart Item */
.rem-topper-info {
    color: #D68777 !important;
    font-weight: 500;
    background: rgba(214, 135, 119, 0.1);
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-block;
    margin-top: 5px;
}

/* Loading States */
.rem-topper-loading {
    position: relative;
    pointer-events: none;
}

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

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

/* Success States */
.rem-topper-success {
    border-color: #28a745;
    background: linear-gradient(135deg, #d4edda 0%, #ffffff 100%);
}

.rem-topper-success::before {
    background: linear-gradient(90deg, #28a745 0%, #20c997 50%, #28a745 100%);
}

/* Error States */
.rem-topper-error {
    border-color: #dc3545;
    background: linear-gradient(135deg, #f8d7da 0%, #ffffff 100%);
}

.rem-topper-error::before {
    background: linear-gradient(90deg, #dc3545 0%, #e74c3c 50%, #dc3545 100%);
}

/* Responsive Design */
@media (max-width: 480px) {
    .rem-topper-selection {
        padding: 15px;
        margin: 10px 0;
    }
    
    .rem-topper-header h4 {
        font-size: 16px;
    }
    
    .rem-topper-dropdown,
    .rem-color-dropdown {
        padding: 10px 12px;
        font-size: 13px;
    }
    
    .rem-topper-preview {
        min-height: 100px;
        padding: 10px;
    }
    
    .topper-preview-image img {
        max-width: 80px;
        max-height: 80px;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .rem-topper-selection {
        background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
        border-color: #D68777;
        color: #e2e8f0;
    }
    
    .rem-topper-header h4 {
        color: #D68777;
    }
    
    .rem-topper-header p {
        color: #a0aec0;
    }
    
    .rem-topper-selector label,
    .rem-color-selector label {
        color: #e2e8f0;
    }
    
    .rem-topper-dropdown,
    .rem-color-dropdown {
        background: #2d3748;
        border-color: #4a5568;
        color: #e2e8f0;
    }
    
    .rem-topper-dropdown:focus,
    .rem-color-dropdown:focus {
        border-color: #D68777;
        background: #2d3748;
    }
    
    .rem-topper-preview {
        background: #2d3748;
        border-color: #D68777;
    }
}

/* Animation for smooth transitions */
.rem-topper-selection * {
    transition: all 0.3s ease;
}

/* Custom scrollbar for dropdowns */
.rem-topper-dropdown::-webkit-scrollbar,
.rem-color-dropdown::-webkit-scrollbar {
    width: 6px;
}

.rem-topper-dropdown::-webkit-scrollbar-track,
.rem-color-dropdown::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.rem-topper-dropdown::-webkit-scrollbar-thumb,
.rem-color-dropdown::-webkit-scrollbar-thumb {
    background: #D68777;
    border-radius: 3px;
}

.rem-topper-dropdown::-webkit-scrollbar-thumb:hover,
.rem-color-dropdown::-webkit-scrollbar-thumb:hover {
    background: #c5766a;
}
