/**
 * Madrassatou Salahuddine - Styles RTL (Arabe)
 * Adaptations pour l'affichage droite à gauche
 */

/* ============================================
   BASE RTL
   ============================================ */
body.rtl {
    direction: rtl;
    text-align: right;
}

/* ============================================
   LAYOUT
   ============================================ */
body.rtl .app-layout {
    direction: rtl;
}

body.rtl .sidebar {
    left: auto;
    right: 0;
}

body.rtl .main-content {
    margin-left: 0;
    margin-right: 280px;
}

body.rtl .mobile-menu-toggle {
    left: auto;
    right: var(--space-md);
}

/* ============================================
   NAVIGATION
   ============================================ */
body.rtl .nav-item {
    flex-direction: row-reverse;
}

body.rtl .nav-item::before {
    left: auto;
    right: 0;
}

body.rtl .nav-item i {
    margin-left: var(--space-md);
    margin-right: 0;
}

body.rtl .nav-section-title {
    padding-left: 0;
    padding-right: var(--space-sm);
}

/* ============================================
   CARDS
   ============================================ */
body.rtl .stat-card {
    border-left: none;
    border-right: 4px solid var(--emerald);
}

body.rtl .stat-card.emerald {
    border-right-color: var(--emerald);
}

body.rtl .stat-card.gold {
    border-right-color: var(--gold-antique);
}

body.rtl .stat-card.burgundy {
    border-right-color: var(--burgundy);
}

body.rtl .stat-card.turquoise {
    border-right-color: var(--turquoise);
}

body.rtl .stat-card::before {
    right: auto;
    left: 0;
    border-radius: var(--radius-lg) 0 0 100%;
}

/* ============================================
   ALERTS
   ============================================ */
body.rtl .alert {
    flex-direction: row-reverse;
    border-left: none;
    border-right: 4px solid;
}

body.rtl .alert-success {
    border-right-color: var(--success);
}

body.rtl .alert-warning {
    border-right-color: var(--warning);
}

body.rtl .alert-danger {
    border-right-color: var(--danger);
}

body.rtl .alert-info {
    border-right-color: var(--info);
}

/* ============================================
   FORMULAIRES
   ============================================ */
body.rtl .form-select {
    background-position: left var(--space-md) center;
    padding-left: var(--space-2xl);
    padding-right: var(--space-lg);
}

body.rtl .login-form .form-control {
    padding-left: var(--space-lg);
    padding-right: 50px;
}

body.rtl .login-form .input-icon {
    left: auto;
    right: var(--space-lg);
}

/* ============================================
   TABLES
   ============================================ */
body.rtl .table th,
body.rtl .table td {
    text-align: right;
}

body.rtl .table th:first-child {
    border-radius: 0 var(--radius-lg) 0 0;
}

body.rtl .table th:last-child {
    border-radius: var(--radius-lg) 0 0 0;
}

/* ============================================
   FLEX UTILITIES
   ============================================ */
body.rtl .flex {
    flex-direction: row-reverse;
}

body.rtl .flex-between {
    flex-direction: row-reverse;
}

body.rtl .flex-center {
    flex-direction: row;
}

/* Exceptions - garder la direction normale */
body.rtl .grid,
body.rtl .surah-list,
body.rtl .progress {
    direction: ltr;
}

body.rtl .grid > * {
    direction: rtl;
}

/* ============================================
   BOUTONS
   ============================================ */
body.rtl .btn {
    flex-direction: row-reverse;
}

body.rtl .btn i {
    margin-left: var(--space-sm);
    margin-right: 0;
}

/* ============================================
   USER INFO
   ============================================ */
body.rtl .user-info {
    flex-direction: row-reverse;
}

body.rtl .user-details {
    text-align: right;
}

/* ============================================
   BREADCRUMB
   ============================================ */
body.rtl .breadcrumb {
    direction: rtl;
}

/* ============================================
   BADGES
   ============================================ */
body.rtl .badge {
    direction: rtl;
}

/* ============================================
   INCIDENTS / DISCIPLINE
   ============================================ */
body.rtl div[style*="border-left"] {
    border-left: none !important;
    border-right: 3px solid;
    border-radius: var(--radius-sm) 0 0 var(--radius-sm) !important;
}

/* ============================================
   PAGE HEADER
   ============================================ */
body.rtl .page-header {
    flex-direction: row-reverse;
}

body.rtl .header-actions {
    flex-direction: row-reverse;
}

/* ============================================
   CARD HEADER
   ============================================ */
body.rtl .card-header {
    flex-direction: row-reverse;
}

body.rtl .card-title {
    flex-direction: row-reverse;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

body.rtl .card-title i {
    margin-left: var(--space-sm);
    margin-right: 0;
}

/* ============================================
   QURAN PROGRESS
   ============================================ */
body.rtl .quran-progress {
    direction: rtl;
}

body.rtl .quran-progress .arabic-verse {
    direction: rtl;
}

/* ============================================
   SIDEBAR LOGO
   ============================================ */
body.rtl .sidebar-logo h1 {
    direction: rtl;
}

body.rtl .sidebar-logo .subtitle {
    direction: rtl;
}

/* ============================================
   LOGIN PAGE
   ============================================ */
body.rtl .login-card {
    direction: rtl;
    text-align: right;
}

body.rtl .login-header h1 {
    direction: rtl;
}

/* ============================================
   RESPONSIVE RTL
   ============================================ */
@media (max-width: 1024px) {
    body.rtl .sidebar {
        left: auto;
        right: 0;
        transform: translateX(100%);
    }

    body.rtl .sidebar.active {
        transform: translateX(0);
    }

    body.rtl .main-content {
        margin-right: 0;
        margin-left: 0;
    }

    body.rtl .mobile-menu-toggle {
        left: auto;
        right: var(--space-md);
    }
}

@media (max-width: 768px) {
    body.rtl .page-header {
        flex-direction: column;
        align-items: center !important;
        text-align: center !important;
    }

    body.rtl .page-header > div,
    body.rtl .page-header > div:first-child {
        text-align: center !important;
        align-items: center;
    }

    body.rtl .page-header h1 {
        text-align: center !important;
    }

    body.rtl .header-actions {
        width: 100%;
        flex-direction: row-reverse;
        justify-content: center;
    }

    body.rtl .card-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    body.rtl .card-title {
        text-align: center;
    }

    body.rtl .flex-between {
        flex-direction: column;
        align-items: stretch;
    }

    body.rtl .table-container::after {
        right: auto;
        left: 0;
        background: linear-gradient(to right, rgba(255,255,255,0.9), transparent);
    }
}

@media (max-width: 480px) {
    body.rtl .mobile-menu-toggle {
        right: var(--space-sm);
    }
}

/* ============================================
   STAT VALUES - NUMBERS LTR
   ============================================ */
body.rtl .stat-value {
    direction: ltr;
    display: inline-block;
}

/* ============================================
   PROGRESS BARS
   ============================================ */
body.rtl .progress {
    direction: ltr;
}

body.rtl .progress-bar {
    direction: ltr;
}

/* ============================================
   ICONS ALIGNMENT
   ============================================ */
body.rtl .fa-arrow-left::before {
    content: "\f061"; /* arrow-right */
}

body.rtl .fa-arrow-right::before {
    content: "\f060"; /* arrow-left */
}

body.rtl .fa-chevron-left::before {
    content: "\f054"; /* chevron-right */
}

body.rtl .fa-chevron-right::before {
    content: "\f053"; /* chevron-left */
}

/* ============================================
   SPECIAL ELEMENTS
   ============================================ */
body.rtl code {
    direction: ltr;
    display: inline-block;
}

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

@media (max-width: 1024px) {
    body.rtl .app-layout {
        display: block;
    }

    body.rtl .main-content {
        flex: 0 0 100%;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        margin-left: 0;
        margin-right: 0;
    }

    body.rtl .app-topbar {
        padding-left: 22px;
        padding-right: 76px;
    }

    body.rtl .mobile-menu-toggle {
        left: auto;
        right: 18px;
    }
}

@media (max-width: 640px) {
    body.rtl .main-content {
        padding-left: 12px;
        padding-right: 12px;
    }

    body.rtl .app-topbar {
        width: 100%;
        margin: 0 0 20px !important;
        padding: 10px 66px 10px 12px;
    }

    body.rtl .mobile-menu-toggle {
        position: fixed;
        left: auto !important;
        right: 12px !important;
    }

    body.rtl .global-search {
        flex: 1 1 0;
        width: 0;
        min-width: 0;
    }

    body.rtl .page-header,
    body.rtl .page-header > div,
    body.rtl .card,
    body.rtl .header-actions {
        width: 100%;
        min-width: 0;
        max-width: 100%;
    }

    body.rtl .header-actions {
        justify-content: center !important;
    }

    body.rtl .page-header .header-actions .btn {
        width: 100%;
    }

    body.rtl .page-header h1 {
        overflow-wrap: anywhere;
    }

    body.rtl .page-header .btn {
        max-width: 100%;
        height: auto;
        white-space: normal;
    }
}
