/* RTL (Right-to-Left) Support for Arabic Language */

/* Global RTL styles - applied when html[dir="rtl"] */
html[dir="rtl"] {
    direction: rtl;
    text-align: right;
}

/* Typography for Arabic - Use IBM Plex Sans Arabic */
html[dir="rtl"] body {
    font-family: 'IBM Plex Sans Arabic', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Flip flexbox row directions */
html[dir="rtl"] .flex-row,
html[dir="rtl"] .d-flex {
    flex-direction: row-reverse;
}

/* Navigation adjustments */
html[dir="rtl"] .navbar,
html[dir="rtl"] .nav-menu,
html[dir="rtl"] .sidebar {
    text-align: right;
}

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

html[dir="rtl"] .nav-links {
    flex-direction: row-reverse;
}

/* Form elements */
html[dir="rtl"] input,
html[dir="rtl"] textarea,
html[dir="rtl"] select {
    text-align: right;
    direction: rtl;
}

html[dir="rtl"] input[type="email"],
html[dir="rtl"] input[type="url"],
html[dir="rtl"] input[type="tel"],
html[dir="rtl"] input[type="number"] {
    direction: ltr;
    text-align: left;
}

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

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

/* Buttons */
html[dir="rtl"] .btn-group {
    flex-direction: row-reverse;
}

html[dir="rtl"] button .icon,
html[dir="rtl"] .btn .icon {
    margin-left: 8px;
    margin-right: 0;
}

/* Tables */
html[dir="rtl"] table {
    text-align: right;
}

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

html[dir="rtl"] th:first-child,
html[dir="rtl"] td:first-child {
    text-align: right;
}

/* Cards and containers */
html[dir="rtl"] .card-header,
html[dir="rtl"] .card-body,
html[dir="rtl"] .card-footer {
    text-align: right;
}

/* Lists */
html[dir="rtl"] ul,
html[dir="rtl"] ol {
    padding-left: 0;
    padding-right: 40px;
}

html[dir="rtl"] li {
    text-align: right;
}

/* Margins and paddings flip */
html[dir="rtl"] .ml-auto {
    margin-left: 0 !important;
    margin-right: auto !important;
}

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

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

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

/* Icons that need flipping */
html[dir="rtl"] .icon-arrow-left {
    transform: scaleX(-1);
}

html[dir="rtl"] .icon-arrow-right {
    transform: scaleX(-1);
}

html[dir="rtl"] .icon-chevron-left {
    transform: scaleX(-1);
}

html[dir="rtl"] .icon-chevron-right {
    transform: scaleX(-1);
}

/* Chat interface */
html[dir="rtl"] .chat-container {
    text-align: right;
}

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

html[dir="rtl"] .chat-message.user {
    margin-left: 0;
    margin-right: auto;
}

html[dir="rtl"] .chat-message.ai {
    margin-right: 0;
    margin-left: auto;
}

html[dir="rtl"] .message-input-container {
    flex-direction: row-reverse;
}

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

/* Dashboard specific */
html[dir="rtl"] .dashboard-header {
    flex-direction: row-reverse;
}

html[dir="rtl"] .stats-grid {
    direction: rtl;
}

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

html[dir="rtl"] .stat-icon {
    margin-left: 15px;
    margin-right: 0;
}

/* Admin panel */
html[dir="rtl"] .admin-sidebar {
    right: 0;
    left: auto;
    border-left: 1px solid #e2e8f0;
    border-right: none;
}

html[dir="rtl"] .admin-content {
    margin-left: 0;
    margin-right: 250px;
}

html[dir="rtl"] .admin-nav-item {
    text-align: right;
}

html[dir="rtl"] .admin-nav-item .icon {
    margin-left: 10px;
    margin-right: 0;
}

/* Candidate cards */
html[dir="rtl"] .candidate-card {
    text-align: right;
}

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

html[dir="rtl"] .candidate-actions {
    flex-direction: row-reverse;
}

/* Job listings */
html[dir="rtl"] .job-card {
    text-align: right;
}

html[dir="rtl"] .job-header {
    flex-direction: row-reverse;
}

html[dir="rtl"] .job-meta {
    flex-direction: row-reverse;
}

/* Insights panel */
html[dir="rtl"] .insight-card {
    text-align: right;
}

html[dir="rtl"] .insight-header {
    flex-direction: row-reverse;
}

html[dir="rtl"] .insight-icon {
    margin-left: 10px;
    margin-right: 0;
}

/* Analytics dashboard */
html[dir="rtl"] .analytics-container {
    text-align: right;
}

html[dir="rtl"] .filter-bar {
    flex-direction: row-reverse;
}

html[dir="rtl"] .chart-container {
    direction: ltr;
}

html[dir="rtl"] .kpi-grid {
    direction: rtl;
}

/* Modal dialogs */
html[dir="rtl"] .modal-header {
    flex-direction: row-reverse;
}

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

html[dir="rtl"] .modal-footer {
    flex-direction: row-reverse;
}

html[dir="rtl"] .modal-close {
    left: 15px;
    right: auto;
}

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

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

/* Badges and tags */
html[dir="rtl"] .badge-container {
    flex-direction: row-reverse;
}

html[dir="rtl"] .tag {
    margin-left: 0;
    margin-right: 8px;
}

/* Evaluation scores */
html[dir="rtl"] .score-bar {
    transform: scaleX(-1);
}

html[dir="rtl"] .competency-row {
    flex-direction: row-reverse;
}

/* Pagination */
html[dir="rtl"] .pagination {
    flex-direction: row-reverse;
}

/* Breadcrumbs */
html[dir="rtl"] .breadcrumb {
    flex-direction: row-reverse;
}

html[dir="rtl"] .breadcrumb-separator {
    transform: scaleX(-1);
}

/* Timeline/steps */
html[dir="rtl"] .timeline {
    border-left: none;
    border-right: 2px solid #e2e8f0;
    padding-left: 0;
    padding-right: 20px;
}

html[dir="rtl"] .timeline-item::before {
    left: auto;
    right: -26px;
}

/* Alerts and notifications */
html[dir="rtl"] .alert {
    text-align: right;
}

html[dir="rtl"] .alert-icon {
    margin-left: 10px;
    margin-right: 0;
}

/* Progress indicators */
html[dir="rtl"] .progress-bar {
    transform: scaleX(-1);
}

/* Interview interface specific */
html[dir="rtl"] .interview-container {
    text-align: right;
}

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

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

/* Header navigation */
html[dir="rtl"] .header-nav {
    flex-direction: row-reverse;
}

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

/* Footer */
html[dir="rtl"] footer {
    text-align: right;
}

html[dir="rtl"] .footer-links {
    flex-direction: row-reverse;
}

/* Language Switcher */
.language-switcher {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm, 8px);
    padding: 6px 12px;
    background: var(--color-border-light, #F3F4F6);
    border-radius: var(--radius-md, 8px);
    font-size: var(--text-sm, 14px);
}

.language-switcher a {
    text-decoration: none;
    color: var(--color-text-secondary, #4B5563);
    padding: 4px 8px;
    border-radius: var(--radius-sm, 4px);
    transition: all 0.2s;
}

.language-switcher a:hover {
    background: var(--color-border, #E5E7EB);
    color: var(--color-text-primary, #1C2440);
}

.language-switcher a.active {
    background: var(--color-primary, #0F6E8C);
    color: white;
}

/* Fix for specific interview pages */
html[dir="rtl"] .interview-header {
    flex-direction: row-reverse;
}

html[dir="rtl"] .interview-progress {
    direction: ltr;
}

/* Offer letter RTL */
html[dir="rtl"] .offer-container {
    text-align: right;
}

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

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

/* Offer management templates RTL */
html[dir="rtl"] .offer-meta > div > div {
    flex-direction: row-reverse;
}

html[dir="rtl"] .offer-actions {
    flex-direction: row-reverse;
}

html[dir="rtl"] .calculated-row {
    flex-direction: row-reverse;
}

html[dir="rtl"] .field-row > div {
    direction: rtl;
}

html[dir="rtl"] .form-row {
    direction: rtl;
}

html[dir="rtl"] .view-container h2,
html[dir="rtl"] .view-container h3,
html[dir="rtl"] .view-container h4 {
    text-align: right;
}

html[dir="rtl"] .view-container .subtitle {
    text-align: right;
}

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

html[dir="rtl"] .form-actions {
    flex-direction: row-reverse;
}

html[dir="rtl"] #rejectModal > div {
    text-align: right;
}

html[dir="rtl"] #rejectModal .form-group {
    text-align: right;
}

html[dir="rtl"] #rejectModal div:last-child {
    flex-direction: row-reverse;
}

/* Admin template specific RTL styles */
html[dir="rtl"] .header {
    flex-direction: row-reverse;
}

html[dir="rtl"] .header-left {
    flex-direction: row-reverse;
}

html[dir="rtl"] .header-right {
    flex-direction: row-reverse;
    gap: 12px;
}

html[dir="rtl"] .search-form {
    flex-direction: row-reverse;
}

html[dir="rtl"] .btn-icon {
    transform: scaleX(-1);
}

html[dir="rtl"] .users-container h2,
html[dir="rtl"] .users-container h3 {
    text-align: right;
}

html[dir="rtl"] .add-user-form .form-row {
    flex-direction: row-reverse;
}

html[dir="rtl"] .screening-section h3 {
    text-align: right;
}

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

/* Print styles for RTL */
@media print {
    html[dir="rtl"] {
        direction: rtl;
    }
    
    html[dir="rtl"] body {
        text-align: right;
    }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    html[dir="rtl"] .admin-sidebar {
        position: fixed;
        right: -250px;
        left: auto;
    }
    
    html[dir="rtl"] .admin-sidebar.open {
        right: 0;
    }
    
    html[dir="rtl"] .admin-content {
        margin-right: 0;
    }
}
