 @import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;500;600;700&display=swap');

:root {
    --teacher-primary: #28a745;
    --teacher-secondary: #218838;
    --teacher-gradient: linear-gradient(135deg, #28a745 0%, #1e7e34 100%);
    --teacher-soft: rgba(40, 167, 69, 0.1);
}

* {
    direction: rtl !important;
    font-family: 'Cairo', sans-serif !important;
}

.fas, .far, .fab, .fa {
    font-family: 'Font Awesome 5 Free' !important;
    direction: ltr !important;
}

/* Global RTL Input Fixes */
input, select, textarea {
    text-align: right !important;
    direction: rtl !important;
}

::placeholder {
    text-align: right !important;
    direction: rtl !important;
}

.login-logo, .form-title, .form-subtitle, .form-group label, .form-group input {
    text-align: right !important;
    font-family: 'Cairo', sans-serif !important;
}

.input-group-append .input-group-text {
    border-radius: 12px 0 0 12px !important;
}

.input-group > .form-control:not(:first-child) {
    border-top-right-radius: 12px !important;
    border-bottom-right-radius: 12px !important;
}

.login-form-container {
    padding-right: 0 !important;
    margin-right: 0 !important;
}

.teacher-portal .bg-primary {
    background-color: var(--teacher-primary) !important;
}

.teacher-portal .text-primary {
    color: var(--teacher-primary) !important;
}

.teacher-portal .btn-primary {
    background-color: var(--teacher-primary) !important;
    border-color: var(--teacher-primary) !important;
}

.teacher-portal .btn-primary:hover {
    background-color: var(--teacher-secondary) !important;
}

.teacher-portal .nav-pills .nav-link.active, 
.teacher-portal .nav-pills .show > .nav-link {
    background-color: var(--teacher-primary) !important;
}

.teacher-portal .sidebar-dark-success .nav-sidebar > .nav-item > .nav-link.active {
    background-color: var(--teacher-primary) !important;
    box-shadow: 0 4px 10px rgba(40,167,69,0.3) !important;
}

.brand-link {
    border-bottom: 1px solid rgba(255,255,255,0.1) !important;
}

.mr-auto-navbav {
    margin-right: auto !important;
}

.navbar-expand .navbar-nav .nav-link {
    padding-right: 1rem;
    padding-left: 1rem;
}

[class*=icheck-]>input:first-child:checked+input[type=hidden]+label::after,
[class*=icheck-]>input:first-child:checked+label::after {
    right: 15px;
    left: auto;
}

.nav-sidebar .nav-link>.right,
.nav-sidebar .nav-link>p>.right {
    left: 1rem;
    right: auto;
}

.nav-sidebar .nav-link>.right:nth-child(2),
.nav-sidebar .nav-link>p>.right:nth-child(2) {
    left: 2.2rem;
    right: auto;
}

.small-box .icon>i {
    left: 15px;
    right: auto;
}

@media (min-width: 992px) {
    .teacher-portal .content-wrapper,
    .teacher-portal .main-footer,
    .teacher-portal .main-header,
    .admin-portal .content-wrapper,
    .admin-portal .main-footer,
    .admin-portal .main-header {
        margin-right: 250px !important;
        margin-left: 0 !important;
        transition: margin-right .3s ease-in-out;
    }

    .teacher-portal.sidebar-mini.sidebar-collapse .content-wrapper,
    .teacher-portal.sidebar-mini.sidebar-collapse .main-footer,
    .teacher-portal.sidebar-mini.sidebar-collapse .main-header,
    .admin-portal.sidebar-mini.sidebar-collapse .content-wrapper,
    .admin-portal.sidebar-mini.sidebar-collapse .main-footer,
    .admin-portal.sidebar-mini.sidebar-collapse .main-header {
        margin-right: 4.6rem !important;
        margin-left: 0 !important;
    }

    .teacher-portal .main-sidebar,
    .admin-portal .main-sidebar {
        right: 0 !important;
        left: auto !important;
    }
}

.teacher-portal .main-sidebar,
.admin-portal .main-sidebar {
    right: 0;
    left: auto;
}

@media (max-width: 991.98px) {
    .teacher-portal .main-sidebar,
    .admin-portal .main-sidebar {
        margin-right: -250px;
        transition: margin-right .3s ease-in-out, transform .3s ease-in-out;
    }

    .teacher-portal.sidebar-open .main-sidebar,
    .admin-portal.sidebar-open .main-sidebar {
        margin-right: 0;
    }
}

/* Force RTL on everything */
.form-control {
    text-align: right !important;
    direction: rtl !important;
}

label {
    width: 100%;
    text-align: right !important;
}

.card-title {
    float: right !important;
    text-align: right !important;
    width: auto;
}

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

::placeholder {
    text-align: right !important;
}

/* Unified Action Buttons (Edit / Delete) */
.edit-btn,
.delete-btn {
    border-radius: 50% !important;
    width: 32px !important;
    height: 32px !important;
    padding: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 14px !important;
    border-width: 1px !important;
    border-style: solid !important;
    background-color: transparent !important;
}

.edit-btn {
    color: #17a2b8 !important;
    /* Info */
    border-color: #17a2b8 !important;
}

.edit-btn:hover {
    color: #fff !important;
    background-color: #17a2b8 !important;
}

.delete-btn {
    color: #dc3545 !important;
    /* Danger */
    border-color: #dc3545 !important;
}

.delete-btn:hover {
    color: #fff !important;
    background-color: #dc3545 !important;
}

/* Unified Green Status Switches (Add/Edit & Tables) */
.teacher-portal .custom-control.custom-switch .custom-control-input:checked~.custom-control-label::before,
.teacher-portal .custom-switch-md .custom-control-input:checked~.custom-control-label::before,
.teacher-portal .custom-switch-lg .custom-control-input:checked~.custom-control-label::before,
.admin-portal .custom-control.custom-switch .custom-control-input:checked~.custom-control-label::before,
.admin-portal .custom-switch-md .custom-control-input:checked~.custom-control-label::before,
.admin-portal .custom-switch-lg .custom-control-input:checked~.custom-control-label::before {
    background-color: #28a745 !important;
    border-color: #28a745 !important;
}

/* Complete Custom Switch RTL Override */
.custom-control.custom-switch {
    padding-right: 0 !important;
    padding-left: 0 !important;
}

.custom-control.custom-switch .custom-control-label {
    position: relative;
    display: inline-block;
    cursor: pointer;
    padding-right: 3.5rem !important;
    padding-left: 0 !important;
    line-height: 1.5rem;
}

.custom-control.custom-switch .custom-control-label::before,
.custom-control.custom-switch .custom-control-label::after {
    content: "";
    position: absolute;
    border: none !important;
    box-shadow: none !important;
    left: auto;
}

/* Medium Switch */
.custom-switch-md .custom-control-label {
    min-height: 1.5rem;
    padding-right: 3.5rem !important;
}

.custom-switch-md .custom-control-label::before {
    height: 1.5rem;
    width: 3rem;
    border-radius: 1.5rem;
    right: 0;
    top: 0;
    background-color: #e9ecef;
    border: 1px solid #ced4da !important;
    transition: all 0.3s ease;
}

.custom-switch-md .custom-control-label::after {
    height: 1.25rem;
    width: 1.25rem;
    border-radius: 50%;
    top: 0.125rem;
    right: 0.125rem;
    background-color: #fff;
    transition: all 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3) !important;
}

.custom-switch-md .custom-control-input:checked~.custom-control-label::after {
    transform: translateX(-1.5rem);
    right: 0.125rem;
}

/* Large Switch */
.custom-switch-lg .custom-control-label {
    min-height: 1.75rem;
    padding-right: 4rem !important;
}

.custom-switch-lg .custom-control-label::before {
    height: 1.75rem;
    width: 3.5rem;
    border-radius: 1.75rem;
    right: 0;
    top: 0;
    background-color: #e9ecef;
    border: 1px solid #ced4da !important;
    transition: all 0.3s ease;
}

.custom-switch-lg .custom-control-label::after {
    height: 1.5rem;
    width: 1.5rem;
    border-radius: 50%;
    top: 0.125rem;
    right: 0.125rem;
    background-color: #fff;
    transition: all 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3) !important;
}

.custom-switch-lg .custom-control-input:checked~.custom-control-label::after {
    transform: translateX(-1.75rem);
    right: 0.125rem;
}

/* Select2 RTL & Cairo Support */
.select2-container--bootstrap4 .select2-selection--single {
    height: 48px !important; /* Premium height */
    padding: 8px 15px !important;
    border-radius: 25px !important; /* Pill shape */
    border: 1px solid #ced4da !important;
}

.select2-container .select2-selection--single .select2-selection__rendered {
    text-align: right !important;
    padding-right: 15px !important;
    line-height: 30px !important;
}

.select2-container--bootstrap4 .select2-selection--single .select2-selection__arrow {
    left: 15px !important;
    right: auto !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
}

/* Fix Input Group with Select2 for Unified Pill Look (RTL) */
.input-group {
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: stretch !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05) !important;
    border-radius: 25px !important;
}

/* The Icon Part (Prepend - on the RIGHT in RTL) */
.input-group-prepend .input-group-text {
    border-radius: 0 25px 25px 0 !important; /* Rounded only on the outer right */
    background-color: #fff !important; /* Match Select2 background */
    border: 1px solid #ced4da !important;
    border-left: 0 !important; /* Remove the inner border */
    height: 48px !important;
    padding: 0 15px !important;
    margin: 0 !important;
    z-index: 2;
}

/* The Select2 Container */
.input-group > .select2-container--bootstrap4 {
    flex: 1 1 auto !important;
    width: 1% !important;
    margin: 0 !important;
}

/* The Select2 Selection Box */
.input-group > .select2-container--bootstrap4 .select2-selection--single {
    height: 48px !important;
    padding: 8px 15px !important;
    border: 1px solid #ced4da !important;
    border-right: 0 !important; /* Remove individual right border to join with prepend */
    border-radius: 0 !important; /* Start as flat box */
    border-top-left-radius: 25px !important; /* Round the outer left */
    border-bottom-left-radius: 25px !important;
    box-shadow: none !important;
    margin: 0 !important;
}

/* Clean up hover/focus states to prevent separate borders popping up */
.input-group > .select2-container--bootstrap4 .select2-selection--single:focus,
.input-group > .select2-container--bootstrap4 .select2-selection--single:active {
    outline: none !important;
    border-color: #ced4da !important;
}

/* Search results refinements */
.select2-search__field {
    text-align: right !important;
    font-family: 'Cairo', sans-serif !important;
    border-radius: 8px !important;
}

.select2-results__option {
    text-align: right !important;
    font-family: 'Cairo', sans-serif !important;
    padding: 10px 15px !important;
}

.select2-container {
    width: 100% !important;
}

.teacher-portal .select2-container--bootstrap4 .select2-results__option--highlighted[aria-selected] {
    background-color: var(--teacher-primary) !important;
}

/* ===== Global RTL Modal Header Fix ===== */
/* Ensures title is on the right, close (X) button is on the left */
.modal-header {
    display: flex !important;
    flex-direction: row-reverse !important;
    align-items: center !important;
}

.modal-header .close {
    margin: 0 !important;
    padding: 0 !important;
    order: -1;
}

.modal-header .modal-title {
    margin: 0 !important;
    text-align: right !important;
}