/**
 * MLM Language Switcher Styles
 * 
 * Estilos para todos los tipos de selectores de idioma:
 * - dropdown (select nativo)
 * - summary (details/summary HTML5)
 * - list (ul/li horizontal)
 * - flags (solo banderas)
 * - inline (con separadores)
 * 
 * Ubicación: assets/css/frontend/mlm-switcher.css
 * 
 * @package MultiLang_Master
 * @since 1.4.1
 * @updated 1.7.0
 */

/* =============================================================================
   CSS VARIABLES - Personalización fácil
   ============================================================================= */
.mlm-switcher {
    --mlm-text: #374151;
    --mlm-text-muted: #6b7280;
    --mlm-bg: #ffffff;
    --mlm-bg-hover: #f3f4f6;
    --mlm-bg-active: #e5e7eb;
    --mlm-border: #d1d5db;
    --mlm-border-focus: #3b82f6;
    --mlm-radius: 6px;
    --mlm-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --mlm-shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.15);
    --mlm-font-size: 14px;
    --mlm-flag-size: 1.25em;
    --mlm-transition: all 0.2s ease;
}

/* =============================================================================
   BASE STYLES - Común a todos los tipos
   ============================================================================= */
.mlm-switcher {
    position: relative;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    font-size: var(--mlm-font-size);
    line-height: 1.5;
    box-sizing: border-box;
}

.mlm-switcher *,
.mlm-switcher *::before,
.mlm-switcher *::after {
    box-sizing: inherit;
}

.mlm-switcher a {
    text-decoration: none;
    color: inherit;
}

.mlm-switcher a:hover {
    text-decoration: none;
}

/* Flag emoji/image base */
.mlm-flag,
.mlm-dropdown-flag {
    font-size: var(--mlm-flag-size);
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.mlm-flag img,
.mlm-dropdown-flag img {
    width: 1.25em;
    height: auto;
    vertical-align: middle;
    border-radius: 2px;
}

/* Language name/code */
.mlm-lang-name,
.mlm-lang-code {
    display: inline-block;
}

.mlm-lang-code {
    text-transform: uppercase;
    font-weight: 500;
    letter-spacing: 0.025em;
}

/* States */
.mlm-current {
    font-weight: 600;
}

.mlm-no-translation {
    opacity: 0.6;
}

.mlm-no-translation::after {
    content: " *";
    font-size: 0.75em;
    vertical-align: super;
}

/* =============================================================================
   TYPE: DROPDOWN - Select nativo con bandera
   ============================================================================= */
.mlm-switcher--dropdown {
    display: inline-block;
}

.mlm-dropdown-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
}

.mlm-dropdown-flag {
    flex-shrink: 0;
    pointer-events: none;
}

.mlm-dropdown-select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-color: var(--mlm-bg);
    border: 1px solid var(--mlm-border);
    border-radius: var(--mlm-radius);
    color: var(--mlm-text);
    cursor: pointer;
    font-size: inherit;
    font-family: inherit;
    line-height: 1.5;
    padding: 8px 32px 8px 12px;
    min-width: 120px;
    transition: var(--mlm-transition);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 12px;
}

.mlm-dropdown-select:hover {
    border-color: var(--mlm-text-muted);
    background-color: var(--mlm-bg-hover);
}

.mlm-dropdown-select:focus {
    outline: none;
    border-color: var(--mlm-border-focus);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.mlm-dropdown-select:focus-visible {
    outline: 2px solid var(--mlm-border-focus);
    outline-offset: 2px;
}

/* =============================================================================
   TYPE: SUMMARY - Details/Summary HTML5
   ============================================================================= */
.mlm-switcher--summary {
    display: inline-block;
    position: relative;
}

.mlm-switcher--summary > details {
    position: relative;
}

.mlm-summary-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--mlm-bg);
    border: 1px solid var(--mlm-border);
    border-radius: var(--mlm-radius);
    cursor: pointer;
    font-size: inherit;
    font-family: inherit;
    color: var(--mlm-text);
    transition: var(--mlm-transition);
    list-style: none;
    user-select: none;
}

.mlm-summary-btn::-webkit-details-marker {
    display: none;
}

.mlm-summary-btn::marker {
    display: none;
    content: "";
}

.mlm-summary-btn:hover {
    background: var(--mlm-bg-hover);
    border-color: var(--mlm-text-muted);
}

.mlm-summary-btn:focus {
    outline: none;
    border-color: var(--mlm-border-focus);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* Chevron icon */
.mlm-summary-btn .mlm-chevron {
    margin-left: auto;
    color: var(--mlm-text-muted);
    transition: transform 0.2s ease;
    font-size: 0.75em;
}

.mlm-summary-btn .mlm-chevron::after {
    content: "▼";
}

details[open] .mlm-summary-btn .mlm-chevron {
    transform: rotate(180deg);
}

/* Dropdown menu */
.mlm-summary-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 100%;
    background: var(--mlm-bg);
    border: 1px solid var(--mlm-border);
    border-radius: var(--mlm-radius);
    box-shadow: var(--mlm-shadow-lg);
    z-index: 1000;
    padding: 4px 0;
    animation: mlm-dropdown-in 0.15s ease-out;
}

@keyframes mlm-dropdown-in {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.mlm-summary-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    color: var(--mlm-text);
    transition: var(--mlm-transition);
    white-space: nowrap;
}

.mlm-summary-link:hover {
    background: var(--mlm-bg-hover);
}

.mlm-summary-link.mlm-current {
    background: var(--mlm-bg-active);
}

.mlm-summary-link[aria-current="true"] {
    background: var(--mlm-bg-active);
    font-weight: 600;
}

/* =============================================================================
   TYPE: LIST - Lista horizontal ul/li
   ============================================================================= */
.mlm-switcher--list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.mlm-list-item {
    margin: 0;
    padding: 0;
}

.mlm-list-item a {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: var(--mlm-radius);
    color: var(--mlm-text);
    transition: var(--mlm-transition);
}

.mlm-list-item a:hover {
    background: var(--mlm-bg-hover);
}

.mlm-list-item.mlm-current a {
    background: var(--mlm-bg-active);
    font-weight: 600;
}

.mlm-list-item a[aria-current="true"] {
    background: var(--mlm-bg-active);
}

/* =============================================================================
   TYPE: FLAGS - Solo banderas
   ============================================================================= */
.mlm-switcher--flags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.mlm-flag-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border-radius: var(--mlm-radius);
    transition: var(--mlm-transition);
    font-size: calc(var(--mlm-flag-size) * 1.25);
}

.mlm-flag-link:hover {
    background: var(--mlm-bg-hover);
    transform: scale(1.1);
}

.mlm-flag-link.mlm-current {
    background: var(--mlm-bg-active);
    box-shadow: 0 0 0 2px var(--mlm-border);
}

.mlm-flag-link[aria-current="true"] {
    background: var(--mlm-bg-active);
    box-shadow: 0 0 0 2px var(--mlm-border-focus);
}

.mlm-flag-link img {
    width: 1.5em;
    height: auto;
    border-radius: 3px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* =============================================================================
   TYPE: INLINE - Con separadores
   ============================================================================= */
.mlm-switcher--inline {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0;
}

.mlm-inline-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    color: var(--mlm-text);
    transition: var(--mlm-transition);
}

.mlm-inline-link:hover {
    color: var(--mlm-border-focus);
}

.mlm-inline-link.mlm-current {
    font-weight: 600;
}

.mlm-inline-link[aria-current="true"] {
    font-weight: 600;
    color: var(--mlm-text);
}

/* Separador entre links */
.mlm-inline-link:not(:last-child)::after {
    content: "|";
    margin-left: 8px;
    color: var(--mlm-border);
    font-weight: 300;
}

/* =============================================================================
   MODIFIER: Dark Theme
   ============================================================================= */
.mlm-switcher--dark {
    --mlm-text: #f3f4f6;
    --mlm-text-muted: #9ca3af;
    --mlm-bg: #1f2937;
    --mlm-bg-hover: #374151;
    --mlm-bg-active: #4b5563;
    --mlm-border: #4b5563;
    --mlm-border-focus: #60a5fa;
    --mlm-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    --mlm-shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.4);
}

.mlm-switcher--dark .mlm-dropdown-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239ca3af' d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
}

/* =============================================================================
   MODIFIER: Pill Style
   ============================================================================= */
.mlm-switcher--pill {
    --mlm-radius: 9999px;
}

.mlm-switcher--pill .mlm-dropdown-select {
    padding-left: 16px;
    padding-right: 36px;
}

.mlm-switcher--pill .mlm-summary-btn {
    padding-left: 16px;
    padding-right: 16px;
}

.mlm-switcher--pill .mlm-summary-menu {
    border-radius: 12px;
    overflow: hidden;
}

/* =============================================================================
   MODIFIER: Minimal (Transparent)
   ============================================================================= */
.mlm-switcher--minimal {
    --mlm-bg: transparent;
    --mlm-bg-hover: rgba(0, 0, 0, 0.05);
    --mlm-bg-active: rgba(0, 0, 0, 0.08);
    --mlm-border: transparent;
    --mlm-shadow: none;
}

.mlm-switcher--minimal .mlm-dropdown-select,
.mlm-switcher--minimal .mlm-summary-btn {
    border-color: transparent;
    background-color: transparent;
}

.mlm-switcher--minimal .mlm-dropdown-select:hover,
.mlm-switcher--minimal .mlm-summary-btn:hover {
    background-color: var(--mlm-bg-hover);
}

.mlm-switcher--minimal .mlm-dropdown-select:focus,
.mlm-switcher--minimal .mlm-summary-btn:focus {
    box-shadow: none;
    background-color: var(--mlm-bg-active);
}

/* =============================================================================
   MODIFIER: Bordered (más énfasis en bordes)
   ============================================================================= */
.mlm-switcher--bordered {
    --mlm-border: #9ca3af;
}

.mlm-switcher--bordered .mlm-dropdown-select,
.mlm-switcher--bordered .mlm-summary-btn {
    border-width: 2px;
}

.mlm-switcher--bordered .mlm-list-item a {
    border: 1px solid var(--mlm-border);
}

/* =============================================================================
   MODIFIER: Size Small
   ============================================================================= */
.mlm-switcher--sm {
    --mlm-font-size: 12px;
    --mlm-flag-size: 1em;
}

.mlm-switcher--sm .mlm-dropdown-select {
    padding: 5px 26px 5px 8px;
    min-width: 90px;
}

.mlm-switcher--sm .mlm-summary-btn {
    padding: 5px 8px;
    gap: 6px;
}

.mlm-switcher--sm .mlm-summary-link {
    padding: 5px 8px;
}

.mlm-switcher--sm .mlm-list-item a {
    padding: 4px 8px;
    gap: 4px;
}

/* =============================================================================
   MODIFIER: Size Large
   ============================================================================= */
.mlm-switcher--lg {
    --mlm-font-size: 16px;
    --mlm-flag-size: 1.5em;
}

.mlm-switcher--lg .mlm-dropdown-select {
    padding: 12px 40px 12px 16px;
    min-width: 160px;
}

.mlm-switcher--lg .mlm-summary-btn {
    padding: 12px 16px;
    gap: 10px;
}

.mlm-switcher--lg .mlm-summary-link {
    padding: 12px 16px;
}

.mlm-switcher--lg .mlm-list-item a {
    padding: 10px 14px;
    gap: 8px;
}

/* =============================================================================
   MODIFIER: Compact (sin nombres, solo flags/códigos)
   ============================================================================= */
.mlm-switcher--compact .mlm-lang-name {
    display: none;
}

.mlm-switcher--compact .mlm-dropdown-select {
    min-width: auto;
    padding-right: 28px;
}

/* =============================================================================
   MODIFIER: Vertical List
   ============================================================================= */
.mlm-switcher--vertical.mlm-switcher--list {
    flex-direction: column;
    align-items: stretch;
}

.mlm-switcher--vertical .mlm-list-item a {
    justify-content: flex-start;
}

/* =============================================================================
   ALIGNMENT HELPERS
   ============================================================================= */
.mlm-switcher--right {
    text-align: right;
}

.mlm-switcher--right.mlm-switcher--summary .mlm-summary-menu {
    left: auto;
    right: 0;
}

.mlm-switcher--center {
    text-align: center;
}

.mlm-switcher--center.mlm-switcher--list,
.mlm-switcher--center.mlm-switcher--flags,
.mlm-switcher--center.mlm-switcher--inline {
    justify-content: center;
}

/* =============================================================================
   ACCESSIBILITY
   ============================================================================= */
.mlm-switcher a:focus-visible,
.mlm-switcher button:focus-visible,
.mlm-switcher select:focus-visible,
.mlm-switcher summary:focus-visible {
    outline: 2px solid var(--mlm-border-focus);
    outline-offset: 2px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .mlm-switcher,
    .mlm-switcher * {
        transition: none !important;
        animation: none !important;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .mlm-switcher {
        --mlm-border: currentColor;
    }
    
    .mlm-switcher a:focus,
    .mlm-switcher button:focus,
    .mlm-switcher select:focus {
        outline: 3px solid currentColor;
    }
}

/* =============================================================================
   RESPONSIVE
   ============================================================================= */
@media (max-width: 480px) {
    .mlm-switcher--list {
        gap: 2px;
    }
    
    .mlm-switcher--list .mlm-list-item a {
        padding: 8px 6px;
    }
    
    .mlm-switcher--inline .mlm-inline-link {
        padding: 4px 6px;
    }
    
    .mlm-switcher--inline .mlm-inline-link:not(:last-child)::after {
        margin-left: 6px;
    }
    
    /* En móvil, forzar nombres cortos si hay muchos idiomas */
    .mlm-switcher--auto-compact .mlm-lang-name {
        display: none;
    }
    
    .mlm-switcher--auto-compact .mlm-lang-code {
        display: inline-block;
    }
}

/* =============================================================================
   PRINT STYLES
   ============================================================================= */
@media print {
    .mlm-switcher {
        display: none !important;
    }
}

/* =============================================================================
   RTL SUPPORT
   ============================================================================= */
[dir="rtl"] .mlm-switcher,
.mlm-switcher[dir="rtl"] {
    direction: rtl;
}

[dir="rtl"] .mlm-dropdown-select {
    padding: 8px 12px 8px 32px;
    background-position: left 10px center;
}

[dir="rtl"] .mlm-summary-btn .mlm-chevron {
    margin-left: 0;
    margin-right: auto;
}

[dir="rtl"] .mlm-inline-link:not(:last-child)::after {
    margin-left: 0;
    margin-right: 8px;
}

[dir="rtl"] .mlm-switcher--right.mlm-switcher--summary .mlm-summary-menu {
    left: 0;
    right: auto;
}

/* =============================================================================
   WORDPRESS ADMIN BAR INTEGRATION
   ============================================================================= */
.admin-bar .mlm-switcher--fixed-top {
    top: 32px;
}

@media screen and (max-width: 782px) {
    .admin-bar .mlm-switcher--fixed-top {
        top: 46px;
    }
}

/* =============================================================================
   UTILITY: Fixed Position
   ============================================================================= */
.mlm-switcher--fixed-top {
    position: fixed;
    top: 10px;
    right: 10px;
    z-index: 99999;
}

.mlm-switcher--fixed-bottom {
    position: fixed;
    bottom: 10px;
    right: 10px;
    z-index: 99999;
}

/* =============================================================================
   TRANSITIONS PARA ESTADOS
   ============================================================================= */
.mlm-switcher--animated .mlm-flag-link:hover {
    transform: scale(1.15) rotate(-5deg);
}

.mlm-switcher--animated .mlm-list-item a:hover {
    transform: translateX(4px);
}

[dir="rtl"] .mlm-switcher--animated .mlm-list-item a:hover {
    transform: translateX(-4px);
}