/*
 * rtl.css — Right-to-Left overrides for Glyphora
 * Loaded on all layouts when locale === 'ar'
 * Covers: admin, buyer, seller
 */

/* ============================================================
   FONT — Cairo for Arabic text
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;500;600;700;800&display=swap');

[dir="rtl"],
[dir="rtl"] body {
    font-family: 'Cairo', 'Segoe UI', Tahoma, sans-serif !important;
    direction: rtl;
    text-align: right;
}

/* ============================================================
   LAYOUT RESETS
   ============================================================ */

/* Flip flex row direction */
[dir="rtl"] .d-flex:not(.flex-column):not(.flex-column-reverse) {
    flex-direction: row-reverse;
}

/* Flex gap sides */
[dir="rtl"] .gap-end { margin-left: unset; margin-right: auto; }
[dir="rtl"] .gap-start { margin-right: unset; margin-left: auto; }
[dir="rtl"] .ms-auto { margin-left: unset !important; margin-right: auto !important; }
[dir="rtl"] .me-auto { margin-right: unset !important; margin-left: auto !important; }

/* Margins */
[dir="rtl"] .ms-1 { margin-left: unset !important; margin-right: 0.25rem !important; }
[dir="rtl"] .ms-2 { margin-left: unset !important; margin-right: 0.5rem !important; }
[dir="rtl"] .ms-3 { margin-left: unset !important; margin-right: 1rem !important; }
[dir="rtl"] .ms-4 { margin-left: unset !important; margin-right: 1.5rem !important; }
[dir="rtl"] .me-1 { margin-right: unset !important; margin-left: 0.25rem !important; }
[dir="rtl"] .me-2 { margin-right: unset !important; margin-left: 0.5rem !important; }
[dir="rtl"] .me-3 { margin-right: unset !important; margin-left: 1rem !important; }
[dir="rtl"] .me-4 { margin-right: unset !important; margin-left: 1.5rem !important; }

/* Padding */
[dir="rtl"] .ps-1 { padding-left: unset !important; padding-right: 0.25rem !important; }
[dir="rtl"] .ps-2 { padding-left: unset !important; padding-right: 0.5rem !important; }
[dir="rtl"] .ps-3 { padding-left: unset !important; padding-right: 1rem !important; }
[dir="rtl"] .ps-4 { padding-left: unset !important; padding-right: 1.5rem !important; }
[dir="rtl"] .pe-1 { padding-right: unset !important; padding-left: 0.25rem !important; }
[dir="rtl"] .pe-2 { padding-right: unset !important; padding-left: 0.5rem !important; }
[dir="rtl"] .pe-3 { padding-right: unset !important; padding-left: 1rem !important; }
[dir="rtl"] .pe-4 { padding-right: unset !important; padding-left: 1.5rem !important; }

/* Text alignment */
[dir="rtl"] .text-start { text-align: right !important; }
[dir="rtl"] .text-end   { text-align: left !important; }

/* Float */
[dir="rtl"] .float-start { float: right !important; }
[dir="rtl"] .float-end   { float: left !important; }

/* Border radius corners */
[dir="rtl"] .rounded-start { border-top-left-radius: unset !important; border-bottom-left-radius: unset !important; border-top-right-radius: var(--bs-border-radius) !important; border-bottom-right-radius: var(--bs-border-radius) !important; }
[dir="rtl"] .rounded-end   { border-top-right-radius: unset !important; border-bottom-right-radius: unset !important; border-top-left-radius: var(--bs-border-radius) !important; border-bottom-left-radius: var(--bs-border-radius) !important; }

/* ============================================================
   ADMIN SIDEBAR
   ============================================================ */

/* Sidebar position */
[dir="rtl"] .admin-sidebar {
    left: unset;
    right: 0;
    border-right: none;
    border-left: 1px solid var(--adm-border, rgba(255,255,255,0.08));
}

[dir="rtl"] .admin-content {
    margin-left: unset;
    margin-right: 260px;
}

[dir="rtl"] .admin-sidebar.collapsed ~ .admin-content {
    margin-right: 72px;
    margin-left: unset;
}

/* Sidebar nav items */
[dir="rtl"] .admin-nav-item {
    text-align: right;
}

[dir="rtl"] .admin-nav-link {
    padding-right: 20px;
    padding-left: 16px;
}

[dir="rtl"] .admin-nav-icon {
    margin-right: unset;
    margin-left: 10px;
}

[dir="rtl"] .admin-nav-arrow {
    margin-left: unset;
    margin-right: auto;
    transform: rotate(180deg);
}

[dir="rtl"] .admin-nav-arrow.open {
    transform: rotate(270deg);
}

/* Sidebar collapse toggle */
[dir="rtl"] .sidebar-toggle {
    right: unset;
    left: -12px;
}

/* Admin topbar */
[dir="rtl"] .admin-topbar {
    flex-direction: row-reverse;
}

[dir="rtl"] .admin-topbar .topbar-left {
    margin-right: unset;
    margin-left: auto;
}

[dir="rtl"] .admin-topbar .topbar-right {
    margin-left: unset;
    margin-right: auto;
}

/* Breadcrumb */
[dir="rtl"] .breadcrumb {
    flex-direction: row-reverse;
    padding-right: 0;
    padding-left: 1rem;
}

[dir="rtl"] .breadcrumb-item + .breadcrumb-item::before {
    padding-right: unset;
    padding-left: 0.5rem;
    float: right;
    content: "\\";
}

/* ============================================================
   ADMIN TABLES
   ============================================================ */

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

[dir="rtl"] .table th:first-child,
[dir="rtl"] .table td:first-child {
    text-align: right;
}

[dir="rtl"] .admin-table-actions {
    text-align: left;
}

/* Sort icons */
[dir="rtl"] .sort-icon {
    margin-left: unset;
    margin-right: 4px;
}

/* ============================================================
   ADMIN CARDS & STATS
   ============================================================ */

[dir="rtl"] .stat-card-icon {
    margin-left: unset;
    margin-right: auto;
}

[dir="rtl"] .stat-card-content {
    text-align: right;
}

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

[dir="rtl"] .kpi-icon {
    margin-left: unset;
    margin-right: 16px;
}

/* ============================================================
   FORMS (all layouts)
   ============================================================ */

[dir="rtl"] .form-label {
    display: block;
    text-align: right;
}

[dir="rtl"] .form-control,
[dir="rtl"] .form-select,
[dir="rtl"] input[type="text"],
[dir="rtl"] input[type="email"],
[dir="rtl"] input[type="password"],
[dir="rtl"] input[type="number"],
[dir="rtl"] input[type="tel"],
[dir="rtl"] textarea,
[dir="rtl"] select {
    text-align: right;
    direction: rtl;
}

[dir="rtl"] .form-check {
    padding-left: unset;
    padding-right: 1.5em;
}

[dir="rtl"] .form-check-input {
    float: right;
    margin-left: unset;
    margin-right: -1.5em;
}

/* Input groups */
[dir="rtl"] .input-group > .form-control:not(:first-child),
[dir="rtl"] .input-group > .form-select:not(:first-child) {
    border-radius: 0.375rem 0 0 0.375rem;
}

[dir="rtl"] .input-group > .form-control:not(:last-child),
[dir="rtl"] .input-group > .form-select:not(:last-child) {
    border-radius: 0 0.375rem 0.375rem 0;
}

[dir="rtl"] .input-group-text:first-child {
    border-radius: 0 0.375rem 0.375rem 0;
    border-left: none;
    border-right: 1px solid;
}

[dir="rtl"] .input-group-text:last-child {
    border-radius: 0.375rem 0 0 0.375rem;
    border-right: none;
    border-left: 1px solid;
}

/* Field icons inside inputs */
[dir="rtl"] .field-icon-left {
    left: unset;
    right: 12px;
}

[dir="rtl"] .field-icon-right {
    right: unset;
    left: 12px;
}

[dir="rtl"] .input-with-icon-left {
    padding-left: unset;
    padding-right: 40px;
}

[dir="rtl"] .input-with-icon-right {
    padding-right: unset;
    padding-left: 40px;
}

/* ============================================================
   BUYER LAYOUT
   ============================================================ */

/* Buyer navbar */
[dir="rtl"] .buyer-nav {
    flex-direction: row-reverse;
}

[dir="rtl"] .buyer-nav-links {
    flex-direction: row-reverse;
}

[dir="rtl"] .buyer-logo {
    margin-right: unset;
    margin-left: auto;
}

/* Buyer sidebar drawer */
[dir="rtl"] .buyer-drawer {
    left: unset;
    right: -320px;
    transform: translateX(100%);
}

[dir="rtl"] .buyer-drawer.open {
    right: 0;
    transform: translateX(0);
}

/* Hero search */
[dir="rtl"] .hero-search-form {
    flex-direction: row-reverse;
}

[dir="rtl"] .hero-search-icon {
    left: unset;
    right: 16px;
}

[dir="rtl"] .hero-search-input {
    padding-left: unset;
    padding-right: 48px;
    text-align: right;
}

/* Property cards */
[dir="rtl"] .property-card-info {
    text-align: right;
}

[dir="rtl"] .property-card-meta {
    flex-direction: row-reverse;
}

[dir="rtl"] .property-card-price {
    text-align: right;
}

[dir="rtl"] .property-card-location {
    flex-direction: row-reverse;
}

[dir="rtl"] .property-card-location .bi {
    margin-right: unset;
    margin-left: 4px;
}

/* Explore / Search page */
[dir="rtl"] .explore-sidebar {
    border-right: none;
    border-left: 1px solid rgba(255,255,255,0.08);
}

[dir="rtl"] .explore-results {
    padding-left: unset;
    padding-right: 1rem;
}

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

[dir="rtl"] .filter-chip {
    direction: rtl;
}

[dir="rtl"] .explore-sort-wrapper {
    flex-direction: row-reverse;
}

/* Property detail page */
[dir="rtl"] .pd-breadcrumb {
    flex-direction: row-reverse;
}

[dir="rtl"] .pd-info-row {
    flex-direction: row-reverse;
}

[dir="rtl"] .pd-meta-item {
    flex-direction: row-reverse;
}

[dir="rtl"] .pd-meta-item .bi {
    margin-right: unset;
    margin-left: 6px;
}

[dir="rtl"] .pd-sidebar {
    border-left: none;
    border-right: 1px solid rgba(255,255,255,0.08);
}

/* Buyer dashboard */
[dir="rtl"] .dashboard-section-header {
    flex-direction: row-reverse;
}

/* Tours steps */
[dir="rtl"] .tour-step-nav {
    flex-direction: row-reverse;
}

[dir="rtl"] .tour-step-indicator {
    flex-direction: row-reverse;
}

/* Offer form */
[dir="rtl"] .offer-financing-tabs {
    flex-direction: row-reverse;
}

/* Closing milestones */
[dir="rtl"] .milestone-list {
    padding-left: unset;
    padding-right: 1.5rem;
}

[dir="rtl"] .milestone-dot {
    left: unset;
    right: -1.5rem;
}

/* Mortgage calculator */
[dir="rtl"] .mortgage-calc-layout {
    flex-direction: row-reverse;
}

[dir="rtl"] .mortgage-slider-label {
    flex-direction: row-reverse;
}

/* ============================================================
   SELLER LAYOUT
   ============================================================ */

/* Seller sidebar */
[dir="rtl"] .seller-sidebar {
    left: unset;
    right: 0;
    border-right: none;
    border-left: 1px solid rgba(255,255,255,0.08);
}

[dir="rtl"] .seller-main {
    margin-left: unset;
    margin-right: 260px;
}

[dir="rtl"] .seller-sidebar.collapsed ~ .seller-main {
    margin-right: 72px;
    margin-left: unset;
}

/* Seller nav items */
[dir="rtl"] .seller-nav-link {
    flex-direction: row-reverse;
    padding-right: 20px;
    padding-left: 16px;
}

[dir="rtl"] .seller-nav-icon {
    margin-right: unset;
    margin-left: 10px;
}

/* Listing wizard steps */
[dir="rtl"] .wizard-steps {
    flex-direction: row-reverse;
}

[dir="rtl"] .wizard-step-connector {
    transform: scaleX(-1);
}

/* Seller listing cards */
[dir="rtl"] .listing-card-actions {
    flex-direction: row-reverse;
}

[dir="rtl"] .listing-card-meta {
    flex-direction: row-reverse;
}

/* Seller tour calendar */
[dir="rtl"] .tour-cal-nav {
    flex-direction: row-reverse;
}

/* ============================================================
   DROPDOWNS & MODALS (all layouts)
   ============================================================ */

[dir="rtl"] .dropdown-menu {
    text-align: right;
    right: 0;
    left: unset;
}

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

[dir="rtl"] .dropdown-item .bi {
    margin-right: unset;
    margin-left: 8px;
}

[dir="rtl"] .modal-header .btn-close {
    margin-right: auto;
    margin-left: 0;
}

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

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

/* ============================================================
   BADGES & TAGS
   ============================================================ */

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

/* ============================================================
   TOASTS (Glyphora UI)
   ============================================================ */

[dir="rtl"] #g-toast-container {
    left: 24px;
    right: unset;
}

[dir="rtl"] .g-toast {
    flex-direction: row-reverse;
    text-align: right;
}

[dir="rtl"] .g-toast__icon {
    margin-right: unset;
    margin-left: 12px;
}

[dir="rtl"] .g-toast__close {
    margin-left: unset;
    margin-right: 12px;
}

/* ============================================================
   ALERTS
   ============================================================ */

[dir="rtl"] .alert {
    text-align: right;
}

[dir="rtl"] .alert-dismissible {
    padding-right: 1rem;
    padding-left: 3rem;
}

[dir="rtl"] .alert-dismissible .btn-close {
    right: unset;
    left: 0;
}

/* ============================================================
   PAGINATION
   ============================================================ */

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

[dir="rtl"] .explore-pagination {
    flex-direction: row-reverse;
}

/* ============================================================
   ICONS inline with text
   ============================================================ */

[dir="rtl"] .bi + span,
[dir="rtl"] .bi + .text {
    margin-left: unset;
    margin-right: 6px;
}

[dir="rtl"] span + .bi,
[dir="rtl"] .text + .bi {
    margin-right: unset;
    margin-left: 6px;
}

/* ============================================================
   LANGUAGE SWITCHER
   ============================================================ */

/* ── Language Dropdown ── */
.lang-dropdown {
    position: relative;
}

/* Override Bootstrap .dropdown-toggle defaults with high specificity */
.lang-dropdown .lang-drop-btn,
.lang-dropdown .lang-drop-btn.dropdown-toggle {
    display: inline-flex !important;
    align-items: center !important;
    gap: 5px !important;
    background: rgba(255,255,255,0.1) !important;
    border: 1px solid rgba(255,255,255,0.22) !important;
    border-radius: 20px !important;
    padding: 5px 11px 5px 9px !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    color: #fff !important;
    cursor: pointer !important;
    transition: background 0.2s, border-color 0.2s !important;
    white-space: nowrap !important;
    box-shadow: none !important;
    text-decoration: none !important;
    line-height: 1.4 !important;
}

/* Remove Bootstrap's default caret arrow */
.lang-dropdown .lang-drop-btn::after,
.lang-dropdown .lang-drop-btn.dropdown-toggle::after {
    display: none !important;
}

.lang-dropdown .lang-drop-btn:hover,
.lang-dropdown .lang-drop-btn:focus,
.lang-dropdown .lang-drop-btn.dropdown-toggle:hover,
.lang-dropdown .lang-drop-btn.dropdown-toggle:focus {
    background: rgba(255,255,255,0.18) !important;
    border-color: rgba(255,255,255,0.35) !important;
    color: #fff !important;
    outline: none !important;
    box-shadow: none !important;
}

.lang-drop-flag {
    font-size: 15px;
    line-height: 1;
}

.lang-drop-short {
    font-size: 11px;
    letter-spacing: 0.04em;
}

.lang-drop-chevron {
    opacity: 0.7;
    transition: transform 0.18s;
    flex-shrink: 0;
    color: #fff;
}
.lang-dropdown .lang-drop-btn[aria-expanded="true"] .lang-drop-chevron {
    transform: rotate(180deg);
}

/* Dropdown panel */
.lang-dropdown .lang-drop-menu,
.lang-dropdown .dropdown-menu.lang-drop-menu {
    min-width: 155px !important;
    padding: 6px 0 !important;
    background: #1e2435 !important;
    border: 1px solid rgba(255,255,255,0.12) !important;
    border-radius: 10px !important;
    box-shadow: 0 8px 28px rgba(0,0,0,0.45) !important;
    margin-top: 6px !important;
}

.lang-dropdown .lang-drop-item,
.lang-dropdown .dropdown-menu .lang-drop-item {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 8px 14px !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    color: #d1d5db !important;
    background: transparent !important;
    transition: background 0.15s, color 0.15s !important;
}
.lang-dropdown .lang-drop-item:hover {
    background: rgba(255,255,255,0.08) !important;
    color: #fff !important;
}
.lang-dropdown .lang-drop-item.active {
    background: rgba(200,121,65,0.14) !important;
    color: #c87941 !important;
    font-weight: 600 !important;
}

.lang-drop-name {
    flex: 1;
}

.lang-drop-check {
    color: #c87941;
    flex-shrink: 0;
}

/* Admin variant */
.lang-dropdown--admin .lang-drop-btn,
.lang-dropdown--admin .lang-drop-btn.dropdown-toggle {
    background: rgba(255,255,255,0.07) !important;
    border-color: rgba(255,255,255,0.14) !important;
    color: #e2e8f0 !important;
}
.lang-dropdown--admin .lang-drop-btn:hover,
.lang-dropdown--admin .lang-drop-btn.dropdown-toggle:hover {
    background: rgba(255,255,255,0.13) !important;
    border-color: rgba(255,255,255,0.28) !important;
    color: #fff !important;
}
.lang-dropdown--admin .lang-drop-chevron {
    color: #e2e8f0;
}
.lang-dropdown--admin .lang-drop-menu,
.lang-dropdown--admin .dropdown-menu.lang-drop-menu {
    background: #161d2e !important;
    border-color: rgba(255,255,255,0.1) !important;
}

/* ============================================================
   NUMBER & DATE INPUTS — keep LTR for numerics
   ============================================================ */

[dir="rtl"] input[type="number"],
[dir="rtl"] input[type="date"],
[dir="rtl"] input[type="datetime-local"],
[dir="rtl"] input[type="time"] {
    direction: ltr;
    text-align: right;
}

/* Phone with dial code — keep dial code LTR */
[dir="rtl"] .dial-code-input {
    direction: ltr;
    text-align: left;
}

/* ============================================================
   ADMIN SPECIFIC OVERRIDES
   ============================================================ */

/* Admin sidebar sub-menu indent flip */
[dir="rtl"] .admin-sub-menu {
    padding-left: unset;
    padding-right: 20px;
}

[dir="rtl"] .admin-sub-menu .admin-nav-link {
    padding-right: 44px;
    padding-left: 16px;
}

/* Admin tabs */
[dir="rtl"] .nav-tabs {
    flex-direction: row-reverse;
}

/* Admin stats row */
[dir="rtl"] .admin-stats-grid {
    direction: rtl;
}

/* Admin user/listing detail header */
[dir="rtl"] .detail-header-info {
    text-align: right;
}

/* Admin offer/dispute detail timeline */
[dir="rtl"] .timeline {
    padding-left: unset;
    padding-right: 30px;
}

[dir="rtl"] .timeline-dot {
    left: unset;
    right: -30px;
}

[dir="rtl"] .timeline-connector {
    left: unset;
    right: -22px;
}

/* ============================================================
   SELLER SPECIFIC
   ============================================================ */

/* Seller dashboard KPI */
[dir="rtl"] .seller-kpi-card {
    text-align: right;
}

[dir="rtl"] .seller-kpi-icon {
    margin-left: unset;
    margin-right: auto;
}

/* Offer card in seller */
[dir="rtl"] .offer-card-header {
    flex-direction: row-reverse;
}

[dir="rtl"] .offer-card-meta {
    flex-direction: row-reverse;
}

/* Closing doc list */
[dir="rtl"] .closing-doc-item {
    flex-direction: row-reverse;
}

/* ============================================================
   RESPONSIVE RTL fixes
   ============================================================ */

@media (max-width: 768px) {
    [dir="rtl"] .admin-sidebar {
        right: -260px;
        left: unset;
    }

    [dir="rtl"] .admin-sidebar.mobile-open {
        right: 0;
        left: unset;
    }

    [dir="rtl"] .admin-content {
        margin-right: 0;
    }

    [dir="rtl"] .seller-sidebar {
        right: -260px;
        left: unset;
    }

    [dir="rtl"] .seller-sidebar.mobile-open {
        right: 0;
    }

    [dir="rtl"] .seller-main {
        margin-right: 0;
    }
}
