/* ==============================================================
   Arabic Hate Speech Keyword Discovery Tool
   Custom styles (تكميلية لـ Bootstrap 5 RTL)
   ============================================================== */

:root {
    --hs-primary: #2c3e50;
    --hs-accent:  #16a085;
    --hs-danger:  #c0392b;
    --hs-warning: #e67e22;
    --hs-bg:      #f5f7fa;
    --hs-text:    #2c3e50;
    --hs-muted:   #7f8c8d;
    --hs-border:  #e1e5ea;
}

/* ----- خط مناسب للعربي + اللاتيني ----- */
body {
    font-family: 'Tajawal', 'Segoe UI', 'Tahoma', sans-serif;
    background-color: var(--hs-bg);
    color: var(--hs-text);
    min-height: 100vh;
}
[dir="rtl"] body { direction: rtl; text-align: right; }
[dir="ltr"] body { direction: ltr; text-align: left; }

/* اتجاه الـ form-label و input داخل LTR صراحة (احتياط لو bootstrap.rtl.css كاشد) */
[dir="ltr"] .form-label,
[dir="ltr"] .form-control,
[dir="ltr"] .form-select {
    text-align: left;
}
[dir="rtl"] .form-label,
[dir="rtl"] .form-control,
[dir="rtl"] .form-select {
    text-align: right;
}

/* ----- مبدّل اللغة في صفحة الدخول ----- */
.lang-switcher-top {
    position: fixed;
    top: 1.25rem;
    display: flex;
    gap: 0.5rem;
    z-index: 1000;
}
[dir="rtl"] .lang-switcher-top { left: 1.25rem; right: auto; }
[dir="ltr"] .lang-switcher-top { right: 1.25rem; left: auto; }

.login-page .lang-switcher-top a.lang-pill,
.lang-switcher-top a.lang-pill {
    display: inline-block;
    padding: 0.4rem 1rem;
    background: rgba(255, 255, 255, 0.2) !important;
    border: 1px solid rgba(255, 255, 255, 0.4) !important;
    border-radius: 20px;
    color: #fff !important;
    text-decoration: none !important;
    font-size: 0.88rem;
    font-weight: 500;
    transition: all 0.15s ease;
    line-height: 1;
}
.lang-switcher-top a.lang-pill:hover {
    background: rgba(255, 255, 255, 0.32) !important;
    color: #fff !important;
    transform: translateY(-1px);
}
.lang-switcher-top a.lang-pill.active {
    background: #fff !important;
    color: var(--hs-primary) !important;
    font-weight: 700;
    border-color: #fff !important;
}

/* ╔═════════════════════════════════════════════════════════╗
   ║ Sidebar layout — استبدل الـ navbar العلوي بـ sidebar جانبي ║
   ╚═════════════════════════════════════════════════════════╝ */

:root {
    --sidebar-width: 260px;
}

body.has-sidebar {
    margin: 0;
    background-color: var(--hs-bg);
}

/* ----- Sidebar نفسه ----- */
.sidebar {
    position: fixed;
    top: 0;
    height: 100vh;
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--hs-primary) 0%, #1f2d3d 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    overflow-y: auto;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.15);
    transition: transform 0.3s ease;
}
[dir="rtl"] .sidebar { right: 0; }
[dir="ltr"] .sidebar { left: 0; }

/* ----- المحتوى الرئيسي ----- */
.main-content {
    min-height: calc(100vh - 60px);
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
}
[dir="rtl"] body.has-sidebar .main-content { margin-right: var(--sidebar-width); margin-left: 0; }
[dir="ltr"] body.has-sidebar .main-content { margin-left: var(--sidebar-width); margin-right: 0; }

/* ----- Brand ----- */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 1.25rem 1rem;
    text-decoration: none;
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 1.2rem;
}
.sidebar-brand:hover { color: #fff; text-decoration: none; }
.sidebar-brand .brand-text { line-height: 1.1; }
.sidebar-brand .brand-name { font-weight: 700; font-size: 0.95rem; }
.sidebar-brand .brand-version {
    font-size: 0.7rem;
    opacity: 0.7;
    margin-top: 2px;
}

/* ----- نواف التنقل ----- */
.sidebar-nav {
    flex: 1;
    padding: 1rem 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.sidebar-item {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.7rem 1rem;
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.12s ease;
    font-size: 0.95rem;
}
.sidebar-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    text-decoration: none;
}
.sidebar-item.active {
    background: var(--hs-accent);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(22, 160, 133, 0.4);
}
.sidebar-item.disabled {
    color: rgba(255, 255, 255, 0.5);
    pointer-events: none;
    font-size: 0.85rem;
}
.sidebar-item .item-icon {
    font-size: 1.15rem;
    width: 1.6rem;
    text-align: center;
    flex-shrink: 0;
}
.sidebar-item .item-label { flex: 1; }

/* ----- Footer ----- */
.sidebar-footer {
    padding: 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.sidebar-lang-dropdown .dropdown-menu {
    background: #fff;
    min-width: 160px;
}
.sidebar-lang-dropdown .dropdown-item.active {
    background: var(--hs-accent);
    color: #fff;
}
.sidebar-logout:hover {
    background: rgba(220, 53, 69, 0.85) !important;
    color: #fff;
}

/* ----- زر التبديل على الموبايل ----- */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    z-index: 1100;
    background: var(--hs-primary);
    color: #fff;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    font-size: 1.4rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    cursor: pointer;
}
[dir="rtl"] .sidebar-toggle { right: 1rem; }
[dir="ltr"] .sidebar-toggle { left: 1rem; }

/* ----- Overlay ----- */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}
.sidebar-overlay.show { display: block; }

/* ----- Responsive: على الموبايل، sidebar مخفي حتى ضغط الزر ----- */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(0);
    }
    [dir="rtl"] .sidebar:not(.show) { transform: translateX(100%); }
    [dir="ltr"] .sidebar:not(.show) { transform: translateX(-100%); }

    body.has-sidebar .main-content {
        margin-right: 0 !important;
        margin-left: 0 !important;
        padding-top: 4rem;
    }
    .sidebar-toggle { display: block; }
}

/* ضمان ترتيب الأزرار في النموذج */
[dir="ltr"] .input-group {
    direction: ltr;
    flex-direction: row;
}
[dir="rtl"] .input-group {
    direction: rtl;
}

/* الـ analyze input لا يُقلب (URL يبقى LTR) */
.analyze-input {
    direction: ltr !important;
    text-align: left !important;
}
.navbar-brand {
    font-weight: 700;
    color: #fff !important;
}
.navbar .nav-link {
    color: rgba(255, 255, 255, 0.85) !important;
}
.navbar .nav-link:hover,
.navbar .nav-link.active {
    color: #fff !important;
}
.navbar .badge-version {
    font-size: 0.7rem;
    background: rgba(255, 255, 255, 0.18);
    padding: 2px 8px;
    border-radius: 10px;
    margin-inline-start: 6px;
    vertical-align: middle;
}

/* ----- البطاقات ----- */
.card {
    border: 1px solid var(--hs-border);
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
.card-header {
    background-color: #fff;
    border-bottom: 1px solid var(--hs-border);
    font-weight: 600;
}

/* ----- صفحة تسجيل الدخول ----- */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
    background: linear-gradient(135deg, #2c3e50 0%, #16a085 100%);
}
.login-card {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: 12px;
    padding: 2.5rem 2rem;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
}
.login-title {
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--hs-primary);
    font-weight: 700;
}
.login-subtitle {
    text-align: center;
    color: var(--hs-muted);
    margin-bottom: 2rem;
    font-size: 0.95rem;
}

/* ----- نموذج التحليل ----- */
.analyze-input {
    font-family: 'Courier New', monospace;
    direction: ltr;
    text-align: left;
}

/* ----- مربّعات الحالة ----- */
.status-box {
    padding: 1rem 1.25rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    border-right: 4px solid;
}
.status-box.idle    { background: #ecf0f1; border-color: #95a5a6; color: #34495e; }
.status-box.working { background: #fff3cd; border-color: #f39c12; color: #7d5409; }
.status-box.success { background: #d4edda; border-color: #27ae60; color: #1e6b3c; }
.status-box.error   { background: #f8d7da; border-color: #c0392b; color: #6f1c14; }

/* ----- بطاقة كلمة مرشّحة ----- */
.candidate-card {
    background: #fff;
    border: 1px solid var(--hs-border);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin-bottom: 0.85rem;
    transition: all 0.15s ease;
}
.candidate-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border-color: var(--hs-accent);
}
.candidate-keyword {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--hs-primary);
}
.candidate-meta {
    color: var(--hs-muted);
    font-size: 0.88rem;
    margin: 0.35rem 0 0.6rem;
}
.candidate-context {
    background: #f8f9fa;
    padding: 0.6rem 0.85rem;
    border-radius: 6px;
    font-size: 0.92rem;
    margin-bottom: 0.4rem;
    line-height: 1.7;
    border-right: 3px solid var(--hs-accent);
}

/* ----- أزرار القرار ----- */
.decision-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.75rem;
}
.btn-accept {
    background: #27ae60;
    color: #fff;
}
.btn-accept:hover { background: #1e8449; color: #fff; }
.btn-reject {
    background: #c0392b;
    color: #fff;
}
.btn-reject:hover { background: #922b21; color: #fff; }
.btn-defer {
    background: #f39c12;
    color: #fff;
}
.btn-defer:hover { background: #b9770e; color: #fff; }

/* ----- النصوص العربية الطويلة ----- */
.transcript-box {
    background: #fafbfc;
    border: 1px solid var(--hs-border);
    border-radius: 6px;
    padding: 1rem;
    max-height: 320px;
    overflow-y: auto;
    line-height: 2.1;
    font-size: 1rem;
}

/* كلمات النص قابلة للنقر */
.transcript-box .word {
    padding: 1px 3px;
    border-radius: 3px;
    cursor: pointer;
    transition: background 0.1s;
}
.transcript-box .word:hover {
    background: #fff3cd;
    color: #7d5409;
}
.transcript-box .word.just-clicked {
    background: #d4edda;
    color: #155724;
    animation: flash 0.6s ease;
}
@keyframes flash {
    0% { background: #28a745; color: #fff; }
    100% { background: #d4edda; color: #155724; }
}

/* ----- شريط التقدّم ----- */
.progress-wrapper {
    margin: 1rem 0;
}
.progress-step {
    color: var(--hs-muted);
    font-size: 0.92rem;
    padding: 0.3rem 0;
}
.progress-step.done { color: #27ae60; }
.progress-step.active { color: var(--hs-accent); font-weight: 600; }

/* ----- Footer ----- */
.app-footer {
    text-align: center;
    color: var(--hs-muted);
    font-size: 0.85rem;
    padding: 2rem 1rem 1rem;
}
[dir="rtl"] body.has-sidebar .app-footer { margin-right: var(--sidebar-width); margin-left: 0; }
[dir="ltr"] body.has-sidebar .app-footer { margin-left: var(--sidebar-width); margin-right: 0; }
@media (max-width: 992px) {
    body.has-sidebar .app-footer {
        margin-right: 0 !important;
        margin-left: 0 !important;
    }
}

/* ----- استجابة (Mobile) ----- */
@media (max-width: 576px) {
    .login-card { padding: 1.75rem 1.25rem; }
    .candidate-keyword { font-size: 1.1rem; }
    .decision-buttons .btn { flex: 1; }
}
