/**
 * WC Sector Delivery - Custom Dropdown Styles
 * Can be enqueued as separate file or injected inline
 */

/* Custom Dropdown Container */
.wc-sector-custom-dropdown {
    position: relative;
    width: 100%;
}

/* Selected Display Box */
.wc-sector-dropdown-selected {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 12px 40px 12px 12px;
    cursor: pointer;
    position: relative;
    user-select: none;
    font-size: 14px;
    line-height: 1.5;
    transition: border-color 0.2s ease;
}

.wc-sector-dropdown-selected:hover {
    border-color: #999;
}

.wc-sector-dropdown-selected:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

/* Dropdown Arrow */
.wc-sector-dropdown-selected:after {
    content: "▼";
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 10px;
    color: #666;
    transition: transform 0.2s ease;
}

.wc-sector-dropdown-selected.active:after {
    content: "▲";
    transform: translateY(-50%) rotate(0deg);
}

/* Options Container */
.wc-sector-dropdown-options {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 4px 4px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 999;
    display: none;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    margin-top: -1px;
}

.wc-sector-dropdown-options.show {
    display: block;
}

/* Individual Option */
.wc-sector-dropdown-option {
    padding: 12px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    font-size: 14px;
    line-height: 1.5;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.wc-sector-dropdown-option:hover:not(.disabled) {
    background: #f5f5f5;
}

.wc-sector-dropdown-option:first-child {
    border-top: 1px solid #eee;
}

/* Disabled Option */
.wc-sector-dropdown-option.disabled {
    color: #999;
    cursor: not-allowed;
    background: #f9f9f9;
    opacity: 0.7;
}

.wc-sector-dropdown-option.disabled:hover {
    background: #f9f9f9;
}

/* Unavailable Badge */
.wc-sector-dropdown-option.disabled .unavailable-badge {
    display: inline-block;
    background: #e74c3c;
    color: white;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 3px;
    margin-left: 8px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Selected Option */
.wc-sector-dropdown-option.selected {
    background: #f0f0f0;
    font-weight: 600;
}

.wc-sector-dropdown-option.selected:not(.disabled) {
    color: #007cba;
}

/* Hide Native Select */
#billing_delivery_type_field select.hidden-native {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    height: 0;
    width: 0;
}

/* Mobile Responsive */
@media screen and (max-width: 768px) {
    .wc-sector-dropdown-selected {
        padding: 10px 35px 10px 10px;
        font-size: 16px; /* Prevents iOS zoom on focus */
    }
    
    .wc-sector-dropdown-option {
        padding: 10px;
        font-size: 16px; /* Prevents iOS zoom on focus */
    }
    
    .wc-sector-dropdown-options {
        max-height: 250px; /* Taller on mobile for easier touch */
    }
}

/* Dark Mode Support (Optional) */
@media (prefers-color-scheme: dark) {
    .wc-sector-dropdown-selected {
        background: #2d2d2d;
        border-color: #444;
        color: #e0e0e0;
    }
    
    .wc-sector-dropdown-options {
        background: #2d2d2d;
        border-color: #444;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    }
    
    .wc-sector-dropdown-option:hover:not(.disabled) {
        background: #3a3a3a;
    }
    
    .wc-sector-dropdown-option.disabled {
        background: #252525;
        color: #666;
    }
    
    .wc-sector-dropdown-option.selected {
        background: #3a3a3a;
    }
}

/* Accessibility: Focus Visible */
.wc-sector-dropdown-option:focus-visible {
    outline: 2px solid #007cba;
    outline-offset: -2px;
}

/* Loading State (Optional Enhancement) */
.wc-sector-custom-dropdown.loading .wc-sector-dropdown-selected {
    opacity: 0.6;
    pointer-events: none;
}

.wc-sector-custom-dropdown.loading .wc-sector-dropdown-selected:after {
    content: "⟳";
    animation: rotate 1s linear infinite;
}

@keyframes rotate {
    from {
        transform: translateY(-50%) rotate(0deg);
    }
    to {
        transform: translateY(-50%) rotate(360deg);
    }
}

/* Error State */
.wc-sector-custom-dropdown.error .wc-sector-dropdown-selected {
    border-color: #e74c3c;
}

/* RTL Support */
[dir="rtl"] .wc-sector-dropdown-selected:after {
    right: auto;
    left: 12px;
}

[dir="rtl"] .wc-sector-dropdown-option .unavailable-badge {
    margin-left: 0;
    margin-right: 8px;
}