/* =========================
   ✅ RTL Full Fix Styles
   ========================= */

html[dir="rtl"] body {
    direction: rtl !important;
    text-align: right !important;
}

/* =========================
   ✅ Aside RTL
   ========================= */
html[dir="rtl"] .aside {
    right: 0 !important;
    left: auto !important;
}

/* =========================
   ✅ Wrapper RTL
   ========================= */
html[dir="rtl"] .wrapper {
    padding-right: var(--kt-aside-width) !important;
    padding-left: 0 !important;
    margin-right: 0 !important;
    margin-left: 0 !important;
    direction: rtl !important;
}

/* =========================
   ✅ Content RTL/LTR Support
   ========================= */
.content-rtl {
    direction: rtl !important;
    text-align: right !important;
}

.content-ltr {
    direction: ltr !important;
    text-align: left !important;
}

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

/* =========================
   ✅ Form Controls RTL
   ========================= */
html[dir="rtl"] .form-control {
    text-align: right;
}

html[dir="rtl"] .form-group label {
    text-align: right;
    display: block;
}

html[dir="rtl"] .invalid-feedback {
    text-align: right;
}

/* =========================
   ✅ Select2 RTL
   ========================= */
html[dir="rtl"] .select2-container--default .select2-selection--single {
    text-align: right;
}

html[dir="rtl"] .select2-container--default .select2-selection--single .select2-selection__arrow {
    left: 1px;
    right: auto;
}

/* =========================
   ✅ Dropify RTL
   ========================= */
html[dir="rtl"] .dropify-wrapper {
    direction: rtl;
}

html[dir="rtl"] .dropify-message p {
    text-align: center;
}

/* =========================
   ✅ Buttons & Alerts RTL
   ========================= */
html[dir="rtl"] .alert {
    text-align: right;
}

html[dir="rtl"] .btn-group > .btn {
    float: right;
}

/* =========================
   ✅ Grid RTL
   ========================= */
html[dir="rtl"] .row {
    flex-direction: row-reverse;
}

html[dir="rtl"] .col-form-label {
    text-align: right;
}

/* =========================
   ✅ Spacing RTL
   ========================= */
html[dir="rtl"] .me-3 {
    margin-left: 1rem !important;
    margin-right: 0 !important;
}

html[dir="rtl"] .me-4 {
    margin-left: 1.5rem !important;
    margin-right: 0 !important;
}

html[dir="rtl"] .ms-1 {
    margin-right: 0.25rem !important;
    margin-left: 0 !important;
}

html[dir="rtl"] .ms-3 {
    margin-right: 1rem !important;
    margin-left: 0 !important;
}

/* =========================
   ✅ Input Group RTL
   ========================= */
html[dir="rtl"] .input-group > .form-control {
    border-radius: 0 0.475rem 0.475rem 0;
}

html[dir="rtl"] .input-group > .input-group-text {
    border-radius: 0.475rem 0 0 0.475rem;
}

/* =========================
   ✅ Modal RTL
   ========================= */
html[dir="rtl"] .modal-header .btn-close {
    margin: -0.5rem auto -0.5rem -0.5rem;
}

html[dir="rtl"] .modal-footer {
    justify-content: flex-start;
}

/* =========================
   ✅ Icons RTL
   ========================= */
html[dir="rtl"] .svg-icon {
    transform: scaleX(-1);
}

/* =========================
   ✅ Custom Form Controls
   ========================= */
html[dir="rtl"] .form-check {
    padding-left: 0;
    padding-right: 1.75rem;
}

html[dir="rtl"] .form-check .form-check-input {
    float: right;
    margin-left: 0;
    margin-right: -1.75rem;
}

/* =========================
   ✅ Header Fix (LTR + RTL)
   ========================= */

:root {
    --kt-aside-width: 265px;
}

/* Large screens */
@media (min-width: 992px) {
    .aside-enabled.aside-fixed.header-fixed .header {
        position: fixed;
        top: 0;
        left: var(--kt-aside-width);
        right: 0;
        width: calc(100% - var(--kt-aside-width));
        height: var(--kt-header-height, 60px);
        transition: left 0.3s ease, right 0.3s ease;
        z-index: 1050;
    }

    html[dir="rtl"] .aside-enabled.aside-fixed.header-fixed .header {
        left: 0 !important;
        right: var(--kt-aside-width) !important;
        width: calc(100% - var(--kt-aside-width)) !important;
        transition: right 0.3s ease, left 0.3s ease;
    }

    .aside {
        z-index: 1040;
    }
}

/* =========================
   ✅ Responsive Fixes
   ========================= */
@media (max-width: 991.98px) {
    html[dir="rtl"] .wrapper {
        padding-right: 0 !important;
    }

    html[dir="rtl"] .aside {
        right: -295px !important;
        left: auto !important;
        transition: right 0.3s ease;
    }

    html[dir="rtl"] .aside.open {
        right: 0 !important;
        left: auto !important;
    }

    .aside-enabled.aside-fixed.header-fixed .header,
    html[dir="rtl"] .aside-enabled.aside-fixed.header-fixed .header {
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        position: relative;
    }
}
