/* =============================================
   RTL (Right-to-Left) Stylesheet
   For Arabic and other RTL languages
   ============================================= */

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

/* ----- Header RTL ----- */
body.rtl .header-left {
    flex-direction: row-reverse;
}

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

body.rtl .search-box input {
    padding: 10px 44px 10px 16px;
    text-align: right;
}

body.rtl .search-box svg {
    left: auto;
    right: 14px;
}

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

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

/* ----- Sidebar RTL ----- */
body.rtl .sidebar {
    left: auto;
    right: 0;
    border-right: none;
    border-left: 1px solid var(--border);
}

body.rtl .nav-group-header {
    border-left: none;
    border-right: 3px solid transparent;
    flex-direction: row-reverse;
}

body.rtl .nav-group.active > .nav-group-header {
    border-left-color: transparent;
    border-right-color: var(--primary);
}

body.rtl .nav-group-header span {
    flex-direction: row-reverse;
}

body.rtl .nav-group-header .chevron {
    transform: rotate(180deg);
}

body.rtl .nav-group.open > .nav-group-header .chevron {
    transform: rotate(90deg);
}

body.rtl .nav-item {
    padding: 8px 52px 8px 20px;
    border-left: none;
    border-right: 3px solid transparent;
}

body.rtl .nav-item.active {
    border-left-color: transparent;
    border-right-color: var(--primary);
}

/* ----- Main Content RTL ----- */
body.rtl .main {
    margin-left: 0;
    margin-right: var(--sidebar-width);
}

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

body.rtl .breadcrumb svg {
    transform: rotate(180deg);
}

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

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

/* ----- Progress Bar RTL ----- */
body.rtl .progress-bar {
    left: 0;
    right: var(--sidebar-width);
}

body.rtl .progress-bar .progress {
    float: right;
}

/* ----- Card RTL ----- */
html[dir="rtl"] .card,
body.rtl .card {
    direction: rtl;
    text-align: right;
}

html[dir="rtl"] .card-header,
body.rtl .card-header {
    flex-direction: row-reverse !important;
    display: flex !important;
}

html[dir="rtl"] .card-header h2,
body.rtl .card-header h2 {
    flex-direction: row-reverse !important;
    display: flex !important;
}

html[dir="rtl"] .card-header h2 .icon,
body.rtl .card-header h2 .icon {
    order: 1;
    margin-left: 10px;
    margin-right: 0;
}

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

/* ----- Diagram RTL ----- */
body.rtl .diagram-controls {
    right: auto;
    left: 12px;
}

body.rtl .diagram-hint {
    direction: rtl;
}

/* ----- Info Box RTL ----- */
html[dir="rtl"] .info-box,
body.rtl .info-box {
    flex-direction: row-reverse !important;
    display: flex !important;
    text-align: right;
}

html[dir="rtl"] .info-box > .icon,
body.rtl .info-box > .icon {
    order: 1;
    margin-left: 12px;
    margin-right: 0;
}

html[dir="rtl"] .info-box-content,
body.rtl .info-box-content {
    text-align: right;
}

/* ----- Table RTL ----- */
body.rtl th,
body.rtl td {
    text-align: right;
}

/* ----- Step List RTL ----- */
html[dir="rtl"] .step-list,
body.rtl .step-list {
    direction: rtl;
}

html[dir="rtl"] .step-item,
body.rtl .step-item {
    flex-direction: row-reverse !important;
    display: flex !important;
}

html[dir="rtl"] .step-content,
body.rtl .step-content {
    text-align: right;
    flex: 1;
}

html[dir="rtl"] .step-number,
body.rtl .step-number {
    order: 1;
    margin-left: 16px;
    margin-right: 0;
}

/* =============================================
   LIST RTL - Critical Fix for Bullet Position
   ============================================= */

/* Remove default list styling and use custom RTL bullets */
body.rtl ul,
body.rtl ol {
    list-style: none !important;
    padding-right: 0 !important;
    padding-left: 0 !important;
    margin: 16px 0;
}

body.rtl li {
    position: relative;
    padding-right: 24px;
    padding-left: 0;
    text-align: right;
    margin-bottom: 8px;
}

/* Custom bullet on the right side for unordered lists */
body.rtl ul > li::before {
    content: "•";
    position: absolute;
    right: 0;
    top: 0;
    color: inherit;
    font-size: 1.2em;
    line-height: 1.4;
}

/* Custom numbers on the right side for ordered lists */
body.rtl ol {
    counter-reset: rtl-counter;
}

body.rtl ol > li {
    counter-increment: rtl-counter;
}

body.rtl ol > li::before {
    content: counter(rtl-counter) ".";
    position: absolute;
    right: 0;
    top: 0;
    color: inherit;
    font-weight: 500;
}

/* Nested lists */
body.rtl ul ul,
body.rtl ol ol,
body.rtl ul ol,
body.rtl ol ul {
    margin-right: 16px;
    margin-left: 0;
    margin-top: 8px;
    margin-bottom: 8px;
}

/* Override inline styles on lists */
body.rtl ul[style],
body.rtl ol[style] {
    padding-right: 0 !important;
    padding-left: 0 !important;
}

body.rtl li[style] {
    padding-right: 24px !important;
    padding-left: 0 !important;
}

/* Role badge in RTL */
body.rtl .step-content .role-badge {
    display: inline-block;
}

/* Inline styled divs with background in step content */
body.rtl .step-content > div[style*="background"],
body.rtl .card-body > div[style*="background"],
body.rtl div[style*="background"] {
    text-align: right;
}

/* ----- Phase Cards RTL ----- */
body.rtl .phase-card {
    text-align: right;
}

/* ----- Color Legend RTL ----- */
body.rtl .color-item {
    flex-direction: row-reverse;
}

/* ----- Overview Cards RTL ----- */
body.rtl .overview-card {
    text-align: center;
}

/* ----- Footer RTL ----- */
body.rtl .footer {
    text-align: center;
}

/* =============================================
   Modal RTL Overrides
   ============================================= */
body.rtl .modal-header {
    flex-direction: row-reverse;
}

body.rtl .modal-title {
    text-align: right;
}

body.rtl .modal-close {
    left: 20px;
    right: auto;
}

body.rtl .modal-zoom-controls {
    flex-direction: row-reverse;
}

body.rtl .modal-hint {
    direction: rtl;
}

/* =============================================
   Landing Page RTL Overrides
   ============================================= */
body.rtl .hero {
    text-align: center;
}

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

body.rtl .section-title::before {
    margin-left: 12px;
    margin-right: 0;
}

body.rtl .module-card {
    text-align: right;
}

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

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

body.rtl .links-grid {
    direction: rtl;
}

/* =============================================
   Language Switcher RTL
   ============================================= */
body.rtl .lang-switcher {
    flex-direction: row-reverse;
}

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

body.rtl .lang-btn .chevron {
    margin-left: 0;
    margin-right: 4px;
}

body.rtl .lang-dropdown {
    left: 0;
    right: auto;
}

body.rtl .lang-option {
    flex-direction: row-reverse;
    text-align: right;
}

/* =============================================
   Responsive RTL Overrides
   ============================================= */
@media (max-width: 1024px) {
    body.rtl .sidebar {
        transform: translateX(100%);
    }

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

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

    body.rtl .progress-bar {
        right: 0;
    }
}

/* =============================================
   Print RTL
   ============================================= */
@media print {
    body.rtl .main {
        margin-right: 0;
    }
}

/* =============================================
   Arabic Font Adjustments
   ============================================= */
body.rtl {
    font-family: 'Inter', 'Noto Sans Arabic', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Slightly larger line height for Arabic text readability */
body.rtl p,
body.rtl li,
body.rtl td {
    line-height: 1.8;
}

/* Adjust heading weights for Arabic */
body.rtl h1,
body.rtl h2,
body.rtl h3,
body.rtl h4 {
    font-weight: 600;
}
