/* ============================================
   RTL (Right-to-Left) Stylesheet
   دعم اللغة العربية - من اليمين لليسار
   مؤسسة محمود الحفناوى للتنمية الخيرية
   ============================================ */

[dir="rtl"] {
    direction: rtl;
    text-align: right;
    font-family: var(--font-primary);
}

/* ============================================
   Forms RTL
   ============================================ */

[dir="rtl"] .form-select {
    background-position: left 0.875rem center;
    padding-left: 2.5rem;
    padding-right: 0.875rem;
}

[dir="rtl"] .form-check {
    padding-right: 0;
}

[dir="rtl"] .form-check-input {
    margin-left: var(--spacing-sm);
    margin-right: 0;
}

[dir="rtl"] .input-group > .form-control {
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

[dir="rtl"] .input-group > .input-group-text:first-child {
    border-radius: var(--radius-md) 0 0 var(--radius-md);
}

[dir="rtl"] .input-group > .input-group-text:last-child {
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

[dir="rtl"] .form-label .required {
    margin-left: 0.25rem;
    margin-right: 0;
}

/* ============================================
   Layout RTL
   ============================================ */

[dir="rtl"] .sidebar {
    right: 0;
    left: auto;
}

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

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

[dir="rtl"] .sidebar.collapsed {
    transform: translateX(-260px);
}

/* ============================================
   Navigation RTL
   ============================================ */

[dir="rtl"] .sidebar-nav .nav-link {
    border-right: 3px solid transparent;
    border-left: none;
}

[dir="rtl"] .sidebar-nav .nav-link .nav-badge {
    margin-left: 0;
    margin-right: auto;
}

[dir="rtl"] .breadcrumb-item + .breadcrumb-item::before {
    content: '\\';
    margin-left: var(--spacing-sm);
    margin-right: 0;
}

/* ============================================
   Header RTL
   ============================================ */

[dir="rtl"] .header-search .search-icon {
    right: 12px;
    left: auto;
}

[dir="rtl"] .header-search .search-input {
    padding-right: 2.5rem;
    padding-left: 1rem;
}

[dir="rtl"] .header-icon .badge {
    right: 2px;
    left: auto;
}

/* ============================================
   Cards RTL
   ============================================ */

[dir="rtl"] .stat-card::before {
    left: auto;
    right: 0;
}

[dir="rtl"] .stat-card .stat-change {
    flex-direction: row;
}

/* ============================================
   Tables RTL
   ============================================ */

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

/* ============================================
   Modals RTL
   ============================================ */

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

/* ============================================
   Dropdown RTL
   ============================================ */

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

[dir="rtl"] .dropdown-menu.dropdown-menu-end {
    right: auto;
    left: 0;
}

/* ============================================
   Utilities RTL
   ============================================ */

[dir="rtl"] .ms-auto {
    margin-right: auto !important;
    margin-left: 0 !important;
}

[dir="rtl"] .me-auto {
    margin-left: auto !important;
    margin-right: 0 !important;
}

[dir="rtl"] .text-start {
    text-align: right !important;
}

[dir="rtl"] .text-end {
    text-align: left !important;
}

[dir="rtl"] .float-start {
    float: right !important;
}

[dir="rtl"] .float-end {
    float: left !important;
}

[dir="rtl"] .border-start {
    border-right: 1px solid var(--gray-200) !important;
    border-left: none !important;
}

[dir="rtl"] .border-end {
    border-left: 1px solid var(--gray-200) !important;
    border-right: none !important;
}

[dir="rtl"] .ps-md {
    padding-right: var(--spacing-md) !important;
    padding-left: 0 !important;
}

[dir="rtl"] .pe-md {
    padding-left: var(--spacing-md) !important;
    padding-right: 0 !important;
}

/* ============================================
   Animation RTL
   ============================================ */

[dir="rtl"] .slide-in-left {
    animation: slideInRight 0.3s ease forwards;
}

[dir="rtl"] .slide-in-right {
    animation: slideInLeft 0.3s ease forwards;
}

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideInLeft {
    from { transform: translateX(-100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ============================================
   Print RTL
   ============================================ */

@media print {
    [dir="rtl"] {
        direction: rtl;
    }
}