/**
 * File: rtl-ltr.css
 * Version: 1.1.0
 * Location: /frontend/static/css/rtl-ltr.css
 * Purpose: Handle LTR layout for English while preserving existing Arabic RTL
 * Note: Application is already RTL by default (Arabic), this file adds LTR support
 */

/* ========== Base Direction Rules ========== */

/* Default is already RTL (Arabic), no changes needed */
[dir="rtl"] {
    /* Preserve existing RTL layout */
}

/* Override for LTR Languages (English) - THIS IS THE MAIN CHANGE */
[dir="ltr"] {
    direction: ltr !important;
}

/* ========== LTR Overrides for English ========== */

/* Main Layout - Flip for LTR */
[dir="ltr"] .main-container {
    direction: ltr;
}

[dir="ltr"] .container-fluid {
    direction: ltr;
}

/* Three Column Layout - Reverse for LTR */
[dir="ltr"] #main-container {
    flex-direction: row !important;
}

/* Left Column (Categories) - Move to actual left in LTR */
[dir="ltr"] #left-column {
    order: 1;
    border-right: 1px solid #dee2e6;
    border-left: none;
}

/* Middle Column */
[dir="ltr"] #middle-column {
    order: 2;
}

/* Right Column (Content) - Move to actual right in LTR */
[dir="ltr"] #right-column {
    order: 3;
    border-left: 1px solid #dee2e6;
    border-right: none;
}

/* Header Adjustments for LTR */
[dir="ltr"] .header {
    direction: ltr;
    text-align: left;
}

[dir="ltr"] .header-title {
    float: left;
    margin-right: auto;
    margin-left: 0;
}

[dir="ltr"] .header-controls {
    float: right;
    margin-left: auto;
    margin-right: 0;
}

/* Buttons and Controls for LTR */
[dir="ltr"] .btn-group {
    direction: ltr;
}

[dir="ltr"] button {
    text-align: left;
}

[dir="ltr"] .dropdown-menu {
    text-align: left;
    left: 0;
    right: auto;
}

/* Search Box for LTR */
[dir="ltr"] .search-container {
    direction: ltr;
}

[dir="ltr"] input[type="text"],
[dir="ltr"] input[type="search"] {
    direction: ltr;
    text-align: left;
    padding-left: 10px;
    padding-right: 35px;
}

[dir="ltr"] .search-icon {
    left: auto;
    right: 10px;
}

/* Tree View for LTR */
[dir="ltr"] .tree-item {
    padding-left: 20px;
    padding-right: 0;
    text-align: left;
}

[dir="ltr"] .tree-item .caret {
    float: left;
    margin-right: 5px;
    margin-left: 0;
}

[dir="ltr"] .tree-item input[type="checkbox"] {
    float: left;
    margin-right: 5px;
    margin-left: 0;
}

[dir="ltr"] .category-item {
    text-align: left;
    padding-left: 10px;
    padding-right: 0;
}

[dir="ltr"] .book-item {
    text-align: left;
    padding-left: 30px;
    padding-right: 0;
}

/* Statistics and Info for LTR */
[dir="ltr"] .stats-info {
    text-align: left;
}

[dir="ltr"] .selection-info {
    text-align: left;
}

/* Content Area for LTR */
[dir="ltr"] #content-body {
    direction: ltr;
    text-align: left;
}

[dir="ltr"] .welcome-view {
    text-align: left;
}

[dir="ltr"] .feature-cards {
    direction: ltr;
}

[dir="ltr"] .feature-card {
    text-align: left;
}

/* Book Reader for LTR */
[dir="ltr"] .book-content {
    direction: ltr;
    text-align: left;
}

[dir="ltr"] .reading-controls {
    direction: ltr;
}

[dir="ltr"] .nav-button.prev {
    float: left;
}

[dir="ltr"] .nav-button.next {
    float: right;
}

/* Progress Bar - Keep LTR even in RTL */
.progress-bar {
    direction: ltr !important; /* Progress always goes left to right */
}

/* Scrollbars for LTR */
[dir="ltr"] .scrollable {
    direction: ltr;
}

[dir="ltr"] ::-webkit-scrollbar {
    /* Scrollbar on right side for LTR */
}

/* Forms for LTR */
[dir="ltr"] .form-group {
    text-align: left;
}

[dir="ltr"] .form-label {
    text-align: left;
}

[dir="ltr"] .form-control {
    text-align: left;
}

/* Tables for LTR */
[dir="ltr"] table {
    direction: ltr;
}

[dir="ltr"] th,
[dir="ltr"] td {
    text-align: left;
}

/* Modals for LTR */
[dir="ltr"] .modal-header {
    direction: ltr;
    text-align: left;
}

[dir="ltr"] .modal-body {
    direction: ltr;
    text-align: left;
}

[dir="ltr"] .modal-footer {
    direction: ltr;
}

[dir="ltr"] .modal-header .close {
    float: right;
    margin-left: auto;
}

/* ========== Language-Specific Typography ========== */

/* Arabic (Default - Preserve existing) */
.lang-ar {
    /* Keep existing Arabic fonts */
}

/* English Specific */
.lang-en {
    font-family: 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.6;
}

.lang-en h1, 
.lang-en h2, 
.lang-en h3 {
    font-weight: 500;
}

/* Persian Specific */
.lang-fa {
    font-family: 'Vazir', 'IRANSans', 'Tahoma', sans-serif;
}

/* Urdu Specific */
.lang-ur {
    font-family: 'Noto Nastaliq Urdu', 'Jameel Noori Nastaleeq', serif;
    line-height: 2;
}

/* ========== Language Switcher Styles ========== */

.language-switcher {
    position: relative;
    display: inline-block;
    margin: 0 10px;
}

.language-select {
    padding: 5px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    cursor: pointer;
    font-size: 14px;
    min-width: 120px;
}

/* Keep RTL for Arabic in select */
[dir="rtl"] .language-select {
    direction: rtl;
    text-align: right;
}

/* LTR for English in select */
[dir="ltr"] .language-select {
    direction: ltr;
    text-align: left;
}

.language-select:hover {
    border-color: #007bff;
}

.language-select:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0,123,255,.25);
}

/* ========== Icons Direction Fix for LTR ========== */

/* Flip navigation arrows for LTR */
[dir="ltr"] .arrow-right::before {
    content: "→";
}

[dir="ltr"] .arrow-left::before {
    content: "←";
}

[dir="ltr"] .chevron-right {
    transform: rotate(0deg);
}

[dir="ltr"] .chevron-left {
    transform: rotate(180deg);
}

/* ========== Utility Classes for LTR ========== */

/* Text Alignment */
[dir="ltr"] .text-start {
    text-align: left !important;
}

[dir="ltr"] .text-end {
    text-align: right !important;
}

[dir="ltr"] .text-center {
    text-align: center !important;
}

/* Float */
[dir="ltr"] .float-start {
    float: left !important;
}

[dir="ltr"] .float-end {
    float: right !important;
}

/* Margins */
[dir="ltr"] .ms-auto {
    margin-left: auto !important;
}

[dir="ltr"] .me-auto {
    margin-right: auto !important;
}

/* Padding */
[dir="ltr"] .ps-0 {
    padding-left: 0 !important;
}

[dir="ltr"] .pe-0 {
    padding-right: 0 !important;
}

[dir="ltr"] .ps-1 {
    padding-left: 0.25rem !important;
}

[dir="ltr"] .pe-1 {
    padding-right: 0.25rem !important;
}

[dir="ltr"] .ps-2 {
    padding-left: 0.5rem !important;
}

[dir="ltr"] .pe-2 {
    padding-right: 0.5rem !important;
}

[dir="ltr"] .ps-3 {
    padding-left: 1rem !important;
}

[dir="ltr"] .pe-3 {
    padding-right: 1rem !important;
}

/* ========== Transitions ========== */

/* Smooth transition only when switching TO LTR */
[dir="ltr"] * {
    transition: direction 0.3s ease,
                text-align 0.3s ease,
                padding 0.3s ease,
                margin 0.3s ease;
}

/* ========== Media Queries for LTR ========== */

@media (max-width: 768px) {
    [dir="ltr"] .mobile-reverse {
        flex-direction: column;
    }
    
    [dir="ltr"] #left-column,
    [dir="ltr"] #middle-column,
    [dir="ltr"] #right-column {
        order: initial;
        width: 100%;
    }
}

/* ========== Print Styles ========== */

@media print {
    [dir="ltr"] {
        direction: ltr;
    }
    
    [dir="ltr"] * {
        text-align: left;
    }
}

/* ========== Important: Don't Break Existing Arabic ========== */

/* These ensure Arabic (RTL) layout remains unchanged */
[dir="rtl"],
html:not([dir="ltr"]) {
    /* Use existing styles - no overrides */
}

/* Only apply changes when explicitly set to LTR */
[dir="ltr"] {
    /* All LTR overrides go here */
}

/*EndFile*/