/**
 * LANGUAGE & CURRENCY SELECTOR
 * Dropdown avec header fixe (onglets) et contenu scrollable
 */

/* ============================================
   CONTAINER
   ============================================ */
.lang-currency-selector {
    position: relative;
    display: inline-block;
}

/* ============================================
   TRIGGER BUTTON (Globe)
   ============================================ */
.globe-button {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    min-width: 48px;
    background: rgba(255, 255, 255, 0.12);
    border: 2px solid rgba(255, 255, 255, 0.25);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.25s ease;
    color: white;
    backdrop-filter: blur(10px);
}

.globe-button:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 215, 0, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.globe-button.loading {
    pointer-events: none;
    opacity: 0.7;
}

.globe-button.loading .globe-icon {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.globe-icon {
    width: 22px;
    height: 22px;
    stroke-width: 2;
}

.current-flag {
    font-size: 20px;
    line-height: 1;
}

.current-currency {
    font-size: 11px;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.2);
    padding: 3px 6px;
    border-radius: 4px;
    letter-spacing: 0.5px;
}

/* ============================================
   DROPDOWN PANEL
   ============================================ */
.selector-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 320px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    z-index: 10000;

    /* Animation */
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px) scale(0.96);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);

    /* Flex pour header fixe */
    display: flex;
    flex-direction: column;
    max-height: 420px;
}

.selector-dropdown.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Arrow pointer */
.selector-dropdown::before {
    content: '';
    position: absolute;
    top: -8px;
    right: 24px;
    width: 16px;
    height: 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    transform: rotate(45deg);
    z-index: -1;
}

/* ============================================
   HEADER FIXE (avec onglets)
   ============================================ */
.selector-header {
    flex-shrink: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 4px;
}

.selector-title {
    color: white;
    font-size: 13px;
    font-weight: 600;
    padding: 8px 12px 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ============================================
   TABS (onglets)
   ============================================ */
.selector-tabs {
    display: flex;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    padding: 4px;
    gap: 4px;
}

.selector-tab {
    flex: 1;
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.8);
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.selector-tab:hover {
    color: white;
    background: rgba(255, 255, 255, 0.1);
}

.selector-tab.active {
    color: #667eea;
    background: white;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* ============================================
   BODY (contenu scrollable)
   ============================================ */
.selector-body {
    flex: 1;
    overflow: hidden;
    background: white;
}

.selector-tab-content {
    display: none;
    padding: 8px;
    max-height: 320px;
    overflow-y: auto;
}

.selector-tab-content.active {
    display: block;
    animation: fadeSlide 0.2s ease;
}

@keyframes fadeSlide {
    from {
        opacity: 0;
        transform: translateX(8px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Scrollbar */
.selector-tab-content::-webkit-scrollbar,
.selector-options::-webkit-scrollbar {
    width: 6px;
}

.selector-tab-content::-webkit-scrollbar-track,
.selector-options::-webkit-scrollbar-track {
    background: #f5f5f5;
    border-radius: 3px;
}

.selector-tab-content::-webkit-scrollbar-thumb,
.selector-options::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.selector-tab-content::-webkit-scrollbar-thumb:hover,
.selector-options::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* ============================================
   OPTIONS (items)
   ============================================ */
.selector-options {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.selector-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: transparent;
    border: 2px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.selector-option:hover {
    background: rgba(102, 126, 234, 0.08);
    border-color: rgba(102, 126, 234, 0.2);
    transform: translateX(4px);
}

.selector-option.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.option-flag {
    font-size: 24px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f5f5f5;
    border-radius: 8px;
    flex-shrink: 0;
}

.selector-option.active .option-flag {
    background: rgba(255, 255, 255, 0.2);
}

.option-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.option-name {
    font-size: 14px;
    font-weight: 600;
    color: #2d3748;
}

.selector-option.active .option-name {
    color: white;
}

.option-code {
    font-size: 11px;
    font-weight: 700;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.selector-option.active .option-code {
    color: rgba(255, 255, 255, 0.8);
}

.option-check {
    font-size: 16px;
    color: #10b981;
    opacity: 0;
    transform: scale(0.5);
    transition: all 0.2s ease;
}

.selector-option.active .option-check {
    opacity: 1;
    color: #ffd700;
    transform: scale(1);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .globe-button {
        padding: 6px 10px;
    }

    .current-flag {
        font-size: 18px;
    }

    .current-currency {
        font-size: 10px;
        padding: 2px 4px;
    }

    .selector-dropdown {
        width: 290px;
        right: -10px;
        max-height: 380px;
    }

    .selector-tab {
        padding: 10px 12px;
        font-size: 12px;
    }

    .selector-tab-content {
        max-height: 280px;
    }

    .selector-option {
        padding: 10px;
    }

    .option-flag {
        width: 32px;
        height: 32px;
        font-size: 20px;
    }

    .option-name {
        font-size: 13px;
    }
}

/* ============================================
   DARK MODE
   ============================================ */
@media (prefers-color-scheme: dark) {
    .selector-dropdown {
        background: #1f2937;
        box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
    }

    .selector-dropdown::before {
        background: linear-gradient(135deg, #4c51bf 0%, #6b46c1 100%);
    }

    .selector-header {
        background: linear-gradient(135deg, #4c51bf 0%, #6b46c1 100%);
    }

    .selector-body {
        background: #1f2937;
    }

    .selector-tab.active {
        background: #1f2937;
        color: #a5b4fc;
    }

    .selector-option:hover {
        background: rgba(99, 102, 241, 0.15);
    }

    .option-flag {
        background: #374151;
    }

    .option-name {
        color: #e5e7eb;
    }

    .option-code {
        color: #9ca3af;
    }

    .selector-tab-content::-webkit-scrollbar-track,
    .selector-options::-webkit-scrollbar-track {
        background: #374151;
    }

    .selector-tab-content::-webkit-scrollbar-thumb,
    .selector-options::-webkit-scrollbar-thumb {
        background: #4b5563;
    }
}

/* ============================================
   RTL SUPPORT
   ============================================ */
html[dir="rtl"] .selector-dropdown {
    right: auto;
    left: 0;
}

html[dir="rtl"] .selector-dropdown::before {
    right: auto;
    left: 24px;
}

html[dir="rtl"] .selector-option:hover,
html[dir="rtl"] .selector-option.active {
    transform: translateX(-4px);
}
