/**
 * SweetTranslate - Language Switcher Styles
 *
 * Lightweight, accessible, and performant
 */

/* Base Variables */
:root {
    --st2-primary: #2563eb;
    --st2-primary-hover: #1d4ed8;
    --st2-bg: #ffffff;
    --st2-bg-hover: #f3f4f6;
    --st2-border: #e5e7eb;
    --st2-text: #1f2937;
    --st2-text-muted: #6b7280;
    --st2-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --st2-shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --st2-radius: 8px;
    --st2-transition: 150ms ease;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --st2-bg: #1f2937;
        --st2-bg-hover: #374151;
        --st2-border: #374151;
        --st2-text: #f9fafb;
        --st2-text-muted: #9ca3af;
    }
}

/* Switcher Container */
.sweetranslate-switcher {
    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

/* Positions */
.st2-position-br {
    bottom: 20px;
    right: 20px;
}

.st2-position-bl {
    bottom: 20px;
    left: 20px;
}

.st2-position-tr {
    top: 20px;
    right: 20px;
}

.st2-position-tl {
    top: 20px;
    left: 20px;
}

/* Current Language Button */
.sweetranslate-current {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--st2-bg);
    border: 1px solid var(--st2-border);
    border-radius: var(--st2-radius);
    box-shadow: var(--st2-shadow);
    color: var(--st2-text);
    cursor: pointer;
    transition: all var(--st2-transition);
    white-space: nowrap;
}

.sweetranslate-current:hover {
    background: var(--st2-bg-hover);
    box-shadow: var(--st2-shadow-lg);
}

.sweetranslate-current:focus {
    outline: 2px solid var(--st2-primary);
    outline-offset: 2px;
}

/* Flag */
.st2-flag {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.st2-flag img {
    display: block;
    border-radius: 2px;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1);
}

/* Name */
.st2-name {
    font-weight: 500;
}

/* Arrow */
.st2-arrow {
    display: flex;
    align-items: center;
    margin-left: 2px;
    transition: transform var(--st2-transition);
}

.sweetranslate-switcher.open .st2-arrow {
    transform: rotate(180deg);
}

/* Dropdown */
.sweetranslate-dropdown {
    position: absolute;
    bottom: 100%;
    right: 0;
    margin-bottom: 8px;
    padding: 6px;
    background: var(--st2-bg);
    border: 1px solid var(--st2-border);
    border-radius: var(--st2-radius);
    box-shadow: var(--st2-shadow-lg);
    list-style: none;
    min-width: 160px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all var(--st2-transition);
}

/* Position adjustments for dropdown */
.st2-position-br .sweetranslate-dropdown,
.st2-position-bl .sweetranslate-dropdown {
    bottom: 100%;
    top: auto;
    margin-bottom: 8px;
    margin-top: 0;
}

.st2-position-tr .sweetranslate-dropdown,
.st2-position-tl .sweetranslate-dropdown {
    top: 100%;
    bottom: auto;
    margin-top: 8px;
    margin-bottom: 0;
    transform: translateY(-10px);
}

.st2-position-bl .sweetranslate-dropdown,
.st2-position-tl .sweetranslate-dropdown {
    right: auto;
    left: 0;
}

.sweetranslate-switcher.open .sweetranslate-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.sweetranslate-dropdown li {
    margin: 0;
    padding: 0;
}

.sweetranslate-dropdown a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    color: var(--st2-text);
    text-decoration: none;
    border-radius: calc(var(--st2-radius) - 4px);
    transition: background var(--st2-transition);
}

.sweetranslate-dropdown a:hover {
    background: var(--st2-bg-hover);
}

.sweetranslate-dropdown a:focus {
    outline: 2px solid var(--st2-primary);
    outline-offset: -2px;
}

/* Inline Style */
.sweetranslate-inline {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px;
    background: var(--st2-bg);
    border: 1px solid var(--st2-border);
    border-radius: var(--st2-radius);
    box-shadow: var(--st2-shadow);
    list-style: none;
    margin: 0;
}

.sweetranslate-inline li {
    margin: 0;
    padding: 0;
}

.sweetranslate-inline a,
.sweetranslate-inline .st2-current-inline {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    color: var(--st2-text);
    text-decoration: none;
    border-radius: calc(var(--st2-radius) - 4px);
    font-size: 13px;
    transition: background var(--st2-transition);
}

.sweetranslate-inline a:hover {
    background: var(--st2-bg-hover);
}

.sweetranslate-inline .st2-current-inline {
    background: var(--st2-primary);
    color: white;
    font-weight: 500;
}

.sweetranslate-inline a:focus {
    outline: 2px solid var(--st2-primary);
    outline-offset: -2px;
}

/* Minimal Style */
.sweetranslate-minimal {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px;
    background: var(--st2-bg);
    border: 1px solid var(--st2-border);
    border-radius: var(--st2-radius);
    box-shadow: var(--st2-shadow);
}

.st2-flag-link,
.st2-flag-current {
    display: block;
    line-height: 0;
    border-radius: 4px;
    overflow: hidden;
    transition: transform var(--st2-transition), box-shadow var(--st2-transition);
}

.st2-flag-link img,
.st2-flag-current img {
    display: block;
}

.st2-flag-link:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.st2-flag-link:focus {
    outline: 2px solid var(--st2-primary);
    outline-offset: 2px;
}

.st2-flag-current {
    opacity: 1;
    box-shadow: 0 0 0 2px var(--st2-primary);
}

/* RTL Support */
[dir="rtl"] .sweetranslate-switcher {
    direction: rtl;
}

[dir="rtl"] .st2-position-br {
    right: auto;
    left: 20px;
}

[dir="rtl"] .st2-position-bl {
    left: auto;
    right: 20px;
}

[dir="rtl"] .st2-position-tr {
    right: auto;
    left: 20px;
}

[dir="rtl"] .st2-position-tl {
    left: auto;
    right: 20px;
}

[dir="rtl"] .st2-arrow {
    margin-left: 0;
    margin-right: 2px;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .sweetranslate-switcher {
        font-size: 13px;
    }

    .st2-position-br,
    .st2-position-bl {
        bottom: 15px;
    }

    .st2-position-br {
        right: 15px;
    }

    .st2-position-bl {
        left: 15px;
    }

    .sweetranslate-current {
        padding: 8px 12px;
    }

    .sweetranslate-dropdown {
        min-width: 140px;
    }

    .sweetranslate-inline {
        gap: 2px;
        padding: 4px;
    }

    .sweetranslate-inline a,
    .sweetranslate-inline .st2-current-inline {
        padding: 5px 8px;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .sweetranslate-current,
    .sweetranslate-dropdown,
    .sweetranslate-dropdown a,
    .st2-arrow,
    .st2-flag-link {
        transition: none;
    }
}

/* Print - Hide Switcher */
@media print {
    .sweetranslate-switcher {
        display: none !important;
    }
}

/* Translation Indicator (optional) */
[data-sweetranslate-translated="true"] {
    /* Can be used for visual debugging */
}

/* Loading State */
.sweetranslate-switcher.loading .sweetranslate-current::after {
    content: '';
    width: 14px;
    height: 14px;
    border: 2px solid var(--st2-border);
    border-top-color: var(--st2-primary);
    border-radius: 50%;
    animation: st2-spin 0.6s linear infinite;
    margin-left: 8px;
}

@keyframes st2-spin {
    to {
        transform: rotate(360deg);
    }
}
