/* RTL Plus — base rtl overrides */
:root { --rtl-plus-flip: scaleX(-1); }

/* Force direction in body as well (safe fallback) */
html[dir="rtl"], body.rtl, body[dir="rtl"] {
    direction: rtl !important;
}

/* Common text alignments */
html[dir="rtl"] h1,
html[dir="rtl"] h2,
html[dir="rtl"] h3,
html[dir="rtl"] h4,
html[dir="rtl"] h5,
html[dir="rtl"] h6,
html[dir="rtl"] p,
html[dir="rtl"] .entry-content,
html[dir="rtl"] .post-content {
    text-align: right;
}

/* Align helpers */
.alignleft { float: right !important; margin-left: 0 !important; margin-right: 1rem !important; }
.alignright { float: left !important; margin-right: 0 !important; margin-left: 1rem !important; }

/* Swap margin/padding helpers where common classes are used */
html[dir="rtl"] [style*="margin-left"] { /* handled by JS for inline styles */ }

/* Mirror common UI components */
html[dir="rtl"] .menu,
html[dir="rtl"] nav,
html[dir="rtl"] .main-navigation {
    direction: rtl;
}

/* Breadcrumbs often use inline separators */
html[dir="rtl"] .breadcrumb,
html[dir="rtl"] .breadcrumbs { text-align: right; }

/* Form elements: labels on right */
html[dir="rtl"] label { text-align: right; display: block; }

/* Table direction */
html[dir="rtl"] table { direction: rtl; }

/* Mirror FontAwesome & similar icons (unless JS does it) */
html[dir="rtl"] .fa,
html[dir="rtl"] .fas,
html[dir="rtl"] .far,
html[dir="rtl"] .fab,
html[dir="rtl"] [class*="icon-"],
html[dir="rtl"] .dashicons {
    transform: var(--rtl-plus-flip);
    -webkit-transform: var(--rtl-plus-flip);
}

/* Mirror images that have 'rtl-mirror' class (developer can add) */
html[dir="rtl"] img.rtl-mirror {
    transform: var(--rtl-plus-flip);
    -webkit-transform: var(--rtl-plus-flip);
    direction: rtl;
}

/* Tabs and pills: flip order with flexbox if needed */
html[dir="rtl"] .nav-tabs,
html[dir="rtl"] .nav-pills,
html[dir="rtl"] .tabs {
    direction: rtl;
}

/* Utility: developers can add .no-rtl to prevent mirroring */
.no-rtl,
html[dir="rtl"] .no-rtl { transform: none !important; -webkit-transform: none !important; }

/* Small refinements for RTL inputs */
html[dir="rtl"] input[type="text"],
html[dir="rtl"] input[type="search"],
html[dir="rtl"] textarea {
    direction: rtl;
    text-align: right;
}

/* Make sure floats in widgets are handled */
html[dir="rtl"] .widget .alignleft { float: right; }
html[dir="rtl"] .widget .alignright { float: left; }

/* Buttons: icons inside button */
html[dir="rtl"] button .icon-left { margin-left: 0.5rem; margin-right: 0; }
html[dir="rtl"] button .icon-right { margin-right: 0.5rem; margin-left: 0; }

/* Minor: ensure pseudo-elements that used left/right behave better */
html[dir="rtl"] *::before, html[dir="rtl"] *::after {
    /* leave as-is; JS will fix inline styles if necessary */
}

/* Developers: override by adding more specific rules or by using the plugin's custom CSS area */
