/**
 * Feuille de styles RTL (Right-to-Left) & Typographie Bilingue - Horizon Vérité (أفق الحق)
 * Direction Artistique : Lionel (Conseil des Agents)
 * Charte Graphique Officielle HV :
 * - Émeraude Primaire : #007a2b
 * - Émeraude Signature : #009736
 * - Noir Onyx : #0a0b0d
 * - Ardoise Secondaire : #5b6472
 * - Blanc Pur : #ffffff
 */

/* Polices : les polices de la charte (Cairo, Amiri, Plus Jakarta Sans) sont hébergées par le site
   (/v2/fonts/*.woff2, même origine), sinon polices installées sur l'appareil, puis polices système.
   Aucune police téléchargée depuis un service externe. */

:root {
    --color-primary: #007a2b;
    --color-turquoise: #009736;
    --color-dark-gray: #0a0b0d;
    --color-secondary-gray: #5b6472;
    --color-white: #ffffff;

    --font-arabic: 'Cairo', 'Segoe UI', 'Geeza Pro', 'Noto Sans Arabic', 'Noto Naskh Arabic', Tahoma, 'DejaVu Sans', Arial, sans-serif;
    --font-latin: 'Amiri', 'Plus Jakarta Sans', Georgia, Cambria, 'Times New Roman', 'Noto Serif', 'DejaVu Serif', serif;
    --font-ui: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans', 'Helvetica Neue', Arial, sans-serif;
}

/* 1. RÈGLE ARABE (html[dir="rtl"]) : Cairo forcée comme police principale avec interligne aéré 1.7 */
html[dir="rtl"],
body[dir="rtl"],
html[dir="rtl"] *:not(.comp-icon-circle):not(.preview-comp-divider):not(.emoji-icon):not([data-emoji]):not(.comp-divider *):not(.aya-toast span:first-child) {
    font-family: var(--font-arabic) !important;
}

/* Préservation stricte de la police d'émojis même en contexte Arabe / RTL */
html[dir="rtl"] .comp-icon-circle,
html[dir="rtl"] .preview-comp-divider,
html[dir="rtl"] .emoji-icon,
html[dir="rtl"] [data-emoji] {
    font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', 'Segoe UI Symbol', 'Android Emoji', 'EmojiSymbols', sans-serif !important;
}

/* Interligne aéré spécifique pour la lisibilité des textes arabes (TICKET-18) */
html[dir="rtl"] p,
html[dir="rtl"] .chat-text-original,
html[dir="rtl"] .chat-text-translated,
html[dir="rtl"] .message-content,
html[dir="rtl"] article {
    line-height: 1.7 !important;
}

html[dir="rtl"] button,
html[dir="rtl"] .btn,
html[dir="rtl"] .btn-nav-link,
html[dir="rtl"] .lang-toggle-btn,
html[dir="rtl"] .badge-tag,
html[dir="rtl"] .wallet-badge-role,
html[dir="rtl"] .summary-badge,
html[dir="rtl"] .navbar-credits-pill,
html[dir="rtl"] .btn-save-profile,
html[dir="rtl"] .btn-action-sm,
html[dir="rtl"] .btn-stripe-buy,
html[dir="rtl"] .btn-recharge,
html[dir="rtl"] .btn-primary,
html[dir="rtl"] input,
html[dir="rtl"] select,
html[dir="rtl"] .preview-badge-tag,
html[dir="rtl"] .preview-word-fr,
html[dir="rtl"] .preview-word-ar,
html[dir="rtl"] .preview-sub-fr,
html[dir="rtl"] .preview-sub-ar,
html[dir="rtl"] .custom-word-row {
    line-height: normal !important;
}

/* Isolation bidirectionnelle pour les nombres, prix et pourcentages */
html[dir="rtl"] .credit-count,
html[dir="rtl"] .pack-price,
html[dir="rtl"] .pack-unit-price,
html[dir="rtl"] .balance-value,
html[dir="rtl"] .progress-percent,
html[dir="rtl"] .timestamp,
html[dir="rtl"] .file-size,
html[dir="rtl"] .price-amount {
    direction: ltr !important;
    unicode-bidi: isolate;
    display: inline-block;
}

html[dir="rtl"],
body[dir="rtl"] {
    direction: rtl;
    text-align: right;
    width: 100%;
    max-width: 100%;
    overflow-x: clip;
}

/* 2. RÈGLE FRANÇAIS (html[dir="ltr"]) : Amiri pour le texte avec fallback sans-serif UI */
html[dir="ltr"],
body[dir="ltr"] {
    direction: ltr;
    text-align: left;
    font-family: var(--font-latin);
    width: 100%;
    max-width: 100%;
    overflow-x: clip;
}

html[dir="ltr"] button,
html[dir="ltr"] .btn,
html[dir="ltr"] .btn-nav-link,
html[dir="ltr"] .lang-toggle-btn,
html[dir="ltr"] .badge-tag,
html[dir="ltr"] .live-indicator,
html[dir="ltr"] input,
html[dir="ltr"] select,
html[dir="ltr"] .custom-select,
html[dir="ltr"] .user-badge,
html[dir="ltr"] .timestamp,
html[dir="ltr"] .progress-percent,
html[dir="ltr"] .file-size,
html[dir="ltr"] pre,
html[dir="ltr"] code {
    font-family: var(--font-ui) !important;
}

/* Inversion de la Barre de Navigation (Concept 1) */
html[dir="rtl"] .app-header {
    direction: rtl;
    text-align: right;
}

html[dir="rtl"] .navbar-container {
    direction: rtl;
}

html[dir="rtl"] .navbar-brand {
    direction: rtl;
}

html[dir="rtl"] .brand-link {
    direction: rtl;
}

html[dir="rtl"] .navbar-nav {
    direction: rtl;
}

html[dir="rtl"] .navbar-actions {
    direction: rtl;
}

html[dir="rtl"] .navbar-user-wrap {
    padding: 3px 4px 3px 8px;
    direction: rtl;
}

/* Formulaire d'avis : alignement selon la langue choisie. */
html[dir="rtl"] .aya-feedback-modal {
    text-align: right;
    direction: rtl;
}

/* Inversion des Cartes de Sélection (Studio & Traduction) */
html[dir="rtl"] .source-grid,
html[dir="rtl"] .lang-grid,
html[dir="rtl"] .color-grid,
html[dir="rtl"] .pos-grid {
    direction: rtl;
}

html[dir="rtl"] .source-card,
html[dir="rtl"] .lang-card,
html[dir="rtl"] .color-card,
html[dir="rtl"] .pos-card {
    text-align: right;
}

html[dir="rtl"] .source-details,
html[dir="rtl"] .lang-details {
    text-align: right;
}

/* Formulaires et Boutons */
html[dir="rtl"] .file-info {
    flex-direction: row;
    text-align: right;
}

html[dir="rtl"] .badges-summary {
    direction: rtl;
}

html[dir="rtl"] .summary-badge {
    direction: rtl;
}

/* Conseil des 7 Agents IA */
html[dir="rtl"] .council-container {
    text-align: right;
    direction: rtl;
}

html[dir="rtl"] .council-header {
    flex-direction: row-reverse;
}

html[dir="rtl"] .council-verdict-box {
    border-left: none !important;
    border-right: 4px solid var(--color-turquoise) !important;
}

html[dir="rtl"] .agent-card {
    text-align: right;
    direction: rtl;
}

html[dir="rtl"] .agent-card-header {
    flex-direction: row-reverse;
}

html[dir="rtl"] .agent-identity {
    flex-direction: row;
}

html[dir="rtl"] .agent-reco {
    flex-direction: row;
}

html[dir="rtl"] .consult-form {
    flex-direction: row;
}

html[dir="rtl"] .consult-reply-box {
    text-align: right;
    direction: rtl;
}

/* Progression et Log */
html[dir="rtl"] .progress-header {
    flex-direction: row-reverse;
}

html[dir="rtl"] .progress-log {
    text-align: right;
    direction: rtl;
}

/* -------------------------------------------------------------
   Page Profil & Portefeuille Solidaire (Issue #19 - RTL)
   ------------------------------------------------------------- */
html[dir="rtl"] .profile-container {
    text-align: right;
    direction: rtl;
}

html[dir="rtl"] .profile-grid {
    direction: rtl;
}

html[dir="rtl"] .profile-card-header,
html[dir="rtl"] .wallet-header,
html[dir="rtl"] .history-header {
    flex-direction: row;
}

html[dir="rtl"] .profile-card-title,
html[dir="rtl"] .wallet-title {
    text-align: right;
    direction: rtl;
}

html[dir="rtl"] .profile-form-group {
    text-align: right;
}

html[dir="rtl"] .profile-input-wrapper {
    flex-direction: column !important;
    width: 100% !important;
}

html[dir="rtl"] .wallet-balance-row {
    flex-direction: row;
    direction: rtl;
}

html[dir="rtl"] .balance-item {
    text-align: right;
}

html[dir="rtl"] .packs-container {
    direction: rtl;
}

html[dir="rtl"] .pack-card {
    text-align: right;
    direction: rtl;
}

html[dir="rtl"] .profile-tabs-nav {
    direction: rtl;
}

html[dir="rtl"] .vocab-grid {
    direction: rtl;
}

html[dir="rtl"] .vocab-card-body {
    text-align: right;
    direction: rtl;
}

html[dir="rtl"] .vocab-card-footer {
    direction: rtl;
}

html[dir="rtl"] .vocab-word-preview-row {
    direction: rtl;
}

html[dir="rtl"] .vocab-col-fr {
    align-items: flex-end;
}

html[dir="rtl"] .vocab-col-ar {
    align-items: flex-start;
    text-align: left;
}

html[dir="rtl"] .vocab-render-preview {
    direction: rtl;
}

/* Toasts en RTL (Ancrage et bordure logique) */
html[dir="rtl"] .aya-toast {
    right: auto !important;
    left: 24px !important;
    border-left: none !important;
    border-right: 4px solid var(--color-turquoise) !important;
    direction: rtl;
    text-align: right;
}

html[dir="rtl"] .aya-toast.success {
    border-right-color: var(--color-turquoise) !important;
}

html[dir="rtl"] .aya-toast.error {
    border-right-color: #ef4444 !important;
}

html[dir="rtl"] .aya-toast.warning {
    border-right-color: #f59e0b !important;
}

html[dir="rtl"] .aya-toast.info {
    border-right-color: var(--color-primary) !important;
}

@media (max-width: 480px) {
    html[dir="rtl"] .aya-toast {
        left: 50% !important;
        right: auto !important;
        transform: translateX(-50%) !important;
    }
}

/* Cartes Vidéos Historique & Pack Cards en RTL */
html[dir="rtl"] .history-card {
    text-align: right;
    direction: rtl;
}

html[dir="rtl"] .video-actions-row {
    flex-direction: row-reverse;
}

html[dir="rtl"] .pack-info {
    padding-right: 0 !important;
    padding-left: 16px !important;
    text-align: right;
}

html[dir="rtl"] .pack-action {
    align-items: flex-start !important;
}

/* -------------------------------------------------------------
   Studio TikTok V3 en RTL
   ------------------------------------------------------------- */
html[dir="rtl"] .main-container {
    direction: rtl;
}

html[dir="rtl"] .control-panel {
    direction: rtl;
    text-align: right;
}

html[dir="rtl"] .section-title {
    text-align: right;
    direction: rtl;
}

html[dir="rtl"] .form-group {
    text-align: right;
    direction: rtl;
}

html[dir="rtl"] .checkbox-label {
    direction: rtl;
    text-align: right;
}

html[dir="rtl"] .simulator-header {
    flex-direction: row-reverse;
    flex-wrap: wrap;
    gap: 0.5rem;
}

html[dir="rtl"] .filename-info {
    text-align: right;
    direction: rtl;
}

html[dir="rtl"] .field-hint {
    text-align: right;
    direction: rtl;
}

html[dir="rtl"] .studio-page-header {
    text-align: right;
    direction: rtl;
}

/* -------------------------------------------------------------
   Pages Légales (CGU & Confidentialité) en RTL
   ------------------------------------------------------------- */
html[dir="rtl"] .legal-page-container,
html[dir="rtl"] .legal-card,
html[dir="rtl"] .legal-section {
    text-align: right;
    direction: rtl;
}

html[dir="rtl"] .legal-section h2 {
    flex-direction: row;
}

html[dir="rtl"] .btn-back-home {
    flex-direction: row-reverse;
}

html[dir="rtl"] .legal-footer-nav {
    flex-direction: row-reverse;
}

html[dir="rtl"] .legal-highlight-box {
    border-left: none !important;
    border-right: 4px solid #10b981;
    border-radius: 12px 0 0 12px !important;
    text-align: right !important;
}

html[dir="rtl"] .legal-warning-box {
    border-left: none !important;
    border-right: 4px solid #f59e0b;
    border-radius: 12px 0 0 12px !important;
    text-align: right !important;
}

html[dir="rtl"] .subcontractor-table th,
html[dir="rtl"] .subcontractor-table td {
    text-align: right !important;
}

/* -------------------------------------------------------------
   Isolation Bidi — Nombres et prix en contexte RTL
   Empêche les chiffres et devises de s'inverser en mode RTL
   ------------------------------------------------------------- */
.aya-bidi-num {
    unicode-bidi: isolate;
    direction: ltr;
    display: inline-block;
}

html[dir="rtl"] .navbar-online-pill,
html[dir="rtl"] .chat-online-pill {
    direction: rtl;
    text-align: right;
}

/* -------------------------------------------------------------
   Navigation Unifiée (Dropdowns Desktop, Bottom Nav & Action Sheet) RTL
   ------------------------------------------------------------- */
html[dir="rtl"] .nav-dropdown-menu {
    right: 0;
    left: auto;
    text-align: right;
}

html[dir="rtl"] #dropdownAccountWrapper .nav-dropdown-menu {
    left: 0;
    right: auto;
}

html[dir="rtl"] .dropdown-item {
    text-align: right;
}

html[dir="rtl"] .dropdown-group-label,
html[dir="rtl"] .sheet-section-title {
    text-align: right;
    text-transform: none;
    letter-spacing: normal;
}

html[dir="rtl"] .dropdown-item:hover {
    transform: translateX(-2px);
}

html[dir="rtl"] .aya-bottom-nav {
    direction: rtl;
}

html[dir="rtl"] .sheet-header {
    direction: rtl;
}

html[dir="rtl"] .sheet-card {
    direction: rtl;
    text-align: right;
}

html[dir="rtl"] .sheet-card-arrow {
    transform: scaleX(-1);
}

/* ── Harmonisation du Footer Légal & Solidaire en RTL (TICKET-19) ── */
html[dir="rtl"] .aya-legal-footer {
    direction: rtl;
    text-align: center;
}

html[dir="rtl"] .aya-legal-footer-links {
    direction: rtl;
}

html[dir="rtl"] .aya-legal-footer-copyright {
    direction: rtl;
    font-family: var(--font-arabic) !important;
}

/* ── STRV1 §12 : achat de Zaytounas (profil) en RTL — Cairo (règle générale ci-dessus), prix et références isolés
   en LTR, interligne normal des boutons ── */
html[dir="rtl"] .zp-card,
html[dir="rtl"] .zp-receipt {
    direction: rtl;
    text-align: right;
}

html[dir="rtl"] .zp-price,
html[dir="rtl"] .zp-ref {
    direction: ltr;
    unicode-bidi: isolate;
}

html[dir="rtl"] .zp-order-btn,
html[dir="rtl"] .zp-receipt-btn,
html[dir="rtl"] .zp-receipt-action {
    line-height: normal !important;
}

/* ── V2 socle commun : blocs éditoriaux explicitement français dans l'enveloppe arabe ──
   La règle Cairo générale (html[dir="rtl"] *) reste intacte pour tout texte arabe. Un bloc marqué lang="fr" (hors
   html/body) ou .hv-lang-fr garde Amiri, la lecture LTR et l'alignement à gauche ; un segment arabe (lang="ar" ou
   .hv-lang-ar) placé dans ce bloc revient à Cairo et RTL. :not(#hv-lang-guard) ne vise aucun élément : il élève
   seulement la spécificité au-dessus de la règle Cairo de aya-rtl.css. Les pictogrammes d'émoji gardent leur police. */
html[dir="rtl"] :is([lang="fr"]:not(html):not(body), .hv-lang-fr):not(#hv-lang-guard),
html[dir="rtl"] :is([lang="fr"]:not(html):not(body), .hv-lang-fr):not(#hv-lang-guard) *:not(.emoji-icon):not([data-emoji]) {
    font-family: var(--font-french, var(--font-latin)) !important;
}

html[dir="rtl"] :is([lang="fr"]:not(html):not(body), .hv-lang-fr):not(#hv-lang-guard) {
    direction: ltr;
    text-align: left;
}

html[dir="rtl"] :is([lang="fr"]:not(html):not(body), .hv-lang-fr) :is([lang="ar"], .hv-lang-ar):not(#hv-lang-guard):not(.emoji-icon):not([data-emoji]),
html[dir="rtl"] :is([lang="fr"]:not(html):not(body), .hv-lang-fr) :is([lang="ar"], .hv-lang-ar):not(#hv-lang-guard) *:not(.emoji-icon):not([data-emoji]) {
    font-family: var(--font-arabic) !important;
}

html[dir="rtl"] :is([lang="fr"]:not(html):not(body), .hv-lang-fr) :is([lang="ar"], .hv-lang-ar):not(#hv-lang-guard):not(.emoji-icon):not([data-emoji]) {
    direction: rtl;
    text-align: right;
}

/* ── V2 (P02-COMMUN-03, Lot 4B) : titre français affiché dans l'enveloppe arabe d'une page V2 ──
   La règle globale html[dir="rtl"] * { line-height: 1.7 !important } (style.css) donnait l'interligne arabe aux
   titres français (repli de langue). Exception limitée aux titres marqués lang="fr" (ou placés dans un bloc
   lang="fr") des pages .hv-v2 : interligne latin. :where() garde une spécificité basse pour que les réglages
   propres des pages (.hv-pXX …[lang="fr"]) restent prioritaires ; le texte arabe n'est pas concerné. */
html[dir="rtl"]:where(.hv-v2) :is(h1, h2, h3, h4)[lang="fr"],
html[dir="rtl"] :where(.hv-v2) :is(h1, h2, h3, h4)[lang="fr"],
html[dir="rtl"]:where(.hv-v2) [lang="fr"]:not(html):not(body) :is(h1, h2, h3, h4),
html[dir="rtl"] :where(.hv-v2) [lang="fr"] :is(h1, h2, h3, h4) {
    line-height: 1.25 !important;
}

html[dir="rtl"]:where(.hv-v2) :is(h1, h2, h3, h4)[lang="fr"] *,
html[dir="rtl"] :where(.hv-v2) :is(h1, h2, h3, h4)[lang="fr"] *,
html[dir="rtl"]:where(.hv-v2) [lang="fr"]:not(html):not(body) :is(h1, h2, h3, h4) *,
html[dir="rtl"] :where(.hv-v2) [lang="fr"] :is(h1, h2, h3, h4) * {
    line-height: inherit !important;
}

/* Parité RTL du sélecteur d'apparence dans Mon espace (profil.html) */
html[dir="rtl"] .hv-p07 .p07-theme-swatch-tri {
    transform: scaleX(-1);
}
