/**
 * Custom Select Field Styling
 * Modern, cross-browser compatible select component for all select elements
 */

.player-select-wrapper,
.custom-select-wrapper {
    position: relative;
    width: 100%;
    max-width: 100%;
}

/* Hide the native select element */
.player-select-wrapper select,
.custom-select-wrapper select {
    opacity: 0;
    position: absolute;
    pointer-events: none;
    z-index: -1;
}

/* Custom select button */
.custom-select {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 50px;
    padding: 12px 20px;
    background: #ffffff;
    border: 2px solid #e1e8ed;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 16px;
    color: #2c3e50;
    box-sizing: border-box;
}

.custom-select:hover {
    border-color: #f8770e;
    box-shadow: 0 2px 8px rgba(248, 119, 14, 0.1);
}

.custom-select.active {
    border-color: #f8770e;
    box-shadow: 0 0 0 3px rgba(248, 119, 14, 0.1);
}

.custom-select.disabled {
    background: #f8f9fa;
    color: #6c757d;
    cursor: not-allowed;
    border-color: #e9ecef;
}

/* Selected value text */
.select-value {
    flex: 1;
    text-align: left;
    color: #2c3e50;
    font-weight: 500;
}

.select-value.placeholder {
    color: #6c757d;
    font-weight: 400;
}

/* Dropdown arrow */
.select-arrow {
    width: 20px;
    height: 20px;
    margin-left: 12px;
    transition: transform 0.3s ease;
    color: #6c757d;
    display: flex;
    align-items: center;
    justify-content: center;
}

.custom-select.active .select-arrow {
    transform: rotate(180deg);
    color: #f8770e;
}

/* SVG arrow icon */
.select-arrow svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

/* Dropdown container */
.select-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #ffffff;
    border: 2px solid #f8770e;
    border-top: none;
    border-radius: 0 0 12px 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    max-height: 200px;
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
}

.select-dropdown.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Custom scrollbar */
.select-dropdown::-webkit-scrollbar {
    width: 6px;
}

.select-dropdown::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.select-dropdown::-webkit-scrollbar-thumb {
    background: #f8770e;
    border-radius: 3px;
}

.select-dropdown::-webkit-scrollbar-thumb:hover {
    background: #e6690c;
}

/* Search input */
.select-search {
    position: sticky;
    top: 0;
    background: #ffffff;
    border: none;
    border-bottom: 1px solid #e1e8ed;
    padding: 12px 20px;
    font-size: 14px;
    outline: none;
    font-family: 'Poppins', sans-serif;
    width: 100%;
    box-sizing: border-box;
}

.select-search::placeholder {
    color: #6c757d;
}

/* Dropdown options */
.select-option {
    padding: 12px 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 1px solid #f8f9fa;
    font-size: 14px;
    color: #2c3e50;
    display: flex;
    align-items: center;
}

.select-option:last-child {
    border-bottom: none;
}

.select-option:hover {
    background: #f8f9fa;
    color: #f8770e;
}

.select-option.selected {
    background: #f8770e;
    color: #ffffff;
    font-weight: 500;
}

.select-option.selected:hover {
    background: #e6690c;
}

.select-option.focused {
    background: #f8f9fa;
    color: #f8770e;
    outline: 2px solid #f8770e;
    outline-offset: -2px;
}

.select-option.no-results {
    color: #6c757d;
    cursor: default;
    font-style: italic;
    text-align: center;
}

.select-option.no-results:hover {
    background: transparent;
    color: #6c757d;
}

/* Player icon in options - only for player selects */
.player-select-wrapper .select-option::before {
    content: "👤";
    margin-right: 8px;
    opacity: 0.7;
}

.player-select-wrapper .select-option.no-results::before {
    content: "🔍";
}

/* Generic icon for other selects */
.custom-select-wrapper .select-option::before {
    content: "📋";
    margin-right: 8px;
    opacity: 0.7;
}

.custom-select-wrapper .select-option.no-results::before {
    content: "🔍";
}

/* Loading state */
.select-loading {
    padding: 20px;
    text-align: center;
    color: #6c757d;
    font-style: italic;
}

/* Error states */
.player-select-wrapper.error .custom-select,
.custom-select-wrapper.error .custom-select {
    border-color: #dc3545;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1);
}

.player-select-wrapper.error .select-value,
.custom-select-wrapper.error .select-value {
    color: #dc3545;
}

/* Validation error styles - Contact Form 7 compatibility */
.player-select-wrapper .wpcf7-not-valid .custom-select,
.custom-select-wrapper .wpcf7-not-valid .custom-select {
    border-color: #dc3545;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1);
}

.player-select-wrapper .wpcf7-validation-error,
.custom-select-wrapper .wpcf7-validation-error {
    color: #dc3545;
    font-size: 12px;
    margin-top: 5px;
    display: block;
}

/* Focus styles for accessibility */
.custom-select:focus {
    outline: none;
    border-color: #f8770e;
    box-shadow: 0 0 0 3px rgba(248, 119, 14, 0.1);
}

/* Legacy support for existing implementations */
.player-search-input {
    display: none; /* Hide old search input */
}

.player-dropdown {
    display: none; /* Hide old dropdown */
}

.selected-player {
    display: none; /* Hide old selected player display */
}

/* Responsive design */
@media (max-width: 768px) {
    .custom-select {
        min-height: 48px;
        padding: 10px 16px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .select-dropdown {
        max-height: 180px;
    }
    
    .select-option {
        padding: 14px 16px;
        font-size: 16px;
    }
    
    .select-search {
        padding: 10px 16px;
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .custom-select {
        min-height: 44px;
        padding: 8px 12px;
    }
    
    .select-dropdown {
        max-height: 160px;
    }
    
    .select-option {
        padding: 12px;
    }
    
    .select-search {
        padding: 8px 12px;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .custom-select {
        border-width: 3px;
    }
    
    .select-option:hover {
        background: #000000;
        color: #ffffff;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .custom-select,
    .select-dropdown,
    .select-arrow,
    .select-option {
        transition: none;
    }
}