/**
 * RAFTELSHOP - Forcer RTL/LTR selon la langue
 * Force la direction correcte pour toutes les pages
 */

/* FORCER LTR pour les langues occidentales */
html[lang="fr"], html[lang="en"], html[lang="es"],
body[lang="fr"], body[lang="en"], body[lang="es"] {
    direction: ltr !important;
}

html[lang="fr"] *, html[lang="en"] *, html[lang="es"] *,
body[lang="fr"] *, body[lang="en"] *, body[lang="es"] * {
    direction: ltr !important;
}

/* RTL : arabe uniquement — kab / tif = interface LTR (translation.php, HTML_DIR) */
html[lang="ar"], body[lang="ar"] {
    direction: rtl !important;
}

html[lang="ar"] *, body[lang="ar"] * {
    direction: rtl !important;
}

html[lang="kab"], html[lang="tif"], body[lang="kab"], body[lang="tif"] {
    direction: ltr !important;
}

/* Exceptions : éléments qui doivent toujours rester LTR */
html[lang="ar"] .logo-link, html[lang="kab"] .logo-link, html[lang="tif"] .logo-link,
html[lang="ar"] .logo-img, html[lang="kab"] .logo-img, html[lang="tif"] .logo-img,
html[lang="ar"] input[type="number"], html[lang="kab"] input[type="number"], html[lang="tif"] input[type="number"] {
    direction: ltr !important;
}

/*
 * Montants (chiffres + DZD/DA) : toujours ordre LTR.
 * - html[lang=ar] * imposait RTL sur .product-price → inversion type « DZD 500 2 »
 * - [dir=rtl] .product-info héritait RTL vers les enfants
 */
html[lang="ar"] .product-price,
html[lang="ar"] .product-original-price,
html[lang="ar"] .deal-price,
html[lang="ar"] .deal-original-price,
body[lang="ar"] .product-price,
body[lang="ar"] .product-original-price,
body[lang="ar"] .deal-price,
body[lang="ar"] .deal-original-price,
[dir="rtl"] .product-price,
[dir="rtl"] .product-original-price,
[dir="rtl"] .deal-card .product-price,
[dir="rtl"] .deal-price,
[dir="rtl"] .deal-original-price,
[dir="rtl"] .product-info .product-price,
[dir="rtl"] .product-info .product-original-price,
[dir="rtl"] .deal-info .deal-price,
[dir="rtl"] .deal-info .product-price,
html[dir="rtl"] .price,
html[dir="rtl"] .deal-price,
html[dir="rtl"] .original-price,
html[dir="rtl"] .price-display,
html[dir="rtl"] .old-price,
body[dir="rtl"] .price,
body[dir="rtl"] .deal-price,
body[dir="rtl"] .original-price,
body[dir="rtl"] .price-display,
body[dir="rtl"] .old-price,
[dir="rtl"] .price-row .price,
[dir="rtl"] .price-row .deal-price,
[dir="rtl"] .price-row .original-price,
[dir="rtl"] .price-row .old-price {
    direction: ltr !important;
    unicode-bidi: isolate !important;
    text-align: right !important; /* bloc aligné à droite en page RTL, contenu chiffré intact */
}

[dir="rtl"] .vendor-rating,
[dir="rtl"] .vendor-rating-value,
[dir="rtl"] .vendor-rating-stars {
    direction: ltr !important;
    unicode-bidi: isolate !important;
}

html[dir="ltr"] .price,
html[dir="ltr"] .deal-price,
html[dir="ltr"] .original-price,
html[dir="ltr"] .price-display,
html[dir="ltr"] .currency,
html[dir="ltr"] .old-price,
body[dir="ltr"] .price,
body[dir="ltr"] .deal-price,
body[dir="ltr"] .original-price,
body[dir="ltr"] .price-display,
body[dir="ltr"] .currency,
body[dir="ltr"] .old-price,
[dir="ltr"] .price-row .price,
[dir="ltr"] .price-row .deal-price,
[dir="ltr"] .price-row .original-price,
[dir="ltr"] .price-row .old-price,
[dir="ltr"] .price-row .currency {
    direction: ltr !important;
    text-align: left !important;
    unicode-bidi: isolate !important;
}

/* Navbar : ne pas inverser complètement */
.navbar-container {
    flex-direction: row !important; /* Toujours garder logo à gauche, icônes à droite */
}

/* RTL : ajustements spécifiques sans inverser la navbar */
[dir="rtl"] .navbar-container {
    direction: rtl !important;
}

[dir="rtl"] .logo-link {
    direction: ltr !important; /* Logo reste toujours LTR */
}

[dir="rtl"] .navbar-actions {
    direction: rtl !important;
}

/* Texte RTL dans les éléments de contenu */
[dir="rtl"] .breadcrumb,
[dir="rtl"] .product-info,
[dir="rtl"] .deal-info,
[dir="rtl"] .vendor,
[dir="rtl"] .description,
[dir="rtl"] .content,
[dir="rtl"] p,
[dir="rtl"] h1, [dir="rtl"] h2, [dir="rtl"] h3, [dir="rtl"] h4, [dir="rtl"] h5, [dir="rtl"] h6 {
    text-align: right !important;
    direction: rtl !important;
}

/* LTR : forcer alignement à gauche */
[dir="ltr"] .breadcrumb,
[dir="ltr"] .product-info,
[dir="ltr"] .deal-info,
[dir="ltr"] .vendor,
[dir="ltr"] .description,
[dir="ltr"] .content,
[dir="ltr"] p,
[dir="ltr"] h1, [dir="ltr"] h2, [dir="ltr"] h3, [dir="ltr"] h4, [dir="ltr"] h5, [dir="ltr"] h6 {
    text-align: left !important;
    direction: ltr !important;
}

/* Boutons et liens : ajustement selon direction */
[dir="rtl"] .btn, [dir="rtl"] .button, [dir="rtl"] a {
    direction: rtl !important;
}

[dir="ltr"] .btn, [dir="ltr"] .button, [dir="ltr"] a {
    direction: ltr !important;
}

/* Inputs et formulaires */
[dir="rtl"] input, [dir="rtl"] textarea, [dir="rtl"] select {
    text-align: right !important;
    direction: rtl !important;
}

[dir="ltr"] input, [dir="ltr"] textarea, [dir="ltr"] select {
    text-align: left !important;
    direction: ltr !important;
}

/* Exception pour les champs numériques */
[dir="rtl"] input[type="number"], [dir="rtl"] input[type="tel"] {
    direction: ltr !important;
    text-align: left !important;
}