/* ============================================================
   RTL (right-to-left) overrides — Arabic site (sites/fampower_ar)
   Issue #240 — https://github.com/FitforKids10/fitforkids-dk/issues/240

   Loaded LAST in the <head> of the backend (coach/member app), the
   legacy frontend, and the standalone auth/error pages — after
   Bootstrap 3.3.6 and the site theme CSS, so equal-specificity rules
   win by source order.

   Every rule is scoped under [dir="rtl"] so this file is completely
   inert on an LTR document. The whole fampower_ar tree is the Arabic
   site, so its templates carry <html dir="rtl" lang="ar"> and this
   sheet is always active there — no LTR site is affected.

   Scope: base direction, generic utilities, the Bootstrap 3 component
   set (grid, floats, nav, dropdowns, modals, forms, tables, lists,
   pagination, breadcrumbs), and directional Font Awesome 4 icons.
   Bespoke per-page backend components are left for the RTL visual-QA
   pass tracked by #242/#243.
   ============================================================ */

/* --- Base direction --------------------------------------- */
html[dir="rtl"] body { direction: rtl; text-align: right; }

/* --- Generic + Bootstrap 3 float / text utilities --------- */
[dir="rtl"] .pull-left,  [dir="rtl"] .float-left,  [dir="rtl"] .fl { float: right !important; }
[dir="rtl"] .pull-right, [dir="rtl"] .float-right, [dir="rtl"] .fr { float: left  !important; }
[dir="rtl"] .text-left  { text-align: right !important; }
[dir="rtl"] .text-right { text-align: left  !important; }

/* --- Bootstrap 3 grid: columns float the other way -------- */
[dir="rtl"] .row > [class^="col-"],
[dir="rtl"] .row > [class*=" col-"] { float: right; }

/* --- Navbar ----------------------------------------------- */
[dir="rtl"] .navbar-nav { margin: 0; }
[dir="rtl"] .navbar-right { float: left !important; margin-right: 0; margin-left: -15px; }
[dir="rtl"] .navbar-left  { float: right !important; }
@media (min-width: 768px) {
  [dir="rtl"] .navbar-nav > li { float: right; }
}

/* --- Dropdowns -------------------------------------------- */
[dir="rtl"] .dropdown-menu { right: 0; left: auto; text-align: right; }
[dir="rtl"] .dropdown-menu.pull-right,
[dir="rtl"] .dropdown-menu-right { right: auto; left: 0; }
[dir="rtl"] .dropdown-menu > li > a { text-align: right; }
[dir="rtl"] .caret { margin-right: 2px; margin-left: 0; }

/* --- Buttons with icons / button groups ------------------- */
[dir="rtl"] .btn-group > .btn:first-child { margin-left: 0; }
[dir="rtl"] .btn .fa,
[dir="rtl"] .btn .glyphicon { margin-left: 4px; margin-right: 0; }

/* --- Forms ------------------------------------------------ */
[dir="rtl"] .form-horizontal .control-label { text-align: left; }
[dir="rtl"] .radio label,
[dir="rtl"] .checkbox label { padding-left: 0; padding-right: 20px; }
[dir="rtl"] .radio input[type="radio"],
[dir="rtl"] .radio-inline input[type="radio"],
[dir="rtl"] .checkbox input[type="checkbox"],
[dir="rtl"] .checkbox-inline input[type="checkbox"] { margin-left: 0; margin-right: -20px; }
[dir="rtl"] .checkbox-inline,
[dir="rtl"] .radio-inline { padding-left: 0; padding-right: 20px; }
[dir="rtl"] .checkbox-inline + .checkbox-inline,
[dir="rtl"] .radio-inline + .radio-inline { margin-left: 0; margin-right: 10px; }
[dir="rtl"] .form-control { text-align: right; }

/* --- Input groups: swap the rounded ends ------------------ */
[dir="rtl"] .input-group .form-control:first-child,
[dir="rtl"] .input-group-addon:first-child,
[dir="rtl"] .input-group-btn:first-child > .btn {
  border-radius: 0 4px 4px 0;
}
[dir="rtl"] .input-group .form-control:last-child,
[dir="rtl"] .input-group-addon:last-child,
[dir="rtl"] .input-group-btn:last-child > .btn {
  border-radius: 4px 0 0 4px;
}

/* --- Lists, list-groups, definition lists ----------------- */
[dir="rtl"] .list-group { padding-right: 0; }
@media (min-width: 768px) {
  /* BS3 only floats .dl-horizontal at >=768px — mirror at the same breakpoint. */
  [dir="rtl"] .dl-horizontal dt { float: right; text-align: left; }
  [dir="rtl"] .dl-horizontal dd { margin-left: 0; margin-right: 180px; }
}

/* --- Breadcrumbs ------------------------------------------ */
[dir="rtl"] .breadcrumb > li { float: right; }
[dir="rtl"] .breadcrumb > li + li:before { padding: 0 5px; }

/* --- Pagination / pager ----------------------------------- */
[dir="rtl"] .pagination { padding-right: 0; }
[dir="rtl"] .pagination > li:first-child > a,
[dir="rtl"] .pagination > li:first-child > span { border-radius: 0 4px 4px 0; }
[dir="rtl"] .pagination > li:last-child > a,
[dir="rtl"] .pagination > li:last-child > span { border-radius: 4px 0 0 4px; }

/* --- Nav tabs / pills ------------------------------------- */
[dir="rtl"] .nav-tabs > li,
[dir="rtl"] .nav-pills > li { float: right; }
[dir="rtl"] .nav-tabs > li { margin-right: 0; margin-left: 2px; }

/* --- Tables ----------------------------------------------- */
[dir="rtl"] .table { text-align: right; }
[dir="rtl"] .table caption { text-align: right; }

/* --- Modals / alerts: the close button changes side ------- */
[dir="rtl"] .modal-header .close { float: left; }
[dir="rtl"] .modal-footer { text-align: left; }
[dir="rtl"] .alert-dismissable .close,
[dir="rtl"] .alert-dismissible .close { right: auto; left: -21px; }
[dir="rtl"] .close { float: left; }

/* --- Panels / wells --------------------------------------- */
[dir="rtl"] .panel-title { text-align: right; }

/* --- Directional Font Awesome 4 icons (mirror them) ------- */
[dir="rtl"] .fa-angle-left:before          { content: "\f105"; }
[dir="rtl"] .fa-angle-right:before         { content: "\f104"; }
[dir="rtl"] .fa-angle-double-left:before   { content: "\f101"; }
[dir="rtl"] .fa-angle-double-right:before  { content: "\f100"; }
[dir="rtl"] .fa-chevron-left:before        { content: "\f054"; }
[dir="rtl"] .fa-chevron-right:before       { content: "\f053"; }
[dir="rtl"] .fa-chevron-circle-left:before { content: "\f138"; }
[dir="rtl"] .fa-chevron-circle-right:before{ content: "\f137"; }
[dir="rtl"] .fa-arrow-left:before          { content: "\f061"; }
[dir="rtl"] .fa-arrow-right:before         { content: "\f060"; }
[dir="rtl"] .fa-arrow-circle-left:before   { content: "\f0a9"; }
[dir="rtl"] .fa-arrow-circle-right:before  { content: "\f0a8"; }
[dir="rtl"] .fa-long-arrow-left:before     { content: "\f178"; }
[dir="rtl"] .fa-long-arrow-right:before    { content: "\f177"; }
[dir="rtl"] .fa-caret-left:before          { content: "\f0da"; }
[dir="rtl"] .fa-caret-right:before         { content: "\f0d9"; }
