/* ==================== SEARCHABLE COUNTRY DROPDOWN COMPONENT ==================== */
/* Reusable searchable select component for country/dial code selection */
/* Include this CSS wherever you need the searchable country dropdown */

/* Phone Input Wrapper */
.js-phone-input-wrapper {
    display: flex;
    gap: 0.75rem;
    align-items: stretch;
}

.js-phone-input {
    flex: 1;
    background: linear-gradient(145deg, rgba(30, 41, 59, 0.8), rgba(15, 23, 42, 0.9));
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 10px;
    padding: 0.625rem 1rem;
    color: var(--text-primary, #f0f6fc);
    font-size: 0.95rem;
    transition: all 0.2s ease;
    min-height: 44px;
}

.js-phone-input:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.js-phone-input::placeholder {
    color: var(--text-muted, #8b949e);
}
.js-searchable-dropdown{
    min-width: 307px;
}
/* Searchable Select Container */
.js-searchable-select-container {
    position: relative;
    min-width: 180px;
    flex-shrink: 0;
    z-index: 1;
}
.recovery-form-group .js-searchable-select-container{
    min-width: 250px;
}
/* When dropdown is open, ensure container is above other elements */
.js-searchable-select-container:has(.js-searchable-dropdown.open) {
    z-index: 9998;
}

.js-searchable-select-container.full-width {
    min-width: 100%;
    width: 100%;
}

/* Trigger Button */
.js-searchable-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.625rem 0.875rem;
    background: linear-gradient(145deg, rgba(30, 41, 59, 0.9), rgba(15, 23, 42, 0.95));
    border: 1px solid rgba(99, 102, 241, 0.35);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 53px;
}

.js-searchable-select-trigger:hover {
    border-color: rgba(99, 102, 241, 0.6);
    background: linear-gradient(145deg, rgba(30, 41, 59, 1), rgba(15, 23, 42, 1));
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.js-searchable-select-trigger.open {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
    border-radius: 10px 10px 0 0;
}

/* Selected Country Display */
.js-selected-country {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    flex: 1;
    min-width: 0;
}

.js-selected-country .js-country-flag {
    font-size: 1.375rem;
    line-height: 1;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.2));
}

.js-selected-country .js-country-text {
    color: #e2e8f0;
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100px;
}

.js-searchable-select-container.full-width .js-selected-country .js-country-text {
    max-width: none;
}

.js-selected-country .js-country-dial-display {
    color: #c7d2fe;
    font-size: 0.9rem;
    font-weight: 600;
    background: rgba(99, 102, 241, 0.25);
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
}

/* Dropdown Arrow */
.js-dropdown-arrow {
    color: #94a3b8;
    font-size: 0.8rem;
    transition: transform 0.3s ease;
}

.js-searchable-select-trigger.open .js-dropdown-arrow {
    transform: rotate(180deg);
    color: #a5b4fc;
}

/* Dropdown Panel */
.js-searchable-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    border: 1px solid rgba(99, 102, 241, 0.5);
    border-top: none;
    border-radius: 0 0 12px 12px;
    box-shadow: 
        0 20px 40px rgba(0, 0, 0, 0.6),
        0 0 0 1px rgba(99, 102, 241, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    max-height: 0;
    overflow: hidden;
}

.js-searchable-dropdown.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    max-height: 380px;
}

/* Open dropdown upward when not enough space below */
.js-searchable-dropdown.open-up {
    top: auto;
    bottom: 100%;
    border-radius: 12px 12px 0 0;
    border-top: 1px solid rgba(99, 102, 241, 0.5);
    border-bottom: none;
    box-shadow: 
        0 -20px 40px rgba(0, 0, 0, 0.6),
        0 0 0 1px rgba(99, 102, 241, 0.2),
        inset 0 -1px 0 rgba(255, 255, 255, 0.05);
}

.js-searchable-select-trigger.open {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

/* When opening up, change trigger border-radius */
.js-searchable-select-container:has(.js-searchable-dropdown.open-up) .js-searchable-select-trigger.open {
    border-radius: 0 0 10px 10px;
}

/* Search Input */
.js-search-input-wrapper {
    position: sticky;
    top: 0;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    background: linear-gradient(180deg, #1e293b 0%, rgba(30, 41, 59, 0.98) 100%);
    border-bottom: 1px solid rgba(99, 102, 241, 0.25);
    z-index: 10;
}

.js-search-input-wrapper i {
    color: #94a3b8;
    font-size: 1rem;
}

.js-search-input-wrapper input {
    flex: 1;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 8px;
    padding: 0.625rem 0.875rem;
    color: #f1f5f9;
    font-size: 0.95rem;
    outline: none;
    transition: all 0.2s ease;
}

.js-search-input-wrapper input::placeholder {
    color: #64748b;
}

.js-search-input-wrapper input:focus {
    border-color: #6366f1;
    background: rgba(15, 23, 42, 1);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* Country List */
.js-country-list {
    max-height: 300px;
    overflow-y: auto;
    padding: 0.375rem 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(99, 102, 241, 0.4) rgba(15, 23, 42, 0.5);
}

.js-country-list::-webkit-scrollbar {
    width: 8px;
}

.js-country-list::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.5);
    border-radius: 4px;
}

.js-country-list::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, rgba(99, 102, 241, 0.5) 0%, rgba(139, 92, 246, 0.4) 100%);
    border-radius: 4px;
}

.js-country-list::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, rgba(99, 102, 241, 0.7) 0%, rgba(139, 92, 246, 0.6) 100%);
}

/* Group Headers */
.js-country-group-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    color: #a5b4fc;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.15) 0%, rgba(99, 102, 241, 0.05) 100%);
    margin-top: 0.25rem;
    border-bottom: 1px solid rgba(99, 102, 241, 0.1);
}

.js-country-group-header:first-child {
    margin-top: 0;
}

.js-country-group-header i {
    font-size: 0.7rem;
    color: #fbbf24;
}

/* Country Items */
.js-country-item {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: all 0.15s ease;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.js-country-item:hover {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2) 0%, rgba(139, 92, 246, 0.15) 100%);
}

.js-country-item.selected {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.25) 0%, rgba(139, 92, 246, 0.2) 100%);
    border-left: 3px solid #6366f1;
}

.js-country-item .js-country-flag {
    font-size: 1.5rem;
    line-height: 1;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3));
}

.js-country-item .js-country-name {
    flex: 1;
    color: #f1f5f9;
    font-size: 0.95rem;
    font-weight: 500;
    letter-spacing: 0.01em;
}

.js-country-item:hover .js-country-name {
    color: #ffffff;
}

.js-country-item .js-country-dial {
    color: #a5b4fc;
    font-size: 0.9rem;
    font-weight: 600;
    background: rgba(99, 102, 241, 0.2);
    padding: 0.25rem 0.625rem;
    border-radius: 6px;
    min-width: 50px;
    text-align: center;
}

.js-country-item:hover .js-country-dial {
    background: rgba(99, 102, 241, 0.35);
    color: #c7d2fe;
}

/* No Results */
.js-no-results {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 2rem 1rem;
    color: #94a3b8;
    text-align: center;
}

.js-no-results i {
    font-size: 2rem;
    opacity: 0.6;
    color: #6366f1;
}

.js-no-results span {
    font-size: 0.95rem;
    font-weight: 500;
}

/* ==================== LIGHT THEME ==================== */
body.light-theme .js-phone-input {
    background: #ffffff;
    border-color: #e2e8f0;
    color: #0f172a;
}

body.light-theme .js-phone-input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

body.light-theme .js-phone-input::placeholder {
    color: #94a3b8;
}

body.light-theme .js-searchable-select-trigger {
    background: #ffffff;
    border-color: #e2e8f0;
}

body.light-theme .js-searchable-select-trigger:hover {
    border-color: #cbd5e1;
    background: #f8fafc;
}

body.light-theme .js-searchable-select-trigger.open {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

body.light-theme .js-selected-country .js-country-text {
    color: #0f172a;
}

body.light-theme .js-selected-country .js-country-dial-display {
    background: rgba(99, 102, 241, 0.1);
    color: #6366f1;
}

body.light-theme .js-dropdown-arrow {
    color: #64748b;
}

body.light-theme .js-searchable-dropdown {
    background: #ffffff;
    border-color: #e2e8f0;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(0, 0, 0, 0.05);
}

body.light-theme .js-search-input-wrapper {
    background: #f8fafc;
    border-bottom-color: #e2e8f0;
}

body.light-theme .js-search-input-wrapper i {
    color: #64748b;
}

body.light-theme .js-search-input-wrapper input {
    background: #ffffff;
    border-color: #e2e8f0;
    color: #0f172a;
}

body.light-theme .js-search-input-wrapper input::placeholder {
    color: #94a3b8;
}

body.light-theme .js-search-input-wrapper input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.1);
}

body.light-theme .js-country-list {
    scrollbar-color: rgba(99, 102, 241, 0.3) transparent;
}

body.light-theme .js-country-list::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.3);
}

body.light-theme .js-country-group-header {
    color: #64748b;
    background: rgba(99, 102, 241, 0.05);
}

body.light-theme .js-country-group-header i {
    color: #6366f1;
}

body.light-theme .js-country-item:hover {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(139, 92, 246, 0.05) 100%);
}

body.light-theme .js-country-item.selected {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15) 0%, rgba(139, 92, 246, 0.1) 100%);
}

body.light-theme .js-country-item .js-country-name {
    color: #0f172a;
}

body.light-theme .js-country-item .js-country-dial {
    color: #6366f1;
    background: rgba(99, 102, 241, 0.1);
}

body.light-theme .js-country-item:hover .js-country-dial {
    background: rgba(99, 102, 241, 0.15);
}

body.light-theme .js-no-results {
    color: #64748b;
}

/* ==================== RTL SUPPORT ==================== */
[dir="rtl"] .js-phone-input-wrapper {
    flex-direction: row-reverse;
}

[dir="rtl"] .js-searchable-select-trigger {
    flex-direction: row-reverse;
}

[dir="rtl"] .js-selected-country {
    flex-direction: row-reverse;
}

[dir="rtl"] .js-country-item {
    flex-direction: row-reverse;
}

[dir="rtl"] .js-search-input-wrapper {
    flex-direction: row-reverse;
}

[dir="rtl"] .js-country-group-header {
    flex-direction: row-reverse;
}

/* ==================== RESPONSIVE STYLES ==================== */
@media (max-width: 768px) {
    .js-phone-input-wrapper {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .js-searchable-select-container {
        min-width: 100%;
        width: 100%;
    }
    
    .js-selected-country .js-country-text {
        max-width: none;
    }
    
    .js-searchable-dropdown {
        max-height: 300px;
    }
    
    .js-country-list {
        max-height: 240px;
    }
}

/* ==================== FORM INTEGRATION ==================== */
/* For use with standard form controls */
.form-group .js-searchable-select-container {
    width: 100%;
}

.phone-grid .js-searchable-select-container {
    min-width: 140px;
}

.phone-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.5rem;
    align-items: stretch;
}

@media (max-width: 480px) {
    .phone-grid {
        grid-template-columns: 1fr;
    }
    
    .phone-grid .js-searchable-select-container {
        min-width: 100%;
    }
}
