/**
 * RTL (Right-to-Left) Styles for Arabic Language
 * This file contains all RTL-specific overrides
 */

/* RTL Body Styles */
body.rtl {
    direction: rtl;
    text-align: right;
}

/* Don't apply RTL to everything - be specific */
body.rtl .main-container {
    direction: rtl;
}

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

body.rtl .side-nav.collapsed {
    transform: translateX(100%);
}

/* Content Wrapper RTL */
body.rtl .content-wrapper {
    direction: rtl;
}

/* Main Content RTL */
body.rtl .main-content {
    margin-left: 0;
    margin-right: 0;
    direction: rtl;
}

body.rtl .section-content {
    direction: rtl;
    text-align: right;
}

/* Mobile RTL */
@media (max-width: 768px) {
    body.rtl .side-nav {
        right: -280px;
        left: auto;
    }
    
    body.rtl .side-nav.mobile-open {
        right: 0;
        left: auto;
    }
}

/* Navigation Items RTL */
body.rtl .nav-item {
    text-align: right;
}

body.rtl .nav-item i {
    margin-right: 0;
    margin-left: 1rem;
}

/* Buttons and Icons RTL */
body.rtl .btn i,
body.rtl .badge i {
    margin-right: 0;
    margin-left: 0.5rem;
}

body.rtl .btn-icon {
    margin-left: 0;
    margin-right: 0.5rem;
}

/* Cards RTL */
body.rtl .card-header-modern {
    text-align: right;
    direction: rtl;
}

body.rtl .page-header {
    text-align: right;
    direction: rtl;
}

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

body.rtl .page-subtitle {
    text-align: right;
}

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

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

/* Forms RTL */
body.rtl .form-label {
    text-align: right;
}

body.rtl .form-control,
body.rtl .form-select,
body.rtl input,
body.rtl textarea,
body.rtl select {
    text-align: right;
    direction: rtl;
}

body.rtl .input-group > :not(:first-child) {
    margin-left: 0;
    margin-right: -1px;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    border-top-right-radius: var(--border-radius);
    border-bottom-right-radius: var(--border-radius);
}

body.rtl .input-group > :not(:last-child) {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-top-left-radius: var(--border-radius);
    border-bottom-left-radius: var(--border-radius);
}

/* Tables RTL */
body.rtl table {
    text-align: right;
}

body.rtl th,
body.rtl td {
    text-align: right;
}

/* Dropdowns RTL */
body.rtl .dropdown-menu {
    right: 0;
    left: auto;
    text-align: right;
}

body.rtl .dropdown-item {
    text-align: right;
}

/* Modals RTL */
body.rtl .modal-header,
body.rtl .modal-body,
body.rtl .modal-footer {
    text-align: right;
}

body.rtl .modal-header .btn-close {
    margin-left: 0;
    margin-right: auto;
}

/* Alerts RTL */
body.rtl .alert {
    text-align: right;
}

body.rtl .alert i {
    margin-right: 0;
    margin-left: 0.5rem;
}

/* Badges RTL */
body.rtl .badge {
    margin-left: 0;
    margin-right: 0.5rem;
}

/* Lists RTL */
body.rtl ul,
body.rtl ol {
    padding-right: 1.5rem;
    padding-left: 0;
}

body.rtl .list-group {
    padding-right: 0;
}

/* Breadcrumbs RTL */
body.rtl .breadcrumb-item + .breadcrumb-item::before {
    float: right;
    padding-right: 0;
    padding-left: 0.5rem;
    content: "/";
}

/* Pagination RTL */
body.rtl .pagination {
    direction: rtl;
}

/* Progress Bars RTL */
body.rtl .progress-bar {
    right: 0;
    left: auto;
}

/* Tooltips RTL */
body.rtl .tooltip {
    text-align: right;
}

/* Popovers RTL */
body.rtl .popover {
    text-align: right;
}

/* Flex Utilities RTL */
body.rtl .d-flex {
    direction: rtl;
}

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

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

/* Text Alignment RTL */
body.rtl .text-left {
    text-align: right !important;
}

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

/* Margin and Padding RTL */
body.rtl .mr-1, body.rtl .mx-1 { margin-right: 0 !important; margin-left: 0.25rem !important; }
body.rtl .mr-2, body.rtl .mx-2 { margin-right: 0 !important; margin-left: 0.5rem !important; }
body.rtl .mr-3, body.rtl .mx-3 { margin-right: 0 !important; margin-left: 1rem !important; }
body.rtl .mr-4, body.rtl .mx-4 { margin-right: 0 !important; margin-left: 1.5rem !important; }
body.rtl .mr-5, body.rtl .mx-5 { margin-right: 0 !important; margin-left: 3rem !important; }

body.rtl .ml-1, body.rtl .mx-1 { margin-left: 0 !important; margin-right: 0.25rem !important; }
body.rtl .ml-2, body.rtl .mx-2 { margin-left: 0 !important; margin-right: 0.5rem !important; }
body.rtl .ml-3, body.rtl .mx-3 { margin-left: 0 !important; margin-right: 1rem !important; }
body.rtl .ml-4, body.rtl .mx-4 { margin-left: 0 !important; margin-right: 1.5rem !important; }
body.rtl .ml-5, body.rtl .mx-5 { margin-left: 0 !important; margin-right: 3rem !important; }

body.rtl .pr-1, body.rtl .px-1 { padding-right: 0 !important; padding-left: 0.25rem !important; }
body.rtl .pr-2, body.rtl .px-2 { padding-right: 0 !important; padding-left: 0.5rem !important; }
body.rtl .pr-3, body.rtl .px-3 { padding-right: 0 !important; padding-left: 1rem !important; }
body.rtl .pr-4, body.rtl .px-4 { padding-right: 0 !important; padding-left: 1.5rem !important; }
body.rtl .pr-5, body.rtl .px-5 { padding-right: 0 !important; padding-left: 3rem !important; }

body.rtl .pl-1, body.rtl .px-1 { padding-left: 0 !important; padding-right: 0.25rem !important; }
body.rtl .pl-2, body.rtl .px-2 { padding-left: 0 !important; padding-right: 0.5rem !important; }
body.rtl .pl-3, body.rtl .px-3 { padding-left: 0 !important; padding-right: 1rem !important; }
body.rtl .pl-4, body.rtl .px-4 { padding-left: 0 !important; padding-right: 1.5rem !important; }
body.rtl .pl-5, body.rtl .px-5 { padding-left: 0 !important; padding-right: 3rem !important; }

/* Border Radius RTL */
body.rtl .rounded-left {
    border-top-left-radius: 0 !important;
    border-bottom-left-radius: 0 !important;
    border-top-right-radius: var(--border-radius) !important;
    border-bottom-right-radius: var(--border-radius) !important;
}

body.rtl .rounded-right {
    border-top-right-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
    border-top-left-radius: var(--border-radius) !important;
    border-bottom-left-radius: var(--border-radius) !important;
}

/* Custom Components RTL */
body.rtl .task-card {
    text-align: right;
}

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

body.rtl .notification-item {
    text-align: right;
}

body.rtl .timeline-item::before {
    right: 0;
    left: auto;
}

body.rtl .timeline-item {
    padding-right: 2rem;
    padding-left: 0;
}

/* Beautiful Language Toggle Switch */
.language-toggle-container {
    position: relative;
}

.language-toggle-switch {
    position: relative;
    width: 140px;
    height: 50px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 25px;
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 4px;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.language-toggle-switch .toggle-option {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    z-index: 2;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    cursor: pointer;
    padding: 0.5rem;
}

.language-toggle-switch .toggle-option.active {
    color: white;
}

.language-toggle-switch .toggle-option i {
    font-size: 1rem;
}

.language-toggle-switch .toggle-slider {
    position: absolute;
    width: 50%;
    height: calc(100% - 8px);
    background: white;
    border-radius: 21px;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    left: 4px;
    top: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.language-toggle-switch.ar .toggle-slider {
    transform: translateX(100%);
}

/* RTL Toggle Switch */
body.rtl .language-toggle-switch .toggle-slider {
    right: 4px;
    left: auto;
}

body.rtl .language-toggle-switch.ar .toggle-slider {
    transform: translateX(-100%);
}

/* Old Language Switcher - Keep for compatibility */
.language-switcher {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--bg-card);
    border-radius: 12px;
    margin-bottom: 1rem;
}

.language-switcher .lang-option {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: transparent;
    color: var(--text-light);
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.language-switcher .lang-option:hover {
    border-color: var(--accent);
    background: rgba(102, 126, 234, 0.1);
}

.language-switcher .lang-option.active {
    border-color: var(--accent);
    background: var(--accent);
    color: white;
}

.language-switcher .lang-option i {
    font-size: 1.25rem;
}

/* Font Adjustments for Arabic */
body.rtl {
    font-family: 'Cairo', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body.rtl h1, body.rtl h2, body.rtl h3, body.rtl h4, body.rtl h5, body.rtl h6 {
    font-family: 'Cairo', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-weight: 700;
}

/* Adjustments for specific components */
body.rtl .adjustment-card {
    text-align: right;
}

body.rtl .payroll-section {
    direction: rtl;
}

body.rtl .chart-container {
    direction: ltr; /* Keep charts LTR for proper rendering */
}

/* Top Navigation RTL */
body.rtl .top-nav {
    direction: rtl;
}

body.rtl .top-nav-flex-container {
    direction: rtl;
}

body.rtl .navbar {
    direction: rtl;
}

body.rtl .navbar-brand {
    margin-right: 0;
    margin-left: 1rem;
}

body.rtl .btn-add-task {
    margin-right: auto;
    margin-left: 0;
}

body.rtl .btn-logout {
    margin-left: 0;
    margin-right: 1rem;
}

/* Search Box RTL */
body.rtl .search-box {
    direction: rtl;
}

body.rtl .search-box i {
    right: auto;
    left: 1rem;
}

body.rtl .search-box input {
    padding-right: 1rem;
    padding-left: 3rem;
}

/* Notification Badge RTL */
body.rtl .notification-badge {
    right: auto;
    right: 0px;
}



/* Avatar RTL */
body.rtl .avatar {
    margin-right: 0;
    margin-left: 0.75rem;
}

/* Stats Cards RTL */
body.rtl .stat-icon {
    margin-right: 0;
    margin-left: 1rem;
}

/* Calendar RTL */
body.rtl .calendar {
    direction: rtl;
}

/* Select2 RTL (if using) */
body.rtl .select2-container {
    direction: rtl;
}

/* DataTables RTL (if using) */
body.rtl .dataTables_wrapper {
    direction: rtl;
}

/* Floating Action Button RTL */
body.rtl .fab {
    right: auto;
    left: 2rem;
}

/* Fingerprint Floating Button RTL */
body.rtl .attendance-floating-btn {
    right: auto;
    left: 30px;
}

@media (max-width: 768px) {
    body.rtl .attendance-floating-btn {
        right: auto;
        left: 20px;
    }
}

/* Mobile Logout Button RTL */
body.rtl .mobile-logout {
    margin-top: 20px;
    margin-left: 20px !important;
    margin-right: 0 !important;
    direction: rtl;
    text-align: right;
}

body.rtl .mobile-logout i {
    margin-left: 0.5rem;
    margin-right: 0;
}

/* Mobile Add Task Button RTL */
body.rtl .mobile-add-task {
    direction: rtl;
    text-align: right;
}

body.rtl .mobile-add-task i {
    margin-left: 0.5rem;
    margin-right: 0;
}

/* Scrollbar RTL */
body.rtl ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

/* Animation Adjustments for RTL */
@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideInLeft {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

body.rtl .slide-in-right {
    animation: slideInLeft 0.3s ease-out;
}

body.rtl .slide-in-left {
    animation: slideInRight 0.3s ease-out;
}
