@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;600&display=swap');

/* ── Arabic Text Reader — reader.css ─────────────────────────────────── */

/* Variables */
.atr-reader, .atr-fc-page {
    --atr-gold:    #C8913A;
    --atr-gold-l:  #EAC97B;
    --atr-bg:      #0d1117;
    --atr-surface: #161b22;
    --atr-border:  rgba(255,255,255,0.1);
    --atr-text:    #e6edf3;
    --atr-muted:   #8b949e;
    --atr-green:   #3fb950;
    --atr-red:     #f85149;
    --atr-radius:  10px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ── Lecteur ─────────────────────────────────────────────────────────── */
.atr-reader {
    background: var(--atr-surface);
    border: 1px solid var(--atr-border);
    border-radius: var(--atr-radius);
    padding: 0;
    overflow: visible;
    position: relative;
}

/* En-tête */
.atr-reader-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--atr-border);
    background: var(--atr-bg);
    border-radius: var(--atr-radius) var(--atr-radius) 0 0;
}
.atr-reader-meta {
    display: flex;
    align-items: center;
    gap: 10px;
}
.atr-reader-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--atr-text);
}
.atr-level-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    border: 1px solid currentColor;
    letter-spacing: .5px;
}
.atr-level-a1 { color: #3fb950; }
.atr-level-a2 { color: #58a6ff; }
.atr-level-b1 { color: #e3b341; }
.atr-level-b2 { color: #f0883e; }
.atr-level-c1, .atr-level-c2 { color: #f85149; }

/* Lien flashcards */
.atr-fc-link {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    padding: 5px 12px;
    border-radius: 6px;
    background: rgba(200,145,58,.12);
    border: 1px solid rgba(200,145,58,.3);
    color: var(--atr-gold);
    text-decoration: none;
    transition: background .15s;
    white-space: nowrap;
}
.atr-fc-link:hover { background: rgba(200,145,58,.22); color: var(--atr-gold-l); }
.atr-fc-link--login { color: var(--atr-muted); background: none; border-color: var(--atr-border); }
.atr-fc-badge {
    background: var(--atr-red);
    color: #fff;
    border-radius: 10px;
    font-size: 10px;
    padding: 1px 6px;
}

/* Texte arabe */
.atr-text {
    padding: 24px 28px;
    font-family: 'Noto Sans Arabic';
    font-size: 22px;
    line-height: 3.5;
    color: var(--atr-text);
    direction: rtl;
    text-align: right;
    word-spacing: 2px;
}

/* Mots cliquables */
.atr-word {
    cursor: pointer;
    border-radius: 4px;
    padding: 1px 3px;
    margin: 0 1px;
    display: inline;
    transition: background .15s, color .15s;
}
.atr-word:hover {
    background: rgba(200,145,58,.2);
    color: var(--atr-gold-l);
}
.atr-word--active {
    background: rgba(200,145,58,.3);
    color: var(--atr-gold);
    outline: 1px solid rgba(200,145,58,.5);
    border-radius: 4px;
}
.atr-word--saved {
    color: var(--atr-gold-l);
    text-decoration: underline dotted rgba(200,145,58,.5);
    text-underline-offset: 4px;
}

/* Hint */
.atr-hint {
    text-align: center;
    font-size: 12px;
    color: var(--atr-muted);
    padding: 8px 20px 16px;
    border-top: 1px solid var(--atr-border);
    letter-spacing: .3px;
}

/* ── Popup ───────────────────────────────────────────────────────────── */
.atr-popup {
    position: absolute;
    z-index: 999;
    width: 300px;
}
.atr-popup-box {
    background: var(--atr-bg);
    border: 1px solid var(--atr-gold);
    border-radius: 12px;
    padding: 16px 18px;
    box-shadow: 0 8px 32px rgba(0,0,0,.5);
}
.atr-popup-close {
    float: right;
    background: none;
    border: none;
    color: var(--atr-muted);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0;
    margin-left: 8px;
}
.atr-popup-close:hover { color: var(--atr-text); }
.atr-popup-word {
    font-family: 'Cairo', 'Noto Sans Arabic', 'Tahoma', sans-serif;
    font-size: 26px;
    color: var(--atr-gold);
    margin-bottom: 4px;
    clear: both;
}
.atr-popup-source {
    font-size: 11px;
    color: var(--atr-muted);
    margin-bottom: 8px;
}
.atr-popup-translation {
    font-size: 20px;
    font-weight: 600;
    color: var(--atr-text);
    margin-bottom: 14px;
    min-height: 28px;
}
.atr-popup-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.atr-popup-btn {
    flex: 1;
    min-width: 90px;
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid var(--atr-border);
    background: transparent;
    color: var(--atr-muted);
    font-size: 12px;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    transition: all .15s;
    display: inline-block;
}
.atr-popup-btn:hover { border-color: var(--atr-gold); color: var(--atr-gold); }
.atr-popup-btn--saved { color: var(--atr-gold) !important; border-color: var(--atr-gold) !important; }
.atr-popup-btn--login { font-size: 11px; }
.atr-correction-form {
    margin-top: 10px;
    display: flex;
    gap: 6px;
}
.atr-correction-form input {
    flex: 1;
    background: rgba(255,255,255,.06);
    border: 1px solid var(--atr-border);
    border-radius: 6px;
    padding: 5px 8px;
    color: var(--atr-text);
    font-size: 13px;
}
.atr-correction-form button {
    padding: 5px 10px;
    border-radius: 6px;
    border: 1px solid var(--atr-gold);
    background: transparent;
    color: var(--atr-gold);
    cursor: pointer;
    font-size: 12px;
}

/* ── Page Flashcards ─────────────────────────────────────────────────── */
.atr-fc-page {
    max-width: 660px;
    margin: 0 auto;
    padding: 24px 16px;
}
.atr-notice {
    padding: 20px;
    text-align: center;
    background: rgba(200,145,58,.08);
    border: 1px solid var(--atr-border);
    border-radius: var(--atr-radius);
}

/* Stats */
.atr-fc-stats {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
}
.atr-fc-stat {
    flex: 1;
    background: var(--atr-surface);
    border: 1px solid var(--atr-border);
    border-radius: var(--atr-radius);
    padding: 16px;
    text-align: center;
}
.atr-fc-stat--green { border-color: rgba(63,185,80,.3); }
.atr-stat-num {
    display: block;
    font-size: 30px;
    font-weight: 700;
    color: var(--atr-text);
}
.atr-fc-stat--green .atr-stat-num { color: var(--atr-green); }
.atr-stat-label { font-size: 12px; color: var(--atr-muted); }

/* Contrôles */
.atr-fc-controls {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
}
.atr-fc-modes {
    display: flex;
    gap: 4px;
    background: var(--atr-surface);
    border: 1px solid var(--atr-border);
    border-radius: 8px;
    padding: 3px;
}
.atr-mode-btn {
    padding: 6px 14px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--atr-muted);
    font-size: 13px;
    cursor: pointer;
    transition: all .15s;
}
.atr-mode-btn--active { background: var(--atr-gold); color: #fff; }
.atr-fc-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--atr-muted);
    cursor: pointer;
}

/* Carte */
.atr-fc-counter {
    text-align: center;
    font-size: 13px;
    color: var(--atr-muted);
    margin-bottom: 10px;
}
.atr-fc-card {
    perspective: 1000px;
    cursor: pointer;
    height: 180px;
    margin-bottom: 12px;
}
.atr-fc-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform .4s cubic-bezier(.4,.2,.2,1);
}
.atr-fc-card-inner.atr-flipped { transform: rotateY(180deg); }
.atr-fc-front, .atr-fc-back {
    position: absolute;
    inset: 0;
    background: var(--atr-surface);
    border: 1px solid var(--atr-border);
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    backface-visibility: hidden;
    padding: 20px;
    text-align: center;
}
.atr-fc-front { border-color: rgba(200,145,58,.3); }
.atr-fc-back  { transform: rotateY(180deg); border-color: rgba(63,185,80,.3); }
.atr-fc-face-label {
    font-size: 11px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--atr-muted);
    margin-bottom: 12px;
}
.atr-fc-face-word {
    font-size: clamp(20px, 4vw, 32px);
    font-weight: 600;
    color: var(--atr-text);
    line-height: 1.3;
}
.atr-fc-front .atr-fc-face-word {
    font-family: 'Cairo', 'Noto Sans Arabic', 'Tahoma', sans-serif;
    color: var(--atr-gold);
    font-size: clamp(22px, 4vw, 32px);
}
.atr-fc-face-hint { font-size: 12px; color: var(--atr-muted); margin-top: 10px; }

/* Barre de progression */
.atr-fc-progress-bar {
    height: 4px;
    background: var(--atr-border);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 14px;
}
.atr-fc-progress-fill {
    height: 100%;
    background: var(--atr-gold);
    border-radius: 2px;
    transition: width .3s;
}

/* Boutons d'action */
.atr-fc-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-bottom: 20px;
}
.atr-fc-btn {
    padding: 9px 18px;
    border-radius: 8px;
    border: 1px solid;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    background: transparent;
    transition: all .15s;
}
.atr-fc-btn--wrong  { border-color: var(--atr-red);   color: var(--atr-red); }
.atr-fc-btn--wrong:hover  { background: rgba(248,81,73,.1); }
.atr-fc-btn--master { border-color: var(--atr-gold);  color: var(--atr-gold); }
.atr-fc-btn--master:hover { background: rgba(200,145,58,.1); }
.atr-fc-btn--next   { border-color: var(--atr-border); color: var(--atr-text); }
.atr-fc-btn--next:hover   { border-color: var(--atr-gold); color: var(--atr-gold); }

/* Résultat */
.atr-fc-result {
    text-align: center;
    padding: 32px 20px;
    background: var(--atr-surface);
    border: 1px solid var(--atr-border);
    border-radius: var(--atr-radius);
    margin-bottom: 24px;
}
.atr-fc-result-icon { font-size: 44px; margin-bottom: 12px; }
.atr-fc-result h3   { font-size: 20px; color: var(--atr-text); margin-bottom: 8px; }
.atr-fc-result p    { color: var(--atr-muted); margin-bottom: 20px; }
.atr-fc-restart {
    padding: 10px 24px;
    border-radius: 8px;
    border: 1px solid var(--atr-gold);
    background: transparent;
    color: var(--atr-gold);
    font-size: 14px;
    cursor: pointer;
}

/* Liste vocabulaire */
.atr-fc-list { margin-top: 32px; }
.atr-fc-list-title {
    font-size: 12px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--atr-muted);
    margin-bottom: 12px;
}
.atr-fc-list-inner {
    display: flex;
    flex-direction: column;
    gap: 1px;
    border-radius: var(--atr-radius);
    overflow: hidden;
    border: 1px solid var(--atr-border);
}
.atr-fc-list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--atr-surface);
    padding: 10px 14px;
    transition: background .12s;
}
.atr-fc-list-item:hover { background: rgba(255,255,255,.04); }
.atr-fc-list-item.atr-mastered .atr-list-ar,
.atr-fc-list-item.atr-mastered .atr-list-fr { opacity: .4; }
.atr-list-ar {
    font-family: 'Cairo', 'Noto Sans Arabic', 'Tahoma', sans-serif;
    font-size: 18px;
    color: var(--atr-gold);
    min-width: 90px;
    text-align: right;
}
.atr-list-fr { flex: 1; font-size: 13px; color: var(--atr-muted); }
.atr-list-actions { display: flex; gap: 4px; }
.atr-list-master, .atr-list-remove {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    font-size: 14px;
    color: var(--atr-muted);
    transition: color .12s;
}
.atr-list-master:hover { color: var(--atr-gold); }
.atr-list-remove:hover  { color: var(--atr-red); }
.atr-fc-empty {
    text-align: center;
    padding: 48px 20px;
    color: var(--atr-muted);
}
.atr-fc-empty-icon { font-size: 40px; margin-bottom: 12px; }

/* ── Admin ───────────────────────────────────────────────────────────── */
.atr-wrap .atr-card {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 20px 24px;
    margin: 16px 0;
}
.atr-wrap .atr-card h2 { margin-top: 0; font-size: 16px; }
.atr-wrap .atr-empty   { color: #888; font-style: italic; padding: 10px 0; }
.atr-wrap .atr-msg     { margin-left: 10px; color: green; font-weight: 500; }
.atr-wrap #atr-content { font-family: 'Cairo', 'Noto Sans Arabic', 'Tahoma', sans-serif; font-size: 17px; }
