/*
 * =====================================================
 * Select2 Custom Styling for Matrimony Platform
 * White Background (#ffffff) | Black Font (#000000)
 * Theme Accents: Orange-Gold & Deep Maroon
 * =====================================================
 */

/* ========== Select2 Container ========== */
.select2-container {
    width: 100% !important;
}

.select2-container--default .select2-selection--single {
    height: 45px;
    border: 1px solid rgba(247, 148, 29, 0.2);
    border-radius: 12px;
    background: #ffffff;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.select2-container--default .select2-selection--single:hover {
    border-color: rgba(247, 148, 29, 0.4);
}

.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--default.select2-container--open .select2-selection--single {
    border-color: #f7941d;
    box-shadow: 0 0 0 3px rgba(247, 148, 29, 0.1);
    outline: none;
}

/* ========== Single Selection ========== */
.select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 43px;
    padding-left: 16px;
    padding-right: 40px;
    color: #000000;
    font-size: 15px;
    font-weight: 500;
}

.select2-container--default .select2-selection--single .select2-selection__placeholder {
    color: #6c757d;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 43px;
    right: 12px;
}

.select2-container--default .select2-selection--single .select2-selection__arrow b {
    border-color: #495057 transparent transparent transparent;
    border-width: 6px 5px 0 5px;
}

.select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b {
    border-color: transparent transparent #495057 transparent;
    border-width: 0 5px 6px 5px;
}

/* ========== Multiple Selection ========== */
.select2-container--default .select2-selection--multiple {
    min-height: 45px;
    border: 1px solid rgba(247, 148, 29, 0.2);
    border-radius: 12px;
    padding: 4px 8px;
    background: #ffffff;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.select2-container--default .select2-selection--multiple:hover {
    border-color: rgba(247, 148, 29, 0.4);
}

.select2-container--default.select2-container--focus .select2-selection--multiple,
.select2-container--default.select2-container--open .select2-selection--multiple {
    border-color: #f7941d;
    box-shadow: 0 0 0 3px rgba(247, 148, 29, 0.1);
    outline: none;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice {
    background: linear-gradient(135deg, #a40034 0%, #8a002c 100%);
    border: none;
    border-radius: 8px;
    color: white;
    padding: 4px 10px;
    margin: 4px 4px 0 0;
    font-size: 14px;
    font-weight: 500;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
    color: white;
    margin-right: 6px;
    font-weight: 700;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover {
    opacity: 1;
    color: #E8D48A;
}

.select2-container--default .select2-search--inline .select2-search__field {
    margin-top: 4px;
    padding: 4px 0;
    font-size: 15px;
    color: #000000;
}

.select2-container--default .select2-search--inline .select2-search__field::placeholder {
    color: #6c757d;
}

/* ========== Dropdown ========== */
.select2-dropdown {
    border: 1px solid rgba(247, 148, 29, 0.3);
    border-radius: 12px;
    background: #ffffff;
    box-shadow: 0 12px 40px rgba(45, 41, 38, 0.15);
    overflow: hidden;
    margin-top: 4px;
}

.select2-container--default .select2-dropdown--above {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    margin-top: 0;
    margin-bottom: 4px;
}

.select2-container--default .select2-dropdown--below {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
}

/* ========== Search Box ========== */
.select2-search--dropdown {
    padding: 12px;
    background: linear-gradient(135deg, rgba(247, 148, 29, 0.04) 0%, transparent 100%);
    border-bottom: 1px solid rgba(247, 148, 29, 0.15);
}

.select2-search--dropdown .select2-search__field {
    border: 1px solid rgba(247, 148, 29, 0.3);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 15px;
    color: #000000;
    background: #ffffff;
    outline: none;
    transition: all 0.3s;
}

.select2-search--dropdown .select2-search__field:focus {
    border-color: #f7941d;
    box-shadow: 0 0 0 2px rgba(247, 148, 29, 0.1);
}

.select2-search--dropdown .select2-search__field::placeholder {
    color: #6c757d;
}

/* ========== Results ========== */
.select2-results {
    padding: 8px 0;
    max-height: 300px;
}

.select2-results__options {
    list-style: none;
    margin: 0;
    padding: 0;
}

.select2-results__option {
    padding: 10px 16px;
    font-size: 15px;
    color: #000000;
    cursor: pointer;
    transition: all 0.2s ease;
    margin: 0 8px 2px 8px;
    border-radius: 8px;
}

.select2-results__option:hover {
    background: rgba(247, 148, 29, 0.08);
    color: #000000;
}

.select2-results__option--highlighted {
    background: linear-gradient(90deg, rgba(164, 0, 52, 0.08) 0%, rgba(164, 0, 52, 0.02) 100%) !important;
    color: #a40034 !important;
    font-weight: 500;
}

.select2-results__option--selected {
    background: linear-gradient(135deg, #f7941d 0%, #e6841a 100%) !important;
    color: white !important;
    font-weight: 600;
}

.select2-results__option[aria-disabled=true] {
    color: #6c757d;
    cursor: not-allowed;
    opacity: 0.6;
}

/* ========== Group Labels ========== */
.select2-results__group {
    font-weight: 700;
    color: #495057;
    padding: 12px 16px 8px 16px;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    background: rgba(247, 148, 29, 0.04);
    margin: 0 8px 4px 8px;
    border-radius: 6px;
}

/* ========== Loading Message ========== */
.select2-results__message {
    padding: 16px;
    text-align: center;
    color: #6c757d;
    font-size: 14px;
}

.select2-container--default .select2-results__option--loading {
    color: #6c757d;
    position: relative;
    padding-left: 40px;
}

.select2-container--default .select2-results__option--loading::before {
    content: '';
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    border: 2px solid rgba(247, 148, 29, 0.3);
    border-top-color: #f7941d;
    border-radius: 50%;
    animation: select2-spin 0.8s linear infinite;
}

@keyframes select2-spin {
    to { transform: translateY(-50%) rotate(360deg); }
}

/* ========== No Results ========== */
.select2-container--default .select2-results > .select2-results__options:empty::after {
    content: 'No results found';
    display: block;
    padding: 24px;
    text-align: center;
    color: #6c757d;
    font-size: 14px;
}

/* ========== Disabled State ========== */
.select2-container--disabled .select2-selection--single,
.select2-container--disabled .select2-selection--multiple {
    background: #F5F3F0;
    cursor: not-allowed;
    opacity: 0.6;
}

.select2-container--disabled .select2-selection__choice {
    opacity: 0.6;
}

/* ========== Invalid State ========== */
.is-invalid + .select2-container--default .select2-selection--single,
.is-invalid + .select2-container--default .select2-selection--multiple {
    border-color: #a40034;
}

.is-invalid + .select2-container--default.select2-container--focus .select2-selection--single,
.is-invalid + .select2-container--default.select2-container--focus .select2-selection--multiple {
    border-color: #a40034;
    box-shadow: 0 0 0 3px rgba(164, 0, 52, 0.1);
}

.is-invalid + .select2-container--default .select2-selection--single .select2-selection__rendered,
.is-invalid + .select2-container--default .select2-selection--multiple .select2-selection__rendered {
    color: #000000;
}

/* ========== Small Size Variant ========== */
.select2-sm + .select2-container--default .select2-selection--single {
    height: 38px;
    border-radius: 8px;
}

.select2-sm + .select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 36px;
    font-size: 14px;
}

.select2-sm + .select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 36px;
}

/* ========== Responsive Adjustments ========== */

/* Large Desktops (≥1920px) - 4K/UHD displays */
@media (min-width: 1920px) {
    .select2-container--default .select2-selection--single {
        height: 48px;
        border-radius: 14px;
    }
    
    .select2-container--default .select2-selection--single .select2-selection__rendered {
        line-height: 46px;
        font-size: 16px;
        padding-left: 18px;
    }
    
    .select2-container--default .select2-selection--single .select2-selection__arrow {
        height: 46px;
        right: 14px;
    }
    
    .select2-results__option {
        padding: 14px 18px;
        font-size: 16px;
    }
    
    .select2-dropdown {
        max-height: 400px;
        border-radius: 14px;
    }
}

/* Desktop (1200px - 1919px) - Standard large screens */
@media (min-width: 1200px) and (max-width: 1919px) {
    .select2-container--default .select2-selection--single {
        height: 46px;
        border-radius: 12px;
    }
    
    .select2-container--default .select2-selection--single .select2-selection__rendered {
        line-height: 44px;
        font-size: 15px;
    }
}

/* Tablet Landscape (769px - 1199px) */
@media (min-width: 769px) and (max-width: 1199px) {
    .select2-container--default .select2-selection--single {
        height: 44px;
        border-radius: 11px;
    }
    
    .select2-container--default .select2-selection--single .select2-selection__rendered {
        line-height: 42px;
        font-size: 14px;
        padding-left: 14px;
    }
    
    .select2-dropdown {
        max-height: 320px;
    }
}

/* Tablet Portrait (577px - 768px) */
@media (min-width: 577px) and (max-width: 768px) {
    .select2-container--default .select2-selection--single {
        height: 44px;
        border-radius: 10px;
        background: #ffffff;
    }
    
    .select2-container--default .select2-selection--single .select2-selection__rendered {
        line-height: 42px;
        font-size: 14px;
        padding-left: 14px;
        color: #000000;
    }
    
    .select2-container--default .select2-selection--single .select2-selection__arrow {
        height: 42px;
    }
    
    .select2-results__option {
        padding: 12px 14px;
        font-size: 14px;
        color: #000000;
    }
    
    .select2-dropdown {
        max-height: 300px;
        border-radius: 10px;
        background: #ffffff;
    }
}

@media (max-width: 576px) {
    /* Mobile phones - match Bootstrap form-select styling */
    .select2-container--default .select2-selection--single {
        height: 42px;
        border-radius: 8px;
        border-width: 1px;
    }
    
    .select2-container--default .select2-selection--single .select2-selection__rendered {
        line-height: 40px;
        font-size: 14px;
        padding-left: 12px;
        padding-right: 36px;
        color: #000000;
    }
    
    .select2-container--default .select2-selection--single .select2-selection__arrow {
        height: 40px;
        right: 10px;
    }
    
    /* Multiple select - mobile */
    .select2-container--default .select2-selection--multiple {
        min-height: 42px;
        border-radius: 8px;
        padding: 4px 8px;
    }
    
    .select2-container--default .select2-selection--multiple .select2-selection__choice {
        font-size: 13px;
        padding: 3px 8px;
    }
    
    /* Dropdown positioning */
    .select2-dropdown {
        border-radius: 8px;
        font-size: 14px;
        max-height: 280px;
        background: #ffffff;
    }
    
    .select2-results__option {
        padding: 12px;
        font-size: 14px;
        min-height: 44px; /* Better touch targets */
        display: flex;
        align-items: center;
        color: #000000;
    }
    
    /* Search field - keep white bg, black text, 16px prevents iOS zoom */
    .select2-search--dropdown .select2-search__field {
        font-size: 16px;
        height: 42px;
        padding: 8px 12px;
        border-radius: 6px;
        background: #ffffff;
        color: #000000;
    }
    
    /* Container width on mobile */
    .select2-container {
        width: 100% !important;
    }
    
    /* Filter sidebar on mobile (user search results page) */
    .filter-group .select2-container--default .select2-selection--single {
        height: 42px;
        border-radius: 8px;
    }
    
    .filter-group .select2-container--default .select2-selection--single .select2-selection__rendered {
        line-height: 40px;
        font-size: 14px;
        padding-left: 12px;
        color: #000000;
    }
    
    .filter-group .select2-container--default .select2-selection--single .select2-selection__arrow {
        height: 40px;
    }
}

@media (max-width: 480px) {
    /* Small phones - compact design */
    .select2-container--default .select2-selection--single {
        height: 40px;
        border-radius: 8px;
    }
    
    .select2-container--default .select2-selection--single .select2-selection__rendered {
        line-height: 38px;
        font-size: 13px;
        padding-left: 10px;
        padding-right: 32px;
        color: #000000;
    }
    
    .select2-container--default .select2-selection--single .select2-selection__arrow {
        height: 38px;
        right: 8px;
    }
    
    .select2-container--default .select2-selection--single .select2-selection__arrow b {
        border-width: 5px 4px 0 4px;
    }
    
    /* Multiple select - small phones */
    .select2-container--default .select2-selection--multiple {
        min-height: 40px;
        padding: 3px 6px;
    }
    
    .select2-container--default .select2-selection--multiple .select2-selection__choice {
        font-size: 12px;
        padding: 2px 6px;
    }
    
    .select2-search--dropdown .select2-search__field {
        font-size: 16px; /* Prevent zoom on iOS */
        height: 40px;
        padding: 8px 10px;
        background: #ffffff;
        color: #000000;
    }
    
    .select2-results__option {
        padding: 10px;
        font-size: 13px;
        min-height: 42px;
        color: #000000;
    }
    
    .select2-dropdown {
        max-height: 250px;
        background: #ffffff;
    }
    
    /* Compact filter sidebar for small phones */
    .filter-group .select2-container--default .select2-selection--single {
        height: 40px;
    }
    
    .filter-group .select2-container--default .select2-selection--single .select2-selection__rendered {
        line-height: 38px;
        font-size: 13px;
        padding-left: 10px;
        color: #000000;
    }
}

/* ========== Admin Panel Specific Styling ========== */
.admin-layout .select2-container--default .select2-selection--single,
.admin-layout .select2-container--default .select2-selection--multiple {
    border-color: #e2e8f0;
}

.admin-layout .select2-container--default.select2-container--focus .select2-selection--single,
.admin-layout .select2-container--default.select2-container--open .select2-selection--single,
.admin-layout .select2-container--default.select2-container--focus .select2-selection--multiple,
.admin-layout .select2-container--default.select2-container--open .select2-selection--multiple {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.admin-layout .select2-results__option--highlighted {
    background: rgba(59, 130, 246, 0.08) !important;
    color: #1e293b !important;
}

.admin-layout .select2-results__option--selected {
    background: #3b82f6 !important;
    color: white !important;
}

/* ========== Dark Mode Support (if needed in future) ========== */
/* Mobile Landscape Orientation */
@media (max-width: 768px) and (orientation: landscape) {
    .select2-dropdown {
        max-height: 200px; /* Shorter height in landscape */
    }
    
    .select2-results__option {
        padding: 10px 12px; /* Compact padding */
    }
}

/* Retina/High-DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .select2-container--default .select2-selection--single {
        border-width: 0.5px; /* Thinner border on retina */
    }
}



/* ========== Clear Selection Button ========== */
.select2-container--default .select2-selection--single .select2-selection__clear {
    color: #a40034;
    font-size: 18px;
    font-weight: 700;
    margin-right: 8px;
    cursor: pointer;
    transition: color 0.2s;
}

.select2-container--default .select2-selection--single .select2-selection__clear:hover {
    color: #8a002c;
}

/* ========== Accessibility Improvements ========== */
.select2-container--default .select2-selection--single:focus,
.select2-container--default .select2-selection--multiple:focus {
    outline: 2px solid #f7941d;
    outline-offset: 2px;
}

.select2-container--default .select2-results__option[aria-selected=true] {
    position: relative;
}

.select2-container--default .select2-results__option[aria-selected=true]::after {
    content: '✓';
    position: absolute;
    right: 16px;
    color: white;
    font-weight: 700;
}

/* ========== Animation ========== */
.select2-dropdown {
    animation: select2-fadeIn 0.2s ease;
}

@keyframes select2-fadeIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========== Z-Index Management ========== */
.select2-container--open {
    z-index: 9999;
}

.select2-dropdown {
    z-index: 10000;
}

/* Ensure dropdown appears above modals if needed */
.modal-open .select2-dropdown {
    z-index: 10500;
}

.modal-open .select2-container {
    z-index: 10500;
}
