/**
 * منصة يونيميديا - إصلاحات RTL ومحازاة اللغة العربية
 * RTL Alignment Fixes & Arabic Text Enhancement
 * Phase 2: RTL Consistency
 */

/* ================================
   إعدادات عامة للدعم RTL
   ================================ */
:root {
    --rtl-spacing-xs: 4px;
    --rtl-spacing-sm: 8px;
    --rtl-spacing-md: 16px;
    --rtl-spacing-lg: 24px;
    --rtl-spacing-xl: 32px;
}

/* تأكد من اتجاه RTL في كل مكان */
html[dir="rtl"],
[dir="rtl"] body {
    text-align: right;
    direction: rtl;
}

/* ================================
   إصلاحات الأيقونات في RTL
   ================================ */
[dir="rtl"] .me-1,
[dir="rtl"] .me-2,
[dir="rtl"] .me-3,
[dir="rtl"] .me-4,
[dir="rtl"] .me-5 {
    margin-left: inherit !important;
}

[dir="rtl"] .me-1 {
    margin-right: 0.25rem !important;
}

[dir="rtl"] .me-2 {
    margin-right: 0.5rem !important;
}

[dir="rtl"] .me-3 {
    margin-right: 1rem !important;
}

[dir="rtl"] .me-4 {
    margin-right: 1.5rem !important;
}

[dir="rtl"] .me-5 {
    margin-right: 3rem !important;
}

[dir="rtl"] .ms-1,
[dir="rtl"] .ms-2,
[dir="rtl"] .ms-3,
[dir="rtl"] .ms-4,
[dir="rtl"] .ms-5 {
    margin-right: inherit !important;
}

[dir="rtl"] .ms-1 {
    margin-left: 0.25rem !important;
}

[dir="rtl"] .ms-2 {
    margin-left: 0.5rem !important;
}

[dir="rtl"] .ms-3 {
    margin-left: 1rem !important;
}

[dir="rtl"] .ms-4 {
    margin-left: 1.5rem !important;
}

[dir="rtl"] .ms-5 {
    margin-left: 3rem !important;
}

[dir="rtl"] .pe-1,
[dir="rtl"] .pe-2,
[dir="rtl"] .pe-3,
[dir="rtl"] .pe-4,
[dir="rtl"] .pe-5 {
    padding-left: inherit !important;
}

[dir="rtl"] .pe-1 {
    padding-right: 0.25rem !important;
}

[dir="rtl"] .pe-2 {
    padding-right: 0.5rem !important;
}

[dir="rtl"] .pe-3 {
    padding-right: 1rem !important;
}

[dir="rtl"] .pe-4 {
    padding-right: 1.5rem !important;
}

[dir="rtl"] .pe-5 {
    padding-right: 3rem !important;
}

[dir="rtl"] .ps-1,
[dir="rtl"] .ps-2,
[dir="rtl"] .ps-3,
[dir="rtl"] .ps-4,
[dir="rtl"] .ps-5 {
    padding-right: inherit !important;
}

[dir="rtl"] .ps-1 {
    padding-left: 0.25rem !important;
}

[dir="rtl"] .ps-2 {
    padding-left: 0.5rem !important;
}

[dir="rtl"] .ps-3 {
    padding-left: 1rem !important;
}

[dir="rtl"] .ps-4 {
    padding-left: 1.5rem !important;
}

[dir="rtl"] .ps-5 {
    padding-left: 3rem !important;
}

/* ================================
   محازاة النصوص
   ================================ */
[dir="rtl"] .text-start {
    text-align: right !important;
}

[dir="rtl"] .text-end {
    text-align: left !important;
}

[dir="rtl"] .text-left {
    text-align: right !important;
}

[dir="rtl"] .text-right {
    text-align: left !important;
}

/* ================================
   إصلاح Flexbox في RTL
   ================================ */
[dir="rtl"] .flex-row {
    flex-direction: row-reverse;
}

[dir="rtl"] .flex-row-reverse {
    flex-direction: row;
}

/* Justify content fixes */
[dir="rtl"] .justify-content-start {
    justify-content: flex-end !important;
}

[dir="rtl"] .justify-content-end {
    justify-content: flex-start !important;
}

/* لا تعكس هذه العناصر */
[dir="rtl"] .d-flex.no-rtl-reverse {
    flex-direction: row !important;
}

[dir="rtl"] .flex-row.no-rtl-reverse {
    flex-direction: row !important;
}

/* ================================
   إصلاح البطاقات والقوائم
   ================================ */
[dir="rtl"] .card-header,
[dir="rtl"] .card-body,
[dir="rtl"] .card-footer {
    text-align: right;
}

[dir="rtl"] .list-group-item {
    text-align: right;
}

/* ================================
   إصلاح النماذج (Forms)
   ================================ */
[dir="rtl"] .form-control,
[dir="rtl"] .form-select,
[dir="rtl"] input,
[dir="rtl"] textarea,
[dir="rtl"] select {
    text-align: right;
}

[dir="rtl"] .form-check {
    padding-right: 1.5em;
    padding-left: 0;
}

[dir="rtl"] .form-check-input {
    float: right;
    margin-right: -1.5em;
    margin-left: 0;
}

[dir="rtl"] .input-group>.form-control,
[dir="rtl"] .input-group>.form-select {
    border-radius: 0;
}

[dir="rtl"] .input-group> :first-child {
    border-top-right-radius: 0.375rem;
    border-bottom-right-radius: 0.375rem;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

[dir="rtl"] .input-group> :last-child {
    border-top-left-radius: 0.375rem;
    border-bottom-left-radius: 0.375rem;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

/* ================================
   إصلاح الأزرار
   ================================ */
[dir="rtl"] .btn-group>.btn:first-child {
    border-top-right-radius: 0.375rem;
    border-bottom-right-radius: 0.375rem;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

[dir="rtl"] .btn-group>.btn:last-child {
    border-top-left-radius: 0.375rem;
    border-bottom-left-radius: 0.375rem;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

[dir="rtl"] .btn i+span,
[dir="rtl"] .btn span+i {
    margin-right: 0.5rem;
    margin-left: 0;
}

/* ================================
   إصلاح القوائم المنسدلة
   ================================ */
[dir="rtl"] .dropdown-menu {
    text-align: right;
    left: auto;
    right: 0;
}

[dir="rtl"] .dropdown-menu-end {
    left: 0;
    right: auto;
}

[dir="rtl"] .dropdown-item {
    text-align: right;
}

[dir="rtl"] .dropdown-item i {
    margin-left: 0.75rem;
    margin-right: 0;
}

/* ================================
   إصلاح الشريط الجانبي والتنقل
   ================================ */
[dir="rtl"] .navbar-nav {
    padding-right: 0;
}

[dir="rtl"] .nav-link {
    text-align: right;
}

[dir="rtl"] .breadcrumb-item+.breadcrumb-item::before {
    float: right;
    padding-left: 0.5rem;
    padding-right: 0;
    content: "\\";
}

/* ================================
   إصلاح التباعد والهوامش
   ================================ */
[dir="rtl"] .border-start {
    border-right: var(--bs-border-width) var(--bs-border-style) var(--bs-border-color) !important;
    border-left: 0 !important;
}

[dir="rtl"] .border-end {
    border-left: var(--bs-border-width) var(--bs-border-style) var(--bs-border-color) !important;
    border-right: 0 !important;
}

[dir="rtl"] .rounded-start {
    border-top-right-radius: var(--bs-border-radius) !important;
    border-bottom-right-radius: var(--bs-border-radius) !important;
    border-top-left-radius: 0 !important;
    border-bottom-left-radius: 0 !important;
}

[dir="rtl"] .rounded-end {
    border-top-left-radius: var(--bs-border-radius) !important;
    border-bottom-left-radius: var(--bs-border-radius) !important;
    border-top-right-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
}

/* ================================
   إصلاح الأيقونات والسهام
   ================================ */
[dir="rtl"] .fa-arrow-right::before {
    content: "\f060";
}

/* يصبح سهم يسار */
[dir="rtl"] .fa-arrow-left::before {
    content: "\f061";
}

/* يصبح سهم يمين */
[dir="rtl"] .fa-chevron-right::before {
    content: "\f053";
}

[dir="rtl"] .fa-chevron-left::before {
    content: "\f054";
}

[dir="rtl"] .fa-angle-right::before {
    content: "\f104";
}

[dir="rtl"] .fa-angle-left::before {
    content: "\f105";
}

/* لا تعكس هذه الأيقونات */
[dir="rtl"] .no-rtl-flip i,
[dir="rtl"] i.no-rtl-flip {
    transform: none !important;
}

/* ================================
   إصلاحات خاصة بالهيدر
   ================================ */
[dir="rtl"] .header-toolbar .toolbar-start {
    order: 2;
}

[dir="rtl"] .header-toolbar .toolbar-end {
    order: 0;
}

[dir="rtl"] .header-toolbar .center-logo {
    order: 1;
}

/* ================================
   إصلاح الجداول
   ================================ */
[dir="rtl"] table {
    text-align: right;
}

[dir="rtl"] th,
[dir="rtl"] td {
    text-align: right;
}

[dir="rtl"] .table-responsive {
    overflow-x: auto;
}

/* ================================
   إصلاح modals و alerts
   ================================ */
[dir="rtl"] .modal-header .btn-close {
    margin: -0.5rem auto -0.5rem -0.5rem;
}

[dir="rtl"] .alert {
    text-align: right;
}

[dir="rtl"] .alert-dismissible .btn-close {
    left: 0;
    right: auto;
}

/* ================================
   إصلاح Pagination
   ================================ */
[dir="rtl"] .pagination {
    flex-direction: row-reverse;
}

[dir="rtl"] .page-item:first-child .page-link {
    border-top-right-radius: var(--bs-pagination-border-radius);
    border-bottom-right-radius: var(--bs-pagination-border-radius);
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

[dir="rtl"] .page-item:last-child .page-link {
    border-top-left-radius: var(--bs-pagination-border-radius);
    border-bottom-left-radius: var(--bs-pagination-border-radius);
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

/* ================================
   إصلاح Progress bars
   ================================ */
[dir="rtl"] .progress-bar {
    float: right;
}

[dir="rtl"] .progress {
    direction: rtl;
}

/* ================================
   إصلاحات خاصة بصفحات التصفح
   ================================ */
[dir="rtl"] .filter-sidebar {
    border-left: 1px solid rgba(0, 0, 0, 0.1);
    border-right: none;
}

[dir="rtl"] .project-card .card-body,
[dir="rtl"] .talent-card .card-body,
[dir="rtl"] .equipment-card .card-body {
    text-align: right;
}

[dir="rtl"] .card-meta {
    display: flex;
    flex-direction: row-reverse;
    justify-content: flex-end;
}

/* ================================
   إصلاح الفوتر
   ================================ */
[dir="rtl"] .footer-links {
    text-align: right;
}

[dir="rtl"] .footer-social {
    justify-content: flex-start;
}

[dir="rtl"] .footer-bottom {
    text-align: right;
}

/* ================================
   تحسين قراءة النص العربي
   ================================ */
[dir="rtl"] p,
[dir="rtl"] .description,
[dir="rtl"] .content {
    line-height: 1.9;
    text-align: right;
}

/* أرقام بالعربي أو الإنجليزي */
[dir="rtl"] .numbers-ar {
    font-feature-settings: "tnum" on;
}

/* ================================
   إصلاحات للشاشات الصغيرة
   ================================ */
@media (max-width: 768px) {
    [dir="rtl"] .mobile-menu-content {
        right: -280px;
        left: auto;
    }

    [dir="rtl"] .mobile-menu-overlay.active .mobile-menu-content {
        right: 0;
        left: auto;
    }

    [dir="rtl"] .mobile-menu-header {
        flex-direction: row-reverse;
    }
}

/* ==========================================================================
   Helper Classes للتحكم في RTL
   ========================================================================== */
.rtl-hidden {
    display: none;
}

[dir="rtl"] .rtl-hidden {
    display: block;
}

[dir="rtl"] .ltr-hidden {
    display: none;
}

.rtl-flip {
    transform: scaleX(1);
}

[dir="rtl"] .rtl-flip {
    transform: scaleX(-1);
}

/* عدم عكس المحتوى */
.preserve-ltr {
    direction: ltr !important;
    text-align: left !important;
}

[dir="rtl"] .preserve-ltr {
    direction: ltr !important;
    text-align: left !important;
}


/* ================================
   إصلاحات إضافية للأيقونات المصفوفة
   ================================ */
[dir="rtl"] .icon-text {
    display: inline-flex;
    flex-direction: row-reverse;
    align-items: center;
    gap: 8px;
}

[dir="rtl"] .stat-item,
[dir="rtl"] .info-item {
    flex-direction: row;
}

/* ================================
   تحسين التباين والقراءة
   ================================ */
body {
    font-family: 'Noto Sans Arabic', 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    font-feature-settings: "kern" 1, "liga" 1;
}

/* القاعدة المُعدلة: استئصال اليمين القسري للسماح بالتوسيط الإبداعي */
[dir="rtl"] h1,
[dir="rtl"] h2,
[dir="rtl"] h3,
[dir="rtl"] h4,
[dir="rtl"] h5,
[dir="rtl"] h6 {
    text-align: unset;
    font-weight: 700;
}

/* === Hero Slogan Mobile Fix === */
.hero-slogan {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0;
    unicode-bidi: isolate;
}

@media (max-width: 480px) {
    .hero-slogan {
        flex-direction: column;
        gap: 0.2rem;
        letter-spacing: 0 !important;
    }
    .hero-slogan bdi,
    .hero-slogan span {
        display: block !important;
        text-align: center;
    }
    .hero-slogan span[style*="opacity"] {
        display: none !important;
    }
}
