/**
 * LinguaLink Public-Facing Styles
 *
 * This file contains the styles for the language switcher menu displayed
 * on the frontend of the website.
 *
 * @version 1.1.0
 * @author Mohsen Khatami
 */

/* ==========================================================================
   CSS Variables for Easy Theming
   ========================================================================== */
:root {
    --ll-primary-color: #0073aa; /* WordPress blue */
    --ll-border-color: #e0e0e0;
    --ll-background-hover: #f0f6fc;
    --ll-dropdown-shadow: 0 5px 15px rgba(0, 0, 0, 0.12);
    --ll-dropdown-bg: #ffffff;
    --ll-text-color: #333;
    --ll-text-hover-color: #0073aa;
}

/* ==========================================================================
   General Menu Styles
   ========================================================================== */
.lingualink-menu {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

.lingualink-menu ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.lingualink-menu a {
    display: flex;
    align-items: center;
    gap: 8px; /* Creates space between flag and title */
    text-decoration: none;
    color: var(--ll-text-color);
    padding: 8px 12px;
    border-radius: 4px;
    transition: background-color 0.2s ease, color 0.2s ease;
    white-space: nowrap;
}

.lingualink-flag {
    display: inline-flex; /* Use flex to align vertically */
    align-items: center;
    line-height: 0; /* Fixes extra space below image */
}

.lingualink-flag img {
    display: block;
    max-width: none; /* Let the shortcode attribute control the size */
    height: auto;
    object-fit: cover;
}

/* ==========================================================================
   Inline Layout
   ========================================================================== */
.lingualink-menu-inline ul {
    display: flex;
    flex-wrap: wrap;
    gap: 8px; /* Space between language items */
}

.lingualink-menu-inline a:hover {
    background-color: var(--ll-background-hover);
    color: var(--ll-text-hover-color);
}

/* ==========================================================================
   Dropdown Layout
   ========================================================================== */
.lingualink-menu-dropdown {
    position: relative;
    display: inline-block;
}

.lingualink-menu-toggle {
    cursor: pointer;
    background: #fff;
    border: 1px solid var(--ll-border-color);
    padding: 8px 12px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.lingualink-menu-toggle:hover {
    border-color: var(--ll-primary-color);
    background-color: #fcfcfc;
}

/* Chevron icon for the dropdown toggle */
.lingualink-menu-toggle::after {
    content: "\\";
    display: inline-block;
    border: solid var(--ll-text-color);
    border-width: 0 2px 2px 0;
    padding: 3px;
    transform: rotate(45deg);
    transition: transform 0.25s ease;
}

.lingualink-menu-dropdown.is-active .lingualink-menu-toggle::after {
    transform: rotate(-135deg);
}

/* The dropdown panel */
.lingualink-menu-dropdown ul {
    display: block; /* Keep it as block for transitions */
    position: absolute;
    top: calc(100% + 5px); /* Position below the button with a small gap */
    left: 0;
    background-color: var(--ll-dropdown-bg);
    border: 1px solid var(--ll-border-color);
    box-shadow: var(--ll-dropdown-shadow);
    min-width: 160px;
    z-index: 1000;
    border-radius: 5px;
    padding: 5px;
    /* Animation */
    opacity: 0;
    transform: translateY(10px);
    visibility: hidden;
    transition: opacity 0.25s ease, transform 0.25s ease, visibility 0s 0.25s;
}

.lingualink-menu-dropdown.is-active ul {
    opacity: 1;
    transform: translateY(0);
    visibility: visible;
    transition-delay: 0s;
}

.lingualink-menu-dropdown li a:hover {
    background-color: var(--ll-background-hover);
    color: var(--ll-text-hover-color);
}