/**
 * Africa Translator — Module Traduction Instantanée Frontend
 * CSS v2.0.0
 */

/* ═══════════════════════════════════════════════
   VARIABLES
═══════════════════════════════════════════════ */
:root {
    --at-topbar-bg:    #1a3c5e;
    --at-topbar-text:  #ffffff;
    --at-active:       #e8a020;
    --at-switcher-bg:  #1a3c5e;
    --at-radius:       8px;
    --at-shadow:       0 4px 20px rgba(0,0,0,0.15);
    --at-transition:   0.25s ease;
    --at-font:         -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --at-z-topbar:     9990;
    --at-z-switcher:   9999;
    --at-z-overlay:    10000;
}

/* ═══════════════════════════════════════════════
   TOPBAR — Barre de langue en haut
═══════════════════════════════════════════════ */
#at-topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: var(--at-z-topbar);
    background: var(--at-topbar-bg);
    color: var(--at-topbar-text);
    font-family: var(--at-font);
    font-size: 13px;
    height: 36px;
    display: flex;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    transition: transform var(--at-transition), opacity var(--at-transition);
}

#at-topbar.at-hidden {
    transform: translateY(-100%);
    opacity: 0;
    pointer-events: none;
}

.at-topbar__inner {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: flex-end;
}

.at-topbar__label {
    opacity: 0.8;
    font-size: 12px;
    margin-right: 4px;
}

.at-topbar__langs {
    display: flex;
    align-items: center;
    gap: 4px;
}

.at-topbar__btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    background: transparent;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 4px;
    color: var(--at-topbar-text);
    font-size: 13px;
    font-family: var(--at-font);
    cursor: pointer;
    transition: all var(--at-transition);
    line-height: 1;
}

.at-topbar__btn:hover {
    background: rgba(255,255,255,0.15);
    border-color: rgba(255,255,255,0.6);
}

.at-topbar__btn.at-active,
.at-topbar__btn[aria-current="true"] {
    background: var(--at-active);
    border-color: var(--at-active);
    color: #fff;
    font-weight: 600;
}

.at-topbar__sep {
    opacity: 0.4;
    font-size: 11px;
}

.at-topbar__count {
    font-size: 11px;
    opacity: 0.55;
    margin-left: 8px;
}

.at-flag {
    font-size: 14px;
    line-height: 1;
}

/* Offset body quand topbar visible */
body.at-topbar-active {
    padding-top: 36px !important;
}

/* ═══════════════════════════════════════════════
   SWITCHER FLOTTANT AMÉLIORÉ
═══════════════════════════════════════════════ */
#at-switcher {
    position: fixed;
    z-index: var(--at-z-switcher);
    font-family: var(--at-font);
    font-size: 14px;
}

#at-switcher.at-switcher--bottom-right {
    bottom: 24px;
    right: 24px;
}

#at-switcher.at-switcher--bottom-left {
    bottom: 24px;
    left: 24px;
}

/* Bouton principal */
.at-switcher__toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 14px;
    background: var(--at-switcher-bg);
    color: #fff;
    border: none;
    border-radius: 30px;
    cursor: pointer;
    box-shadow: var(--at-shadow);
    font-size: 14px;
    font-family: var(--at-font);
    font-weight: 600;
    transition: all var(--at-transition);
    user-select: none;
    white-space: nowrap;
}

.at-switcher__toggle:hover {
    background: #234f78;
    box-shadow: 0 6px 24px rgba(0,0,0,0.2);
    transform: translateY(-1px);
}

.at-switcher__toggle:active {
    transform: translateY(0);
}

.at-switcher__toggle[aria-expanded="true"] {
    border-radius: 12px 12px 0 0;
}

.at-switcher__globe {
    font-size: 16px;
    transition: transform var(--at-transition);
}

.at-switcher__toggle[aria-expanded="true"] .at-switcher__globe {
    transform: rotate(20deg);
}

.at-switcher__current-flag {
    font-size: 16px;
}

.at-switcher__current-label {
    font-size: 12px;
    letter-spacing: 0.5px;
    opacity: 0.9;
}

.at-switcher__arrow {
    font-size: 9px;
    opacity: 0.7;
    transition: transform var(--at-transition);
}

.at-switcher__toggle[aria-expanded="true"] .at-switcher__arrow {
    transform: rotate(180deg);
}

/* Panel */
.at-switcher__panel {
    position: absolute;
    bottom: 100%;
    background: #fff;
    border-radius: 12px 12px 0 0;
    box-shadow: var(--at-shadow);
    min-width: 180px;
    overflow: hidden;
    border: 1px solid rgba(0,0,0,0.08);
    border-bottom: none;
}

.at-switcher--bottom-right .at-switcher__panel {
    right: 0;
}
.at-switcher--bottom-left .at-switcher__panel {
    left: 0;
}

/* Animation panneau */
.at-switcher__panel:not([hidden]) {
    animation: at-slide-up 0.2s ease forwards;
}

@keyframes at-slide-up {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Boutons de langue dans le panel */
.at-switcher__lang-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 11px 16px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-family: var(--at-font);
    color: #333;
    text-align: left;
    transition: background var(--at-transition);
    position: relative;
}

.at-switcher__lang-btn:hover {
    background: #f0f6ff;
}

.at-switcher__lang-btn.at-active {
    background: #eef4ff;
    color: var(--at-switcher-bg);
    font-weight: 600;
}

.at-switcher__lang-btn .at-flag {
    font-size: 18px;
}

.at-check {
    margin-left: auto;
    color: var(--at-active);
    font-size: 13px;
    opacity: 0;
    transition: opacity var(--at-transition);
}

.at-switcher__lang-btn.at-active .at-check {
    opacity: 1;
}

/* Séparateur */
.at-switcher__divider {
    height: 1px;
    background: #eee;
    margin: 4px 12px;
}

/* Bouton recherche */
.at-switcher__search-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 16px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-family: var(--at-font);
    color: #666;
    transition: all var(--at-transition);
}

.at-switcher__search-btn:hover {
    background: #f8f8f8;
    color: var(--at-switcher-bg);
}

/* Status */
.at-switcher__status {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px 10px;
    font-size: 11px;
    color: #999;
    border-top: 1px solid #f0f0f0;
}

.at-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #ccc;
    transition: background 0.3s;
    flex-shrink: 0;
}

.at-status-dot.at-translating {
    background: var(--at-active);
    animation: at-pulse 1s infinite;
}

.at-status-dot.at-done {
    background: #4caf50;
}

@keyframes at-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ═══════════════════════════════════════════════
   BARRE DE PROGRESSION
═══════════════════════════════════════════════ */
#at-progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    z-index: calc(var(--at-z-overlay) + 1);
    background: rgba(255,255,255,0.2);
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

#at-progress-bar.at-active {
    opacity: 1;
}

#at-progress-bar.at-topbar-offset {
    top: 36px;
}

.at-progress__inner {
    height: 100%;
    background: var(--at-active);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 0 2px 2px 0;
}

/* ═══════════════════════════════════════════════
   TOAST NOTIFICATION
═══════════════════════════════════════════════ */
#at-toast {
    position: fixed;
    bottom: 90px;
    right: 24px;
    z-index: var(--at-z-overlay);
    background: #222;
    color: #fff;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 13px;
    font-family: var(--at-font);
    box-shadow: var(--at-shadow);
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease;
    pointer-events: none;
    max-width: 280px;
}

#at-toast.at-toast--visible {
    opacity: 1;
    transform: translateY(0);
}

/* ═══════════════════════════════════════════════
   OVERLAY DE RECHERCHE
═══════════════════════════════════════════════ */
.at-overlay {
    position: fixed;
    inset: 0;
    z-index: var(--at-z-overlay);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 60px;
    font-family: var(--at-font);
}

.at-overlay[hidden] {
    display: none;
}

.at-overlay__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(3px);
}

.at-overlay__panel {
    position: relative;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
    width: 100%;
    max-width: 540px;
    margin: 0 16px;
    overflow: hidden;
    animation: at-overlay-in 0.25s ease;
}

@keyframes at-overlay-in {
    from { opacity: 0; transform: scale(0.95) translateY(-10px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.at-overlay__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px 14px;
    border-bottom: 1px solid #eee;
}

.at-overlay__title {
    font-size: 16px;
    font-weight: 700;
    color: #1a3c5e;
    margin: 0;
}

.at-overlay__close {
    background: none;
    border: none;
    font-size: 18px;
    color: #999;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all var(--at-transition);
    line-height: 1;
}

.at-overlay__close:hover {
    background: #f0f0f0;
    color: #333;
}

.at-overlay__body {
    padding: 16px 20px 20px;
}

/* Champ de recherche */
.at-search-box {
    position: relative;
    margin-bottom: 16px;
}

.at-search-box__input {
    width: 100%;
    padding: 12px 40px 12px 14px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 15px;
    font-family: var(--at-font);
    color: #333;
    outline: none;
    transition: border-color var(--at-transition);
    box-sizing: border-box;
}

.at-search-box__input:focus {
    border-color: #1a3c5e;
}

.at-search-box__icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 16px;
    pointer-events: none;
}

/* Résultats */
.at-search-results {
    min-height: 100px;
    max-height: 300px;
    overflow-y: auto;
}

.at-search-results__hint {
    color: #aaa;
    font-size: 13px;
    text-align: center;
    margin-top: 24px;
}

.at-search-results__item {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    align-items: center;
    padding: 10px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: background var(--at-transition);
    border-bottom: 1px solid #f5f5f5;
}

.at-search-results__item:last-child {
    border-bottom: none;
}

.at-search-results__item:hover {
    background: #f0f6ff;
}

.at-search-results__item .at-fr {
    color: #333;
    font-size: 13px;
}

.at-search-results__item .at-en {
    color: #1a3c5e;
    font-size: 13px;
    font-weight: 500;
}

.at-search-results__count {
    color: #888;
    font-size: 12px;
    margin-bottom: 8px;
}

.at-search-results__empty {
    color: #aaa;
    font-size: 13px;
    text-align: center;
    padding: 20px;
}

mark.at-highlight {
    background: #fff3cd;
    color: inherit;
    border-radius: 2px;
    padding: 0 1px;
}

.at-overlay__stats {
    margin-top: 12px;
    font-size: 11px;
    color: #bbb;
    text-align: right;
}

/* ═══════════════════════════════════════════════
   TRADUCTION EN COURS — Effet visuel
═══════════════════════════════════════════════ */
.at-translating-body {
    transition: opacity 0.15s ease;
}

.at-translating-body.at-busy {
    opacity: 0.6;
    pointer-events: none;
}

/* Animation de glissement lors du changement */
@keyframes at-fade-lang {
    0%   { opacity: 0; }
    100% { opacity: 1; }
}

body.at-lang-switching * {
    animation: at-fade-lang 0.3s ease forwards;
}

/* ═══════════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════════ */
@media (max-width: 480px) {
    .at-topbar__count {
        display: none;
    }
    
    .at-topbar__label {
        display: none;
    }

    #at-switcher.at-switcher--bottom-right,
    #at-switcher.at-switcher--bottom-left {
        bottom: 16px;
        right: 16px;
        left: auto;
    }

    .at-overlay__panel {
        margin: 0 8px;
    }

    .at-search-results__item {
        grid-template-columns: 1fr;
    }
}

/* ═══════════════════════════════════════════════
   ACCESSIBILITÉ
═══════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
}

.at-switcher__toggle:focus-visible,
.at-switcher__lang-btn:focus-visible,
.at-topbar__btn:focus-visible,
.at-overlay__close:focus-visible {
    outline: 2px solid var(--at-active);
    outline-offset: 2px;
}
