/**
 * Language Menu Switch Pro - Frontend Styles
 * Version: 3.0.0
 */

/* ==== Language Switcher Container ==== */
.lmsp-switcher {
    position: relative;
    display: inline-block;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

/* ==== Dropdown Style ==== */
.lmsp-dropdown {
    position: relative;
}

.lmsp-toggle {
    cursor: pointer;
    padding: 10px 16px;
    border: 1px solid #4caf50;
    background: #66bb6a;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #ffffff;
    transition: all 0.2s ease;
    min-width: 140px;
    justify-content: space-between;
}

.lmsp-toggle:hover {
    border-color: #4caf50;
    background: #4caf50;
}

.lmsp-toggle:focus {
    outline: 2px solid #4caf50;
    outline-offset: 2px;
}

.lmsp-arrow {
    font-size: 10px;
    margin-left: auto;
    transition: transform 0.2s ease;
}

.lmsp-dropdown:hover .lmsp-arrow {
    transform: rotate(180deg);
}

.lmsp-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: #66bb6a;
    border: 1px solid #4caf50;
    border-radius: 0 0 6px 6px;
    border-top: none;
    min-width: 180px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 99999;
    opacity: 0;
    transform: translateY(0);
    transition: opacity 0.2s ease, transform 0.2s ease;
    margin-top: 0;
    padding-top: 0;
}

/* Remove bottom border-radius from toggle when dropdown is open */
.lmsp-dropdown:hover .lmsp-toggle,
.lmsp-dropdown.active .lmsp-toggle {
    border-radius: 6px 6px 0 0;
    border-bottom-color: transparent;
}

/* Invisible bridge to keep hover active when moving to menu */
.lmsp-dropdown::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: 20px;
    background: transparent;
    pointer-events: auto;
}

.lmsp-dropdown:hover .lmsp-menu,
.lmsp-dropdown.active .lmsp-menu {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

.lmsp-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    text-decoration: none;
    color: #ffffff;
    transition: background 0.2s ease, color 0.2s ease;
    border-bottom: 1px solid #4caf50;
}

.lmsp-option:last-child {
    border-bottom: none;
}

.lmsp-option:hover {
    background: #81c784;
    color: #ffffff;
}

.lmsp-option.active {
    background: #4caf50;
    color: #ffffff;
    font-weight: 600;
}

/* ==== Button Style ==== */
.lmsp-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.lmsp-button {
    padding: 8px 14px;
    border: 1px solid #4caf50;
    background: #66bb6a;
    text-decoration: none;
    color: #ffffff;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
    font-size: 14px;
}

.lmsp-button:hover {
    background: #4caf50;
    border-color: #4caf50;
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.lmsp-button.active {
    background: #4caf50;
    color: #fff;
    border-color: #4caf50;
    font-weight: 600;
}

.lmsp-button.active:hover {
    background: #43a047;
    border-color: #43a047;
}

/* ==== Flag and Name ==== */
.lmsp-flag {
    font-size: 1.3em;
    line-height: 1;
}

.lmsp-flag-img {
    width: 24px;
    height: 18px;
    border-radius: 2px;
    object-fit: cover;
    vertical-align: middle;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.lmsp-name {
    font-size: 14px;
    white-space: nowrap;
}

.lmsp-code {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

/* ==== RTL Support ==== */
/* For Hebrew (RTL), position switcher on the right side */
.rtl .lmsp-switcher,
.lang-he .lmsp-switcher {
    float: right;
    direction: rtl;
}

.rtl .lmsp-dropdown,
.lang-he .lmsp-dropdown {
    direction: rtl;
}

.rtl .lmsp-menu,
.lang-he .lmsp-menu {
    left: auto;
    right: 0;
}

.rtl .lmsp-arrow,
.lang-he .lmsp-arrow {
    margin-left: 0;
    margin-right: auto;
}

/* For LTR languages, position switcher on the left */
.ltr .lmsp-switcher,
.lang-en .lmsp-switcher,
.lang-ru .lmsp-switcher,
.lang-es .lmsp-switcher,
.lang-pt .lmsp-switcher,
.lang-de .lmsp-switcher,
.lang-it .lmsp-switcher {
    float: left;
    direction: ltr;
}

/* ==== Mobile Responsive ==== */
@media (max-width: 768px) {
    /* Switcher container - ensure it doesn't overflow */
    .lmsp-switcher {
        max-width: 100%;
    }

    /* Toggle button - more compact on tablet */
    .lmsp-toggle {
        padding: 8px 12px;
        min-width: auto;
        font-size: 13px;
        white-space: nowrap;
    }

    /* Dropdown menu - better positioning on mobile */
    .lmsp-menu {
        min-width: 160px;
        left: auto;
        right: 0;
    }

    /* RTL fix for mobile */
    .rtl .lmsp-menu,
    .lang-he .lmsp-menu {
        left: 0;
        right: auto;
    }

    /* Options - slightly smaller padding */
    .lmsp-option {
        padding: 10px 12px;
        font-size: 13px;
    }

    /* Button style - compact */
    .lmsp-button {
        padding: 6px 10px;
        font-size: 13px;
    }

    /* Language name - slightly smaller */
    .lmsp-name {
        font-size: 13px;
    }

    /* Flag emoji - slightly smaller */
    .lmsp-flag {
        font-size: 1.2em;
    }
}

@media (max-width: 480px) {
    /* Switcher - full width if needed */
    .lmsp-switcher {
        display: inline-flex;
        max-width: 100%;
    }

    /* Toggle button - even more compact */
    .lmsp-toggle {
        padding: 6px 10px;
        min-width: auto;
        font-size: 12px;
        gap: 6px;
    }

    /* Dropdown menu - full width on very small screens */
    .lmsp-menu {
        min-width: 140px;
        max-width: 200px;
        right: 0;
        left: auto;
    }

    /* RTL fix for very small mobile */
    .rtl .lmsp-menu,
    .lang-he .lmsp-menu {
        left: 0;
        right: auto;
    }

    /* Options - compact */
    .lmsp-option {
        padding: 8px 10px;
        font-size: 12px;
        gap: 6px;
    }

    /* Button style - very compact */
    .lmsp-buttons {
        gap: 4px;
        flex-wrap: wrap;
        justify-content: center;
    }

    .lmsp-button {
        padding: 5px 8px;
        font-size: 11px;
        gap: 4px;
    }

    /* Show flag always, but make name optional */
    .lmsp-flag {
        font-size: 1.1em;
        display: inline-block;
    }

    /* Keep language name visible but smaller */
    .lmsp-name {
        font-size: 11px;
        display: inline-block;
    }

    /* Language code - smaller */
    .lmsp-code {
        font-size: 10px;
    }

    /* Arrow - smaller */
    .lmsp-arrow {
        font-size: 8px;
    }
}

/* ==== Very Small Screens (< 360px) ==== */
@media (max-width: 360px) {
    /* On very small screens, hide text but keep flags */
    .lmsp-name {
        display: none;
    }

    /* Make toggle even more compact */
    .lmsp-toggle {
        min-width: 50px;
        padding: 6px 8px;
    }

    /* Show only flags in options */
    .lmsp-option .lmsp-name {
        display: none;
    }

    /* Buttons - flags only */
    .lmsp-button .lmsp-code {
        display: none;
    }
}

/* ==== Dark Mode Support ==== */
@media (prefers-color-scheme: dark) {
    .lmsp-toggle,
    .lmsp-menu,
    .lmsp-button {
        background: #1e1e1e;
        border-color: #444;
        color: #e0e0e0;
    }

    .lmsp-toggle:hover,
    .lmsp-button:hover {
        background: #2a2a2a;
        border-color: #0073aa;
    }

    .lmsp-option {
        color: #e0e0e0;
        border-bottom-color: #333;
    }

    .lmsp-option:hover {
        background: #2a2a2a;
        color: #4a9eff;
    }

    .lmsp-option.active {
        background: #1a3a52;
        color: #4a9eff;
    }

    .lmsp-button.active {
        background: #0073aa;
        color: #fff;
        border-color: #0073aa;
    }
}

/* ==== Accessibility ==== */
.lmsp-toggle:focus,
.lmsp-option:focus,
.lmsp-button:focus {
    outline: 2px solid #4caf50;
    outline-offset: 2px;
}

.lmsp-toggle:focus:not(:focus-visible),
.lmsp-option:focus:not(:focus-visible),
.lmsp-button:focus:not(:focus-visible) {
    outline: none;
}

/* ==== Animation ==== */
@keyframes lmsp-fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.lmsp-menu {
    animation: lmsp-fadeIn 0.2s ease;
}

/* ==== Elementor Menu Integration ==== */
/* When language switcher is inside Elementor menu */
.elementor-nav-menu .lmsp-switcher,
.elementor-widget-nav-menu .lmsp-switcher {
    display: inline-block;
    vertical-align: middle;
}

/* Header positioning removed - user will configure in Elementor */

/* ==== Print Styles ==== */
@media print {
    .lmsp-switcher {
        display: none !important;
    }
}
