/**
 * Frontend styles for WPrad Consultations Translator
 * Supports both LTR and RTL layouts
 */

/* ========================================
   Base Language Switcher Styles
   ======================================== */

.wpct-language-switcher {
    display: inline-block;
    position: relative;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

.wpct-language-switcher *,
.wpct-language-switcher *:before,
.wpct-language-switcher *:after {
    box-sizing: border-box;
}

.wpct-language-switcher a {
    text-decoration: none;
    color: inherit;
    transition: all 0.3s ease;
}

.wpct-language-switcher a:hover {
    color: #2271b1;
}

/* ========================================
   Dropdown Style
   ======================================== */

.wpct-dropdown {
    position: relative;
    display: inline-block;
}

.wpct-dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 15px;
    background: #fff;
    border: 1px solid #dcdcde;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    color: #2c3338;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.wpct-dropdown-toggle:hover {
    border-color: #2271b1;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.wpct-dropdown-toggle:focus {
    outline: 2px solid #2271b1;
    outline-offset: 2px;
}

.wpct-dropdown-arrow {
    font-size: 10px;
    margin-left: 5px;
    transition: transform 0.3s ease;
}

.wpct-dropdown.active .wpct-dropdown-arrow {
    transform: rotate(180deg);
}

.wpct-dropdown-content {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 5px;
    background: #fff;
    border: 1px solid #dcdcde;
    border-radius: 4px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    min-width: 180px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    list-style: none;
    margin: 0;
    padding: 0;
}

.wpct-dropdown.active .wpct-dropdown-content {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.wpct-dropdown-content li {
    margin: 0;
    border-bottom: 1px solid #f0f0f1;
}

.wpct-dropdown-content li:last-child {
    border-bottom: none;
}

.wpct-dropdown-content a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 15px;
    color: #2c3338;
    transition: all 0.2s ease;
}

.wpct-dropdown-content a:hover {
    background: #f6f7f7;
    color: #2271b1;
}

.wpct-dropdown-content a.current {
    background: #f0f8ff;
    font-weight: 600;
}

.wpct-current-indicator {
    margin-left: auto;
    color: #00a32a;
}

/* ========================================
   List Style
   ======================================== */

.wpct-style-list .wpct-language-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.wpct-style-list .wpct-language-item {
    margin: 0;
}

.wpct-style-list .wpct-language-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 10px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.wpct-style-list .wpct-language-link:hover {
    background: #f6f7f7;
}

.wpct-style-list .wpct-language-item.current .wpct-language-link {
    background: #f0f8ff;
    font-weight: 600;
}

/* ========================================
   Flags Style
   ======================================== */

.wpct-style-flags .wpct-flags-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 10px;
    align-items: center;
}

.wpct-style-flags .wpct-flag-item {
    margin: 0;
}

.wpct-style-flags .wpct-language-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 5px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.wpct-style-flags .wpct-language-link:hover {
    transform: scale(1.1);
}

.wpct-style-flags .wpct-language-link.current {
    position: relative;
}

.wpct-style-flags .wpct-language-link.current::after {
    content: '✓';
    position: absolute;
    bottom: -5px;
    right: -5px;
    background: #00a32a;
    color: #fff;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
}

.wpct-language-code {
    font-size: 11px;
    font-weight: 600;
    color: #646970;
}

/* ========================================
   Inline Style
   ======================================== */

.wpct-style-inline .wpct-inline-switcher {
    display: flex;
    align-items: center;
    gap: 5px;
}

.wpct-style-inline .wpct-separator {
    color: #dcdcde;
    margin: 0 5px;
}

.wpct-style-inline .wpct-language-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 8px;
    border-radius: 3px;
}

.wpct-style-inline .wpct-language-link:hover {
    background: #f6f7f7;
}

.wpct-style-inline .wpct-language-link.current {
    font-weight: 600;
    color: #2271b1;
}

/* ========================================
   Flags
   ======================================== */

.wpct-flag {
    display: inline-block;
    width: 20px;
    height: 15px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    border-radius: 2px;
    box-shadow: 0 0 1px rgba(0,0,0,0.2);
}

.wpct-flag-small {
    width: 16px;
    height: 12px;
}

.wpct-flag-large {
    width: 32px;
    height: 24px;
}

/* Flag backgrounds - Using emoji as fallback */
.wpct-flag-en,
.wpct-flag-en_US,
.wpct-flag-us,
.wpct-flag-gb {
    background: linear-gradient(180deg, #012169 0%, #012169 33.33%, #fff 33.33%, #fff 66.66%, #C8102E 66.66%, #C8102E 100%);
}

.wpct-flag-ar,
.wpct-flag-ae,
.wpct-flag-sa {
    background: linear-gradient(90deg, #00732F 0%, #00732F 25%, #fff 25%, #fff 50%, #000 50%, #000 75%, #EE2737 75%, #EE2737 100%);
}

/* Alternative: Using emoji flags */
.wpct-flag::before {
    content: '';
    display: block;
    width: 100%;
    height: 100%;
    text-align: center;
    line-height: 1;
}

.wpct-flag-en::before,
.wpct-flag-en_US::before { content: '🇺🇸'; }
.wpct-flag-gb::before { content: '🇬🇧'; }
.wpct-flag-ar::before,
.wpct-flag-ae::before { content: '🇦🇪'; }
.wpct-flag-sa::before { content: '🇸🇦'; }

/* ========================================
   Widget Styles
   ======================================== */

.wpct-widget-switcher {
    margin: 15px 0;
}

.wpct-widget-vertical .wpct-language-list {
    flex-direction: column;
}

.wpct-widget-horizontal .wpct-language-list {
    flex-direction: row;
    flex-wrap: wrap;
}

.widget .wpct-language-switcher {
    width: 100%;
}

.widget .wpct-dropdown-toggle {
    width: 100%;
    justify-content: space-between;
}

.widget .wpct-dropdown-content {
    width: 100%;
}

/* ========================================
   Menu Integration
   ======================================== */

.wpct-menu-language-switcher {
    position: relative;
}

.wpct-menu-language-switcher .wpct-language-switcher {
    padding: 0;
    margin: 0;
}

.wpct-menu-language-switcher .wpct-dropdown-toggle {
    background: transparent;
    border: none;
    padding: 10px 15px;
}

.wpct-menu-language-switcher .wpct-dropdown-content {
    right: auto;
    left: 0;
}

/* Align right in header menus */
.menu-item.wpct-menu-language-switcher {
    margin-left: auto;
}

/* ========================================
   Mobile Styles
   ======================================== */

@media (max-width: 768px) {
    .wpct-dropdown-content {
        position: fixed;
        left: 10px !important;
        right: 10px !important;
        width: auto !important;
        max-width: 400px;
        margin: 0 auto;
    }
    
    .wpct-style-list .wpct-language-list {
        flex-direction: column;
    }
    
    .wpct-style-flags .wpct-flags-list {
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .wpct-dropdown-toggle {
        padding: 10px 15px;
        font-size: 16px;
    }
    
    .wpct-dropdown-content a {
        padding: 12px 15px;
        font-size: 16px;
    }
}

/* ========================================
   Accessibility
   ======================================== */

.wpct-language-switcher a:focus,
.wpct-dropdown-toggle:focus {
    outline: 2px solid #2271b1;
    outline-offset: 2px;
}

/* Screen reader text */
.wpct-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

/* ========================================
   Loading State
   ======================================== */

.wpct-language-switcher.wpct-loading {
    opacity: 0.6;
    pointer-events: none;
}

.wpct-language-switcher.wpct-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #2271b1;
    border-radius: 50%;
    animation: wpct-spin 1s linear infinite;
}

@keyframes wpct-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ========================================
   Dark Theme Support
   ======================================== */

@media (prefers-color-scheme: dark) {
    .wpct-dropdown-toggle {
        background: #1e1e1e;
        border-color: #3c434a;
        color: #f0f0f1;
    }
    
    .wpct-dropdown-content {
        background: #1e1e1e;
        border-color: #3c434a;
    }
    
    .wpct-dropdown-content a {
        color: #f0f0f1;
    }
    
    .wpct-dropdown-content a:hover {
        background: #2c3338;
        color: #72aee6;
    }
    
    .wpct-dropdown-content a.current {
        background: #2c3338;
    }
}

/* ========================================
   Theme Compatibility
   ======================================== */

/* Twenty Twenty-One */
.theme-twentytwentyone .wpct-dropdown-toggle {
    font-family: var(--global--font-primary);
}

/* Twenty Twenty */
.theme-twentytwenty .wpct-language-switcher {
    font-family: "Inter var", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, sans-serif;
}

/* Astra */
.ast-theme-transparent-header .wpct-dropdown-toggle {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.2);
    color: #fff;
}

/* Elementor */
.elementor-widget .wpct-language-switcher {
    width: auto;
    display: inline-block;
}