/* rtl-fixes.css */
/* RTL/LTR Support Fixes: This file contains specific overrides and adjustments
   to ensure consistent behavior and appearance in both RTL and LTR contexts */

/* Base Typography & Font */
body {
    font-family: 'Tajawal', -apple-system, BlinkMacSystemFont,
        'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell,
        'Open Sans', 'Helvetica Neue', sans-serif;
    letter-spacing: normal;
    line-height: 1.6;
}

/* Force identical color variables by language attribute */
html[lang="ar"],
html[lang="en"],
html[lang="de"] {
    --color-primary: #1d3557;
    --color-secondary: #457b9d;
    --color-accent: #e63946;
    --color-light: #f1faee;
    --color-success: #2a9d8f;
    --color-warning: #e9c46a;
    --color-danger: #e63946;
    --color-info: #457b9d;
    --color-dark: #1d3557;
    --body-bg: #f8f9fa;
    --card-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.05);
    --animation-duration: 0.3s;
    --border-radius: 0.5rem;
    --header-height: 60px;
    --sidebar-width: 280px;
}

/* Directional Enforcements */
html[dir="rtl"] body,
.rtl-active body {
    direction: rtl;
    text-align: right;
}

html[dir="ltr"] body {
    direction: ltr;
    text-align: left;
}

/* Navbar color refresh by language */
html[data-lang="ar"] .navbar,
html[data-lang="en"] .navbar,
html[data-lang="de"] .navbar {
    background-color: var(--color-primary) !important;
}

/* Input type overrides: always LTR */
input[type="email"],
input[type="url"],
input[type="tel"],
input[type="number"],
input[type="password"] {
    direction: ltr;
    text-align: left;
}

/* Bootstrap margin swaps for RTL & LTR */
:root {
    --bs-border-radius: var(--border-radius);
}

html[dir="rtl"] {
    /* Swap ms- and me- classes */
    --bs-me: margin-left;
    --bs-ms: margin-right;
}

html[dir="ltr"] {
    --bs-me: margin-right;
    --bs-ms: margin-left;
}

/* Apply swaps */
.me-1 {
    var(--bs-me): .25rem !important;
    var(--bs-ms): 0 !important;
}

.me-2 {
    var(--bs-me): .5rem !important;
    var(--bs-ms): 0 !important;
}

.me-3 {
    var(--bs-me): 1rem !important;
    var(--bs-ms): 0 !important;
}

.me-4 {
    var(--bs-me): 1.5rem !important;
    var(--bs-ms): 0 !important;
}

.ms-1 {
    var(--bs-ms): .25rem !important;
    var(--bs-me): 0 !important;
}

.ms-2 {
    var(--bs-ms): .5rem !important;
    var(--bs-me): 0 !important;
}

.ms-3 {
    var(--bs-ms): 1rem !important;
    var(--bs-me): 0 !important;
}

.ms-4 {
    var(--bs-ms): 1.5rem !important;
    var(--bs-me): 0 !important;
}

/* Badge positioning */
html[dir="rtl"] .badge {
    margin-right: .25rem;
    margin-left: 0;
}

html[dir="ltr"] .badge {
    margin-left: .25rem;
    margin-right: 0;
}

/* Input group radius adjustments */
html[dir="rtl"] .input-group>*:not(:first-child) {
    margin-right: -1px;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-top-left-radius: var(--bs-border-radius);
    border-bottom-left-radius: var(--bs-border-radius);
}

html[dir="rtl"] .input-group>*:not(:last-child) {
    margin-left: -1px;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    border-top-right-radius: var(--bs-border-radius);
    border-bottom-right-radius: var(--bs-border-radius);
}

/* Button group fixes */
.btn-group .btn {
    padding: .5rem .6rem;
    min-width: 38px;
    text-align: center;
    font-weight: 400;
    font-size: 14px;
}

.btn-group .btn i {
    font-size: 16px;
}

/* Border radius first/last adjustments */
.btn-group .btn:first-child {
    border-top-right-radius: .25rem;
    border-bottom-right-radius: .25rem;
}

.btn-group .btn:last-child {
    border-top-left-radius: .25rem;
    border-bottom-left-radius: .25rem;
}

html[dir="rtl"] .btn-group .btn:first-child {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-top-left-radius: .25rem;
    border-bottom-left-radius: .25rem;
}

html[dir="rtl"] .btn-group .btn:last-child {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    border-top-right-radius: .25rem;
    border-bottom-right-radius: .25rem;
}

/* Table alignment */
html[dir="rtl"] .table th,
html[dir="rtl"] .table td {
    text-align: right;
}

html[dir="ltr"] .table th,
html[dir="ltr"] .table td {
    text-align: left;
}

/* Card body text alignment */
html[dir="rtl"] .card-body {
    text-align: right;
}

html[dir="ltr"] .card-body {
    text-align: left;
}

/* Arabic content embedding */
.arabic-content {
    font-family: 'Tajawal', sans-serif;
    display: inline-block;
    direction: rtl;
    unicode-bidi: embed;
    text-align: right;
}

/* Twitter handle style */
.twitter-handle {
    direction: ltr;
    unicode-bidi: embed;
    display: inline-block;
    font-family: 'Roboto', sans-serif;
    color: #1DA1F2;
}

/* Toast notification fix */
.toast {
    position: relative;
    min-height: 100px;
    z-index: 9999 !important;
    border-radius: .5rem;
    box-shadow: 0 .5rem 1rem rgba(0, 0, 0, 0.15);
}

.toast.show {
    display: block !important;
}

.toast-header {
    padding: .5rem .75rem;
}

.toast-body {
    padding: .75rem;
    word-wrap: break-word;
}

/* Feature cards RTL/LTR consistent */
.feature-card {
    text-align: center !important;
    min-height: 200px !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
}

.feature-card.twitter i,
.feature-card.twitter h3,
.feature-card.twitter p,
.feature-card.youtube i,
.feature-card.youtube h3,
.feature-card.youtube p,
.feature-card.settings i,
.feature-card.settings h3,
.feature-card.settings p {
    color: #fff !important;
}

/* Tweet accordion improvements */
.tweet-accordion {
    margin-bottom: 10px !important;
    border: 1px solid #ddd !important;
    border-radius: 8px !important;
    overflow: hidden !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1) !important;
}

.tweet-accordion-header {
    padding: 12px 15px !important;
    background: #f8f9fa !important;
    cursor: pointer !important;
    border-bottom: 1px solid #ddd !important;
    transition: background-color .2s ease !important;
    font-weight: 600 !important;
    color: #333 !important;
}

.tweet-accordion-header:hover {
    background: #e9ecef !important;
}

.tweet-content {
    color: #212529 !important;
    font-size: .95rem !important;
    line-height: 1.6 !important;
    white-space: pre-wrap !important;
}

/* Progress text highlight */
#progress-text {
    font-weight: bold !important;
    color: #0d6efd !important;
}

/* Quick action cards */
.row.align-items-stretch .card {
    height: 100% !important;
    min-height: 180px !important;
}

.row.align-items-stretch .card .card-body {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 !important;
}

.row.align-items-stretch .card .card-body form {
    margin-top: auto !important;
}

/* ======= Fix for #refresh-progress ======= */
/* اجعل الشريط ثابتاً فوق المحتوى ولا يأخذ مساحة في التخطيط */
#refresh-progress {
    position: fixed;
    top: calc(var(--header-height, 60px) + 1rem);
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    max-width: 800px;
    z-index: 1050;
    display: none;
    /* Standardmäßig ausgeblendet */
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

#refresh-progress.show {
    display: block;
    visibility: visible;
    opacity: 1;
}

#refresh-progress.hide {
    display: none;
    visibility: hidden;
    opacity: 0;
}