/**
 * Polyglot AI Public Styles
 * Base styles only - theme-specific styles are in separate files:
 * - public-divi4.css: Divi 4 (Classic) styles
 * - public-divi5.css: Divi 5 (Theme Builder) styles
 * - public-elementor.css: Elementor styles
 */

/* ==========================================================================
   Base Styles - Used by all themes
   ========================================================================== */

/* Switcher Container */
.polyglot-switcher {
    position: relative;
    display: inline-block;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    z-index: 1000;
}

/* Flag Images */
.polyglot-flag {
    width: 20px;
    height: 15px;
    object-fit: cover;
    border-radius: 2px;
    vertical-align: middle;
}

/* Flag Emoji */
.polyglot-flag-emoji {
    font-size: 1.2em;
    line-height: 1;
    vertical-align: middle;
}

/* Floating Switcher */
.polyglot-floating-switcher {
    position: fixed !important;
    top: 20px !important;
    right: 20px !important;
    margin: 0 10px;
    z-index: 99999999 !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Dropdown Style */
.polyglot-dropdown {
    position: relative;
    z-index: 999999 !important;
}

.polyglot-dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    color: #333;
    transition: all 0.2s ease;
}

.polyglot-dropdown-toggle:hover {
    background: #f5f5f5;
    border-color: #ccc;
}

.polyglot-dropdown-arrow {
    font-size: 10px;
    margin-left: 4px;
    transition: transform 0.2s ease;
}

.polyglot-dropdown.open .polyglot-dropdown-arrow {
    transform: rotate(180deg);
}

.polyglot-dropdown-menu {
    position: absolute;
    top: 100%;
    left: auto;
    right: 0;
    margin: 4px 0 0 !important;
    padding: 4px 0 !important;
    list-style: none;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: opacity 0.2s ease, visibility 0.2s ease;
    min-width: 150px;
    z-index: 999999 !important;
}

.polyglot-dropdown.open .polyglot-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: none;
    z-index: 999999 !important;
    position: fixed !important;
}

.polyglot-dropdown.open {
    z-index: 999999 !important;
}

li.polyglot-menu-switcher:has(.polyglot-dropdown.open) {
    z-index: 999999 !important;
}

.polyglot-dropdown-menu li,
.polyglot-dropdown-menu > li {
    margin: 0 !important;
    padding: 0 !important;
    list-style: none !important;
    border: none !important;
    background: none !important;
}

.polyglot-dropdown-menu li a,
.polyglot-dropdown-menu > li > a {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    padding: 8px 12px !important;
    margin: 0 !important;
    color: #333 !important;
    text-decoration: none !important;
    transition: background 0.2s ease !important;
    font-size: 14px !important;
    line-height: 1.4 !important;
    min-height: auto !important;
    height: auto !important;
}

.polyglot-dropdown-menu li a:hover,
.polyglot-dropdown-menu > li > a:hover {
    background: #f5f5f5 !important;
}

.polyglot-dropdown-menu li.polyglot-current,
.polyglot-dropdown-menu > li.polyglot-current {
    background: #f0f7ff !important;
    display: block !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

.polyglot-dropdown-menu li.polyglot-current a,
.polyglot-dropdown-menu > li.polyglot-current > a {
    font-weight: 500 !important;
    display: flex !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

/* ==========================================================================
   Portaled Dropdown Menu (moved to body via JavaScript)
   These styles apply when the dropdown is portaled for z-index escape
   ========================================================================== */

body > .polyglot-dropdown-menu {
    background: #fff !important;
    background-color: #fff !important;
    border: 1px solid #ddd !important;
    border-radius: 4px !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
    padding: 4px 0 !important;
    min-width: 150px !important;
    z-index: 2147483647 !important;
}

body > .polyglot-dropdown-menu li {
    display: block !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    background-color: transparent !important;
    border: none !important;
    list-style: none !important;
    float: none !important;
}

body > .polyglot-dropdown-menu li a {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    padding: 8px 12px !important;
    margin: 0 !important;
    color: #333 !important;
    background: transparent !important;
    background-color: transparent !important;
    text-decoration: none !important;
    font-size: 14px !important;
    line-height: 1.4 !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

body > .polyglot-dropdown-menu li a:hover {
    background: #f5f5f5 !important;
    background-color: #f5f5f5 !important;
}

body > .polyglot-dropdown-menu li.polyglot-current {
    background: #f0f7ff !important;
    background-color: #f0f7ff !important;
}

body > .polyglot-dropdown-menu li.polyglot-current a {
    font-weight: 500 !important;
}

/* Remove any separators from dropdown items */
body > .polyglot-dropdown-menu li::after,
body > .polyglot-dropdown-menu li::before {
    content: none !important;
    display: none !important;
}

/* Flags Style */
.polyglot-flags-container {
    display: flex;
    align-items: center !important;
    gap: 6px;
    max-width: 100%;
    min-height: 20px;
}

.polyglot-flags-scroll-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    padding: 0;
    margin: 0;
    border: 1px solid #ddd;
    border-radius: 50%;
    background: #fff;
    color: #666;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s ease;
    font-size: 10px;
    line-height: 1;
}

.polyglot-flags-scroll-btn:hover {
    background: #f5f5f5;
    border-color: #ccc;
    color: #333;
}

.polyglot-flags-scroll-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.polyglot-flags-container.has-overflow .polyglot-flags-scroll-btn {
    display: flex;
}

.polyglot-flags-wrapper {
    overflow: hidden;
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center !important;
    height: 100%;
}

.polyglot-flags-list {
    display: flex;
    align-items: center !important;
    justify-content: flex-start;
    gap: 4px;
    list-style: none !important;
    list-style-type: none !important;
    margin: 0 !important;
    padding: 0 !important;
    transition: transform 0.3s ease;
}

.polyglot-flags-list li,
.polyglot-flags-list > li {
    margin: 0 !important;
    padding: 0 !important;
    list-style: none !important;
    list-style-type: none !important;
    flex-shrink: 0;
}

.polyglot-flags-list li a {
    display: flex;
    align-items: center;
    padding: 0 2px;
    border-radius: 3px;
    transition: all 0.2s ease;
    opacity: 0.7;
    line-height: 1;
}

.polyglot-flags-list li a:hover {
    opacity: 1;
    transform: scale(1.1);
}

.polyglot-flags-list li.polyglot-current a {
    opacity: 1;
    background: rgba(0, 0, 0, 0.08);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.polyglot-flags-list .polyglot-flag {
    width: auto;
    height: 14px;
    display: block;
    object-fit: contain;
    vertical-align: middle;
}

/* Text List Style */
.polyglot-text-list {
    display: flex;
    align-items: center;
    gap: 4px;
    list-style: none !important;
    list-style-type: none !important;
    margin: 0;
    padding: 0;
}

.polyglot-text-list li,
.polyglot-text-list > li {
    margin: 0 !important;
    padding: 0 !important;
    list-style: none !important;
    list-style-type: none !important;
    display: flex;
    align-items: center;
}

.polyglot-text-list li:not(:last-child)::after {
    content: "|";
    margin-left: 4px;
    color: #999;
}

.polyglot-text-list li a {
    color: #666;
    text-decoration: none;
    font-size: 12px;
    font-weight: 400;
    letter-spacing: 0.5px;
    transition: color 0.2s ease;
    white-space: nowrap;
}

.polyglot-text-list li a:hover {
    color: #333;
}

.polyglot-text-list li.polyglot-current a {
    color: #0073aa;
    font-weight: 600;
}

/* Menu Item Switcher */
.polyglot-menu-switcher {
    position: relative;
}

.polyglot-menu-switcher .polyglot-switcher {
    display: flex;
    align-items: center;
    height: 100%;
}

/* RTL Support */
[dir="rtl"] .polyglot-dropdown-toggle {
    flex-direction: row-reverse;
}

[dir="rtl"] .polyglot-dropdown-menu li a {
    flex-direction: row-reverse;
}

[dir="rtl"] .polyglot-floating-switcher {
    right: auto !important;
    left: 20px !important;
}

/* Responsive */
@media screen and (max-width: 768px) {
    .polyglot-floating-switcher {
        right: 10px !important;
    }

    .polyglot-dropdown-toggle {
        padding: 6px 10px;
        font-size: 13px;
    }

    .polyglot-dropdown-toggle .polyglot-lang-name {
        display: none;
    }

    .polyglot-flag {
        width: 18px;
        height: 13px;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .polyglot-dropdown-toggle {
        background: #2d2d2d;
        border-color: #444;
        color: #fff;
    }

    .polyglot-dropdown-toggle:hover {
        background: #3d3d3d;
    }

    .polyglot-dropdown-menu {
        background: #2d2d2d;
        border-color: #444;
    }

    .polyglot-dropdown-menu li a,
    .polyglot-dropdown-menu > li > a {
        color: #fff !important;
    }

    .polyglot-dropdown-menu li a:hover,
    .polyglot-dropdown-menu > li > a:hover {
        background: #3d3d3d !important;
    }

    .polyglot-dropdown-menu li.polyglot-current,
    .polyglot-dropdown-menu > li.polyglot-current {
        background: #1a365d !important;
    }

    .polyglot-text-list li a {
        color: #aaa;
    }

    .polyglot-text-list li a:hover {
        color: #fff;
    }

    .polyglot-flags-scroll-btn {
        background: #2d2d2d;
        border-color: #444;
        color: #fff;
    }

    .polyglot-flags-scroll-btn:hover {
        background: #3d3d3d;
        border-color: #555;
    }

    .polyglot-flags-list li.polyglot-current a {
        background: rgba(255, 255, 255, 0.1);
    }
}
