/* RTL/LTR Support */

/* ─── Direction-based Fonts ─── */
[dir="rtl"] body {
    font-family: var(--font-family-ar);
    direction: rtl;
}

[dir="ltr"] body {
    font-family: var(--font-family-en);
    direction: ltr;
}

/* ─── Form Text Alignment ─── */
[dir="rtl"] .form-group input,
[dir="rtl"] .form-group select,
[dir="rtl"] .form-group textarea {
    text-align: start;
}

[dir="ltr"] .form-group input,
[dir="ltr"] .form-group select,
[dir="ltr"] .form-group textarea {
    text-align: start;
}

/* ─── Alerts ─── */
[dir="rtl"] .alert {
    flex-direction: row-reverse;
}

/* ─── Hero ─── */
[dir="rtl"] .hero-actions {
    flex-direction: row-reverse;
}

/* ─── Form Row (forgot password link) ─── */
[dir="rtl"] .form-row {
    justify-content: flex-end;
}

[dir="ltr"] .form-row {
    justify-content: flex-start;
}

/* ─── Profile Info Rows ─── */
[dir="rtl"] .profile-info-row {
    flex-direction: row-reverse;
}

/* ─── Modal Footer ─── */
[dir="rtl"] .modal-footer {
    justify-content: flex-start;
}

[dir="ltr"] .modal-footer {
    justify-content: flex-end;
}

/* ─── Calendar Navigation ─── */
[dir="rtl"] .calendar-nav {
    flex-direction: row-reverse;
}

/* ─── Partner Active Card ─── */
[dir="rtl"] .partner-active-card {
    flex-direction: row-reverse;
    text-align: right;
}

[dir="ltr"] .partner-active-card {
    text-align: left;
}

/* ─── Partner Actions Row ─── */
[dir="rtl"] .partner-actions-row {
    flex-direction: row-reverse;
}

/* ─── Request Cards ─── */
[dir="rtl"] .request-card {
    flex-direction: row-reverse;
}

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

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

/* ─── Search Input Group ─── */
[dir="rtl"] .search-input-group {
    flex-direction: row-reverse;
}

/* ─── Recovery Actions ─── */
[dir="rtl"] .recovery-actions {
    flex-direction: row-reverse;
}

/* ─── Dashboard Actions ─── */
[dir="rtl"] .dashboard-actions {
    flex-direction: row-reverse;
}

/* ─── Recent Items ─── */
[dir="rtl"] .recent-item {
    flex-direction: row-reverse;
}

/* ─── Notification Items ─── */
[dir="rtl"] .notif-item {
    flex-direction: row-reverse;
}

/* ─── Streak Cards Grid ─── */
[dir="rtl"] .streak-cards {
    direction: rtl;
}

/* ─── Stats Grid ─── */
[dir="rtl"] .stats-grid {
    direction: rtl;
}

/* ─── Calendar Grid ─── */
[dir="rtl"] .calendar-grid {
    direction: rtl;
}

/* ─── Recovery Code Display ─── */
[dir="rtl"] .recovery-code-display {
    flex-direction: row-reverse;
}

/* ─── Checklist Habits ─── */
[dir="rtl"] .habit-check {
    flex-direction: row-reverse;
}

/* ─── Severity Options ─── */
[dir="rtl"] .severity-options label {
    flex-direction: row-reverse;
}

/* ─── Mood Options ─── */
[dir="rtl"] .mood-options,
[dir="rtl"] .need-options {
    flex-direction: row-reverse;
}

/* ─── Checkbox/Radio Labels (checkin options) ─── */
[dir="rtl"] .checkin-option-inner {
    flex-direction: row-reverse;
}

/* ─── Trigger Chips ─── */
[dir="rtl"] .trigger-chip span {
    flex-direction: row-reverse;
}

/* ─── Text Alignment Utilities ─── */
[dir="rtl"] .text-start { text-align: right; }
[dir="rtl"] .text-end { text-align: left; }
[dir="ltr"] .text-start { text-align: left; }
[dir="ltr"] .text-end { text-align: right; }

/* ─── Logical Margin Utilities ─── */
[dir="rtl"] .ms-auto { margin-right: auto; margin-left: 0; }
[dir="ltr"] .ms-auto { margin-left: auto; margin-right: 0; }
[dir="rtl"] .me-auto { margin-left: auto; margin-right: 0; }
[dir="ltr"] .me-auto { margin-right: auto; margin-left: 0; }

/* ─── RTL-specific: Flip arrows/chevrons visually ─── */
[dir="rtl"] .cal-empty + .cal-day::before {
    direction: rtl;
}

/* ─── Spinner direction-neutral ─── */
.spinner {
    display: inline-block;
    width: 1em;
    height: 1em;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Accessibility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* Print */
@media print {
    .alert, .btn, .auth-form, .modal {
        display: none;
    }
}
