/* RTL (Arabic) Support for Maritime System */

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

/* Sidebar RTL */
[dir="rtl"] .sidebar {
    left: auto;
    right: 0;
    box-shadow: inset -1px 0 0 rgba(0, 0, 0, .1);
}

[dir="rtl"] .sidebar .nav-link {
    text-align: right;
    padding-right: 1rem;
    padding-left: 2rem;
}

[dir="rtl"] .sidebar .nav-link i {
    margin-right: 0;
    margin-left: 0.75rem;
}

[dir="rtl"] main {
    margin-left: auto !important;
    margin-right: 280px !important;
    padding-right: var(--bs-gutter-x, 1.5rem);
    padding-left: var(--bs-gutter-x, 1.5rem);
}

/* Navbar RTL */
[dir="rtl"] .navbar-brand {
    box-shadow: inset -1px 0 0 rgba(0, 0, 0, .25);
    padding-right: 1.25rem;
    padding-left: 0;
}

[dir="rtl"] .navbar-nav {
    padding-right: 0;
    margin-right: auto;
    margin-left: 0;
}

/* Form Controls RTL */
[dir="rtl"] .form-control, [dir="rtl"] .form-select {
    text-align: right;
    padding-right: 0.75rem;
    padding-left: 2.25rem;
}

[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;
}

/* Table RTL */
[dir="rtl"] .table {
    text-align: right;
}

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

[dir="rtl"] .table-responsive {
    direction: rtl;
}

/* Button Groups RTL */
[dir="rtl"] .btn-group {
    direction: rtl;
}

[dir="rtl"] .btn-group > .btn:first-child:not(:last-child):not(.dropdown-toggle) {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    border-top-right-radius: 0.25rem;
    border-bottom-right-radius: 0.25rem;
}

[dir="rtl"] .btn-group > .btn:last-child:not(:first-child) {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-top-left-radius: 0.25rem;
    border-bottom-left-radius: 0.25rem;
}

[dir="rtl"] .btn-toolbar {
    justify-content: flex-end;
}

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

[dir="rtl"] .card .border-start {
    border-right: 0.25rem solid !important;
    border-left: none !important;
}

[dir="rtl"] .card .border-end {
    border-left: 0.25rem solid !important;
    border-right: none !important;
}

/* Navigation RTL */
[dir="rtl"] .nav-tabs .nav-link {
    margin-right: 0;
    margin-left: 2px;
}

[dir="rtl"] .nav-pills .nav-link {
    margin-right: 0;
    margin-left: 0.5rem;
}

/* Breadcrumb RTL */
.breadcrumb {
    flex-direction: row-reverse;
}

/* Alert RTL */
[dir="rtl"] .alert {
    text-align: right;
}

[dir="rtl"] .alert-dismissible .btn-close {
    left: 0;
    right: auto;
}

/* Modal RTL */
[dir="rtl"] .modal-header, [dir="rtl"] .modal-body, [dir="rtl"] .modal-footer {
    text-align: right;
}

[dir="rtl"] .modal-header .btn-close {
    margin: -0.5rem auto -0.5rem -0.5rem;
}

/* Pagination RTL */
.pagination {
    flex-direction: row-reverse;
}

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

[dir="rtl"] .dropdown-toggle::after {
    margin-right: 0.255em;
    margin-left: 0;
}

/* Typography RTL */
h1, h2, h3, h4, h5, h6 {
    text-align: right;
}

p, div, span {
    text-align: right;
}

/* List RTL */
ul, ol {
    text-align: right;
    padding-right: 1rem;
    padding-left: 0;
}

/* Input Group RTL */
.input-group {
    flex-direction: row-reverse;
}

/* Badge RTL */
.badge {
    text-align: center;
}

/* Custom RTL Classes */
.text-left-rtl {
    text-align: left !important;
}

.text-right-rtl {
    text-align: right !important;
}

.float-left-rtl {
    float: right !important;
}

.float-right-rtl {
    float: left !important;
}

.border-left-rtl {
    border-right: 1px solid #dee2e6 !important;
    border-left: 0 !important;
}

.border-right-rtl {
    border-left: 1px solid #dee2e6 !important;
    border-right: 0 !important;
}

.ml-auto-rtl {
    margin-right: auto !important;
    margin-left: 0 !important;
}

.mr-auto-rtl {
    margin-left: auto !important;
    margin-right: 0 !important;
}

/* Statistics Cards RTL */
[dir="rtl"] .row.no-gutters.align-items-center .col-auto {
    order: -1;
}

[dir="rtl"] .col.me-2 {
    margin-left: 0.5rem !important;
    margin-right: 0 !important;
}

/* Font Support for Arabic */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Arabic:wght@400;500;600;700&display=swap');

body[dir="rtl"] {
    font-family: 'Noto Sans Arabic', 'Segoe UI', Tahoma, Arial, sans-serif;
    line-height: 1.6;
}

/* PDF RTL Support */
.delivery-order-rtl {
    direction: rtl;
    text-align: right;
}

.delivery-order-rtl .info-label {
    text-align: right;
}

.delivery-order-rtl .signature-section {
    flex-direction: row-reverse;
}

/* Data Tables RTL */
.dataTables_wrapper {
    direction: rtl;
}

.dataTables_filter {
    text-align: left;
}

.dataTables_info {
    text-align: right;
}

/* Form Labels RTL */
.form-label {
    text-align: right;
    display: block;
}

/* Required Field Indicator RTL */
[dir="rtl"] .form-label.required::after {
    content: " *";
    color: #dc3545;
}

/* Calendar RTL (if using date pickers) */
.calendar-rtl {
    direction: rtl;
}

/* Number inputs should remain LTR */
[dir="rtl"] input[type="number"], 
[dir="rtl"] input[type="tel"], 
[dir="rtl"] input[type="date"],
[dir="rtl"] input[type="time"],
[dir="rtl"] .ltr-input {
    direction: ltr;
    text-align: left;
}

/* Responsive RTL */
@media (max-width: 768px) {
    .sidebar {
        right: -100%;
        left: auto;
    }
    
    .sidebar.show {
        right: 0;
    }
    
    main {
        margin-right: 0;
        margin-left: 0;
    }
}

/* Search and Filter RTL */
.search-container {
    text-align: right;
}

.search-container input {
    text-align: right;
}

/* Status Indicators RTL */
[dir="rtl"] .status-indicator {
    display: inline-block;
    margin-left: 0.5rem;
    margin-right: 0;
}

/* Bootstrap 5 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"] .ms-1 { margin-right: 0.25rem !important; margin-left: 0 !important; }
[dir="rtl"] .ms-2 { margin-right: 0.5rem !important; margin-left: 0 !important; }
[dir="rtl"] .ms-3 { margin-right: 1rem !important; margin-left: 0 !important; }
[dir="rtl"] .ms-4 { margin-right: 1.5rem !important; margin-left: 0 !important; }
[dir="rtl"] .ms-5 { margin-right: 3rem !important; margin-left: 0 !important; }

[dir="rtl"] .me-1 { margin-left: 0.25rem !important; margin-right: 0 !important; }
[dir="rtl"] .me-2 { margin-left: 0.5rem !important; margin-right: 0 !important; }
[dir="rtl"] .me-3 { margin-left: 1rem !important; margin-right: 0 !important; }
[dir="rtl"] .me-4 { margin-left: 1.5rem !important; margin-right: 0 !important; }
[dir="rtl"] .me-5 { margin-left: 3rem !important; margin-right: 0 !important; }

[dir="rtl"] .ps-1 { padding-right: 0.25rem !important; padding-left: 0 !important; }
[dir="rtl"] .ps-2 { padding-right: 0.5rem !important; padding-left: 0 !important; }
[dir="rtl"] .ps-3 { padding-right: 1rem !important; padding-left: 0 !important; }
[dir="rtl"] .ps-4 { padding-right: 1.5rem !important; padding-left: 0 !important; }
[dir="rtl"] .ps-5 { padding-right: 3rem !important; padding-left: 0 !important; }

[dir="rtl"] .pe-1 { padding-left: 0.25rem !important; padding-right: 0 !important; }
[dir="rtl"] .pe-2 { padding-left: 0.5rem !important; padding-right: 0 !important; }
[dir="rtl"] .pe-3 { padding-left: 1rem !important; padding-right: 0 !important; }
[dir="rtl"] .pe-4 { padding-left: 1.5rem !important; padding-right: 0 !important; }
[dir="rtl"] .pe-5 { padding-left: 3rem !important; padding-right: 0 !important; }

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

[dir="rtl"] .border-start { 
    border-right: 1px solid #dee2e6 !important; 
    border-left: 0 !important; 
}

[dir="rtl"] .border-end { 
    border-left: 1px solid #dee2e6 !important; 
    border-right: 0 !important; 
}

[dir="rtl"] .rounded-start { 
    border-top-right-radius: 0.25rem !important;
    border-bottom-right-radius: 0.25rem !important;
    border-top-left-radius: 0 !important;
    border-bottom-left-radius: 0 !important;
}

[dir="rtl"] .rounded-end { 
    border-top-left-radius: 0.25rem !important;
    border-bottom-left-radius: 0.25rem !important;
    border-top-right-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
}