/* =====================================================================
   iNashra — واجهة موحّدة (2026)
   تصميم داكن مناسب لغرف الأخبار والتحكم: هادئ، واضح، أزرار قليلة.
   ===================================================================== */

:root {
    --bg:        #0f1115;
    --surface:   #171a21;
    --surface-2: #1e222b;
    --surface-3: #262b36;
    --border:    #2b313d;
    --text:      #e7e9ee;
    --muted:     #98a1b1;
    --faint:     #6b7385;
    --accent:    #3b82f6;
    --accent-2:  #2563eb;
    --accent-bg: rgba(59, 130, 246, .14);
    --danger:    #ef4444;
    --danger-bg: rgba(239, 68, 68, .14);
    --success:   #22c55e;
    --success-bg:rgba(34, 197, 94, .14);
    --warning:   #f59e0b;
    --warning-bg:rgba(245, 158, 11, .14);
    --radius:    8px;
    --radius-sm: 6px;
    --shadow:    0 8px 24px rgba(0, 0, 0, .35);
    --font: "Cairo", "Segoe UI", Tahoma, "Noto Sans Arabic", Arial, sans-serif;
    /* ألوان كتابة حسب الخلفية (تُغيَّر في المظاهر الفاتحة آخر الملف) */
    --strong:       #fff;      /* نص بارز / عند المرور */
    --hover-border: #3a4150;
    --accent-text:  #93c5fd;
    --success-text: #86efac;
    --warning-text: #fcd34d;
    --danger-text:  #fca5a5;
    --glow:         #1b2a44;   /* توهج خلفية الصفحات العامة */
    --scheme:       dark;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--strong); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 10px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--hover-border); }

/* ---------- الأزرار ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 34px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--surface-3); border-color: var(--hover-border); color: var(--strong); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn svg { width: 16px; height: 16px; flex: none; }

.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn-danger  { color: var(--danger-text); }
.btn-danger:hover { background: var(--danger-bg); border-color: var(--danger); color: #fff; }
.btn-ghost   { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--border); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn[disabled] { opacity: .45; pointer-events: none; }

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    padding: 0;
}
.icon-btn:hover { background: var(--surface-3); color: var(--strong); }
.icon-btn.danger:hover { background: var(--danger-bg); color: var(--danger); }
.icon-btn svg { width: 18px; height: 18px; }

/* ---------- الشريط العلوي ---------- */
.topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 56px;
    padding: 0 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 0 4px var(--danger-bg); }
/* شعار iNashra: الحرف i بلون مميز */
.brand-name { font-weight: 800; letter-spacing: .3px; unicode-bidi: isolate; }
.brand-name span { color: var(--danger); font-weight: 800; margin-inline-end: 1px; }
.topbar .spacer { flex: 1; }
.clock { font-variant-numeric: tabular-nums; font-size: 20px; font-weight: 700; color: var(--strong); letter-spacing: .5px; min-width: 110px; text-align: center; }

.datebox { display: flex; align-items: center; gap: 4px; }
.datebox input[type=date] {
    height: 34px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
    color-scheme: var(--scheme);
}

/* ---------- تبويبات الساعات ---------- */
.hours {
    display: flex;
    gap: 4px;
    padding: 8px 16px;
    overflow-x: auto;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    scrollbar-width: thin;
}
.hour {
    position: relative;
    flex: none;
    min-width: 62px;
    height: 34px;
    padding: 0 10px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
}
.hour:hover { background: var(--surface-2); color: var(--text); }
.hour.active { background: var(--accent); color: #fff; }
.hour.now::after {
    content: "";
    position: absolute;
    top: 5px;
    inset-inline-end: 6px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--danger);
}

/* ---------- لوحة النشرة ---------- */
.board { display: flex; flex-direction: column; height: calc(100vh - 56px - 51px); }
.panel { display: none; flex: 1; flex-direction: column; min-height: 0; }
.panel.active { display: flex; }

.toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    min-height: 52px;
    padding: 8px 16px;
    border-bottom: 1px solid var(--border);
}
.toolbar .title { font-weight: 700; font-size: 15px; margin-inline-end: 8px; }
.toolbar .spacer { flex: 1; }

.stat {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    font-size: 12px;
    color: var(--muted);
}
.stat b { font-size: 14px; color: var(--text); font-variant-numeric: tabular-nums; }
.stat.main b { color: var(--accent-text); }

.split { display: flex; flex: 1; min-height: 0; gap: 12px; padding: 12px 16px 16px; }
.split .pane {
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.split .pane-main { flex: 3; }
.split .pane-side { flex: 2; }
.pane-head {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 42px;
    padding: 0 12px;
    border-bottom: 1px solid var(--border);
    font-weight: 700;
    color: var(--muted);
    font-size: 13px;
}
.pane iframe { flex: 1; width: 100%; border: 0; background: var(--surface); }

/* ---------- القوائم المنسدلة (details/summary) ---------- */
.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-list {
    position: absolute;
    top: calc(100% + 6px);
    inset-inline-start: 0;
    z-index: 50;
    min-width: 170px;
    padding: 6px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.menu-list a, .menu-list button {
    display: flex;
    width: 100%;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text);
    font: inherit;
    text-align: start;
    cursor: pointer;
}
.menu-list a:hover, .menu-list button:hover { background: var(--surface-3); }

/* ---------- قائمة أخبار النشرة (قابلة للسحب) ---------- */
.page { padding: 0; min-height: 100vh; background: var(--surface); }
.page-bar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 8px;
    height: 48px;
    padding: 0 12px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.page-bar .spacer { flex: 1; }
.count { color: var(--muted); font-size: 13px; }

.rundown { list-style: none; margin: 0; padding: 8px; }
.story {
    display: grid;
    grid-template-columns: 28px 34px 86px minmax(0, 1fr) auto auto 32px;
    align-items: center;
    gap: 10px;
    min-height: 66px;
    margin-bottom: 6px;
    padding: 6px 10px 6px 8px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color .15s, background .15s;
}
.story:hover { border-color: var(--hover-border); }
.story.current { border-color: var(--accent); background: var(--accent-bg); }
.story.ui-sortable-helper { box-shadow: var(--shadow); border-color: var(--accent); background: var(--surface-3); }
.story-placeholder {
    height: 66px;
    margin-bottom: 6px;
    border: 2px dashed var(--accent);
    border-radius: var(--radius);
    background: var(--accent-bg);
}

.handle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 48px;
    border-radius: var(--radius-sm);
    color: var(--faint);
    cursor: grab;
    touch-action: none;
}
.handle:hover { background: var(--surface-3); color: var(--strong); }
.handle:active { cursor: grabbing; }
.handle svg { width: 18px; height: 18px; }

.seq {
    font-weight: 800;
    font-size: 18px;
    color: var(--muted);
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.thumb {
    position: relative;
    width: 86px;
    height: 54px;
    border-radius: var(--radius-sm);
    background: var(--surface-3);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--faint);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb svg { width: 22px; height: 22px; }
a.thumb:hover { outline: 2px solid var(--accent); }
.thumb .play {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, .35);
    opacity: 0;
    transition: opacity .15s;
    color: #fff;
}
a.thumb:hover .play { opacity: 1; }

.story-main { min-width: 0; }
.story-title {
    display: block;
    font-weight: 700;
    font-size: 15px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}
.story-title:hover { color: var(--accent-text); }
.story-meta { display: flex; gap: 6px; margin-top: 4px; flex-wrap: wrap; }

.tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 22px;
    padding: 0 8px;
    border-radius: 999px;
    background: var(--surface-3);
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}
.tag.blue  { background: var(--accent-bg);  color: var(--accent-text); }
.tag.green { background: var(--success-bg); color: var(--success-text); }
.tag.amber { background: var(--warning-bg); color: var(--warning-text); }
a.tag:hover { color: var(--strong); }

.time {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    font-variant-numeric: tabular-nums;
    font-size: 12px;
    color: var(--muted);
    line-height: 1.35;
}
.time b { color: var(--text); font-size: 14px; }

.empty {
    padding: 48px 16px;
    text-align: center;
    color: var(--faint);
}
.empty svg { width: 36px; height: 36px; display: block; margin: 0 auto 10px; opacity: .6; }

.toast {
    position: fixed;
    bottom: 16px;
    inset-inline-start: 50%;
    transform: translateX(50%);
    z-index: 100;
    padding: 10px 16px;
    border-radius: var(--radius);
    background: var(--surface-3);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    font-weight: 600;
}
.toast.ok   { border-color: var(--success); }
.toast.warn { border-color: var(--warning); }

/* ---------- قائمة الأخبار المتاحة (للإضافة إلى النشرة) ---------- */
.seg {
    display: inline-flex;
    padding: 3px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    border: 1px solid var(--border);
}
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
}
.seg input:checked + span { background: var(--surface-3); color: var(--strong); }

.search {
    flex: 1;
    min-width: 80px;
    height: 32px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
}
.search:focus { outline: none; border-color: var(--accent); }

.pool { list-style: none; margin: 0; padding: 6px 8px 72px; }
.pool-item {
    display: grid;
    grid-template-columns: 22px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
}
.pool-item:hover { background: var(--surface-2); }
.pool-item.checked { background: var(--accent-bg); border-color: var(--accent); }
.pool-item input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; margin: 0; }
.pool-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pool-title a:hover { color: var(--accent-text); text-decoration: underline; }
.pool-meta { display: flex; gap: 6px; margin-top: 2px; font-size: 12px; color: var(--muted); }
.pool-item.old .pool-title { color: var(--muted); }
.pool-dur { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; }

.dock {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--surface);
    border-top: 1px solid var(--border);
}
.dock .spacer { flex: 1; }

/* ---------- النماذج (تحرير الخبر وغيره) ---------- */
.form-page { max-width: 1280px; margin: 0 auto; padding: 16px; }
.form-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
@media (max-width: 860px) { .form-grid { grid-template-columns: 1fr; } }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.card-body { padding: 16px; }
.card-title { margin: 0 0 12px; font-size: 13px; font-weight: 700; color: var(--muted); }
.card + .card { margin-top: 12px; }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 13px; font-weight: 600; }
.input, .select, .textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
}
.input, .select { height: 40px; padding: 0 12px; }
.input.lg { height: 46px; font-size: 17px; font-weight: 700; }
.textarea { min-height: 360px; padding: 12px 14px; font-size: 17px; line-height: 1.9; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.input[readonly] { color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.chip {
    height: 26px; padding: 0 10px; border: 1px solid var(--border); border-radius: 999px;
    background: var(--surface-2); color: var(--muted); font: inherit; font-size: 12px; font-weight: 700; cursor: pointer;
}
.chip:hover { background: var(--surface-3); color: var(--strong); }

.row { display: flex; align-items: center; gap: 10px; }
.row + .row { margin-top: 10px; }
.row .grow { flex: 1; min-width: 0; }
.kv { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--muted); font-size: 13px; }
.kv .v { font-weight: 700; font-variant-numeric: tabular-nums; }
.file-name { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; direction: ltr; text-align: left; }

/* مفتاح تشغيل/إيقاف */
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle .track { position: relative; width: 42px; height: 24px; flex: none; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--border); transition: background .15s; }
.toggle .track::after { content: ""; position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; border-radius: 50%; background: #cbd2dd; transition: transform .15s; }
.toggle input:checked + .track { background: var(--success); border-color: var(--success); }
.toggle input:checked + .track::after { transform: translateX(-18px); background: #fff; }
.toggle input:disabled + .track { opacity: .5; }
.toggle.locked { cursor: not-allowed; }

.banner { display: flex; align-items: center; gap: 10px; padding: 10px 14px; margin-bottom: 12px; border-radius: var(--radius); font-weight: 600; }
.banner.warn { background: var(--warning-bg); border: 1px solid var(--warning); color: var(--warning-text); }
.banner.ok   { background: var(--success-bg); border: 1px solid var(--success); color: var(--success-text); }
.banner.err  { background: var(--danger-bg);  border: 1px solid var(--danger); color: var(--danger-text); }

.savebar { position: sticky; bottom: 0; display: flex; align-items: center; gap: 10px; margin-top: 16px; padding: 12px 0;
           background: linear-gradient(to top, var(--bg) 70%, transparent); }
.savebar .spacer { flex: 1; }

/* ---------- شريط الفيديوهات غير المرتبطة (وضع الـ Agent) ---------- */
.vstrip { position: sticky; top: 48px; z-index: 15; margin: 8px 8px 0; padding: 8px 10px;
          background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); }
.vstrip-head { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.vstrip-head b { color: var(--text); font-size: 13px; }
.vstrip-head .spacer { flex: 1; }
.agent-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); flex: none; }
.agent-dot.on { background: var(--success); box-shadow: 0 0 0 3px var(--success-bg); }
.vstrip-list { display: flex; gap: 8px; overflow-x: auto; padding-top: 8px; min-height: 20px; }
.vstrip-empty { color: var(--faint); font-size: 12px; padding: 4px 0; }
.vstrip-hint { color: var(--muted); font-size: 11.5px; margin-top: 4px; }
.vstrip .vs-close { width: 26px; height: 26px; font-size: 13px; }
/* أيقونة الفيديوهات غير المرتبطة (للمونتير) */
.vbtn { position: relative; display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 11px 0 9px;
        border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-2); color: var(--faint);
        cursor: pointer; font: inherit; font-size: 12.5px; font-weight: 700; white-space: nowrap;
        transition: color .2s, border-color .2s, background .2s; }
.vbtn .vicon { position: relative; display: inline-flex; }
.vbtn svg { width: 20px; height: 20px; }
.vbtn:hover { border-color: var(--hover-border); }
/* لا فيديو أصلاً */
.vbtn.st-none { color: var(--faint); }
/* فيديوهات تنتظر الربط */
.vbtn.st-wait { color: #fff; background: var(--warning); border-color: var(--warning); animation: vpulse 1.8s ease-out infinite; }
/* كل الفيديوهات مرتبطة */
.vbtn.st-ok { color: var(--success-text); background: var(--success-bg); border-color: var(--success); }
.vbtn[aria-expanded="true"] { box-shadow: 0 0 0 2px var(--accent-bg); }
.vbtn .vbadge { display: none; }
.vbtn .agent-dot { position: absolute; bottom: -2px; inset-inline-start: -3px; width: 7px; height: 7px; box-shadow: 0 0 0 2px var(--surface-2); }
@keyframes vpulse { 0% { box-shadow: 0 0 0 0 rgba(245,158,11,.55); } 70% { box-shadow: 0 0 0 9px rgba(245,158,11,0); } 100% { box-shadow: 0 0 0 0 rgba(245,158,11,0); } }
.vcard { flex: none; width: 150px; padding: 6px; border-radius: var(--radius-sm); background: var(--surface);
         border: 1px solid var(--border); cursor: grab; user-select: none; position: relative; }
.vcard:hover { border-color: var(--hover-border); }
.vcard.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-bg); }
.vcard.dragging { opacity: .5; }
.vcard .vthumb { width: 100%; height: 78px; border-radius: 4px; background: var(--surface-3); overflow: hidden;
                 display: flex; align-items: center; justify-content: center; color: var(--faint); }
.vcard .vthumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vcard .vthumb svg { width: 22px; height: 22px; }
.vcard .vname { margin-top: 4px; font-size: 11px; direction: ltr; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vcard .vmeta { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.vcard .vstate { margin-top: 4px; font-size: 11px; font-weight: 700; }
.vcard.assigned { cursor: default; border-color: rgba(245,158,11,.5); }
.vcard.assigned .vstate { color: var(--warning-text); }
.vcard.error { border-color: rgba(239,68,68,.5); }
.vcard.error .vstate { color: var(--danger-text); }
.vcard .vx { position: absolute; top: 4px; inset-inline-end: 4px; width: 20px; height: 20px; border-radius: 50%; border: 0;
             background: rgba(0,0,0,.6); color: #fff; cursor: pointer; font-size: 12px; line-height: 20px; padding: 0; }
.spin { display: inline-block; width: 10px; height: 10px; border: 2px solid var(--muted); border-top-color: transparent;
        border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -1px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* الخبر كهدف للإفلات */
.story.drop-ok { border-color: var(--accent); background: var(--accent-bg); }
.story.pick-target { cursor: copy; }
.slot-pop { position: absolute; z-index: 60; display: flex; gap: 6px; align-items: center; padding: 8px;
            background: var(--surface-3); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.slot-pop span { font-size: 12px; color: var(--muted); margin-inline-end: 4px; }
.slot-pop .btn { min-width: 44px; justify-content: center; }
.slot-pop .btn.has { border-color: var(--warning); }
.sync-warn { color: var(--warning-text); }
.vstrip-head { flex-wrap: wrap; row-gap: 2px; }
.vstrip-head > * { white-space: nowrap; }
.vcard .vmeta span { direction: ltr; unicode-bidi: isolate; }

/* صفحة مدير الأخبار (tabs/index.php وإطاراتها): لون أزرق كحلي لتمييزها عن صفحة المونتاج */
html:not([data-tone="light"]) .theme-manage {
    --bg:        #0b1730;
    --surface:   #112244;
    --surface-2: #172b54;
    --surface-3: #1f3666;
    --border:    #2b4475;
    --muted:     #a5b4cf;
}
html:not([data-tone="light"]):has(body.theme-manage) { background: #0b1730; }
html:not([data-tone="light"]) .theme-manage .topbar { background: #0f2550; box-shadow: inset 0 -3px 0 var(--accent); }
/* في المظاهر الفاتحة: صفحة المدير تتميّز بشريط علوي أزرق فاتح، وبقية الصفحة بلون المظهر */
[data-tone="light"] .theme-manage .topbar { background: #d3e1f7; color: #0b1b3a; box-shadow: inset 0 -3px 0 #1d4ed8; }

/* ---------- قائمة المستخدم (inc/ui.php: ui_user_menu) ---------- */
.um { position: relative; }
.um-btn { display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 8px 0 10px; border: 1px solid var(--border);
          border-radius: 999px; background: var(--surface-2); color: var(--text); font: inherit; font-size: 13px; cursor: pointer; }
.um-btn:hover, .um-btn[aria-expanded="true"] { border-color: var(--accent); }
.um-btn svg { width: 14px; height: 14px; color: var(--muted); }
.um-av { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--accent);
         color: #fff; font-weight: 800; font-size: 12px; }
.um-name { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.um-pop { position: absolute; top: calc(100% + 8px); inset-inline-end: 0; z-index: 1000; min-width: 270px; padding: 6px;
          background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); }
.um-pop[hidden] { display: none; }
.um-head { padding: 10px 12px 12px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.um-head b { display: block; font-size: 14px; }
.um-head span { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }
.um-pop a, .um-pop button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border: 0; border-radius: 8px;
          background: none; color: var(--text); font: inherit; font-size: 13.5px; text-align: start; text-decoration: none; cursor: pointer; }
.um-pop a:hover { background: var(--surface-2); }
.um-pop svg { width: 18px; height: 18px; flex: none; color: var(--muted); }
.um-pop button[disabled] { opacity: .55; cursor: default; }
.um-pop em { margin-inline-start: auto; font-style: normal; font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--surface-3); color: var(--muted); }
.um-pop .um-wa svg { color: #25d366; }
.um-pop .um-out { color: var(--danger-text); }
.um-pop .um-out svg { color: var(--danger-text); }
.um-sep { height: 1px; margin: 6px 4px; background: var(--border); }
@media (max-width: 700px) { .um-name { display: none; } }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.ltr { direction: ltr; unicode-bidi: isolate; }
input.ltr, textarea.ltr { text-align: left; }

/* ---- اللغات (inc/i18n.php) ---- */
.lsw { position: relative; }
.lsw summary { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 10px; border: 1px solid var(--border);
               border-radius: var(--radius-sm); cursor: pointer; list-style: none; color: var(--muted); font-size: 13px; user-select: none; }
.lsw summary::-webkit-details-marker { display: none; }
.lsw summary:hover, .lsw[open] summary { border-color: var(--accent); color: var(--text); }
.lsw summary svg { width: 17px; height: 17px; }
.lsw > div { position: absolute; top: calc(100% + 6px); inset-inline-end: 0; z-index: 1000; min-width: 150px; padding: 5px;
             background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); }
.lsw > div a { display: block; padding: 8px 12px; border-radius: 7px; color: var(--text); text-decoration: none; font-size: 14px; text-align: start; }
.lsw > div a:hover { background: var(--surface-2); }
.lsw > div a.on { color: var(--accent-text); font-weight: 700; }
.um-langs { display: flex; gap: 4px; padding: 4px 8px 8px; flex-wrap: wrap; }
.um-langs a { flex: 1; min-width: 56px; justify-content: center; padding: 6px 4px !important; font-size: 12.5px !important;
              border: 1px solid var(--border) !important; }
.um-langs a.on { border-color: var(--accent) !important; color: var(--accent-text) !important; font-weight: 700; }
.um-label { padding: 8px 12px 2px; color: var(--faint); font-size: 11.5px; }

/* ---- اتجاه LTR (الإنكليزية والإسبانية) لعناصر تعتمد على الاتجاه ---- */
[dir="ltr"] .toast { transform: translateX(-50%); }
[dir="ltr"] .toggle .track::after { right: auto; left: 2px; }
[dir="ltr"] .toggle input:checked + .track::after { transform: translateX(18px); }
[dir="ltr"] .flist .nm { text-align: left; }

/* =====================================================================
   المظاهر (inc/i18n.php: ui_theme) — data-theme و data-tone على <html>
   الداكن هو :root أعلاه. الفاتحة: كتابة داكنة جداً على خلفية فاتحة لوضوح أعلى.
   ===================================================================== */
html { color-scheme: var(--scheme); }

/* أزرار اختيار المظهر في قائمة المستخدم */
.um-themes { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px 8px 8px; }
.um-pop .um-themes a { gap: 7px; padding: 6px 8px; font-size: 12.5px; border: 1px solid var(--border); }
.um-pop .um-themes a.on { border-color: var(--accent); color: var(--accent-text); font-weight: 700; }
.um-sw { flex: none; width: 16px; height: 16px; border-radius: 50%; border: 1px solid rgba(128, 128, 128, .6); }
.um-sw-dark  { background: #171a21; }
.um-sw-gray  { background: #e4e7eb; }
.um-sw-beige { background: #ece3d3; }
.um-sw-green { background: #d6ead9; }

[data-tone="light"] {
    --danger:       #dc2626;
    --danger-bg:    rgba(220, 38, 38, .10);
    --success:      #16a34a;
    --success-bg:   rgba(22, 163, 74, .12);
    --warning:      #d97706;
    --warning-bg:   rgba(217, 119, 6, .13);
    --shadow:       0 8px 24px rgba(15, 23, 42, .16);
    --strong:       #000;
    --success-text: #166534;
    --warning-text: #92400e;
    --danger-text:  #b91c1c;
    --scheme:       light;
}

/* رصاصي فاتح */
[data-theme="gray"] {
    --bg:           #e4e7eb;
    --surface:      #f8f9fb;
    --surface-2:    #eceef2;
    --surface-3:    #dde1e7;
    --border:       #c3c9d2;
    --text:         #0f172a;
    --muted:        #3f4a5a;
    --faint:        #5f6b7a;
    --accent:       #1d4ed8;
    --accent-2:     #1e40af;
    --accent-bg:    rgba(29, 78, 216, .11);
    --accent-text:  #1e40af;
    --hover-border: #8f99a8;
    --glow:         #f4f6f9;
}

/* بيج */
[data-theme="beige"] {
    --bg:           #ece3d3;
    --surface:      #fbf7ef;
    --surface-2:    #f3ebdc;
    --surface-3:    #e7dbc5;
    --border:       #cdbb9c;
    --text:         #231a0e;
    --muted:        #54452f;
    --faint:        #75644b;
    --accent:       #9a3412;
    --accent-2:     #7c2d12;
    --accent-bg:    rgba(154, 52, 18, .11);
    --accent-text:  #7c2d12;
    --hover-border: #a8916b;
    --glow:         #f7f0e3;
}

/* أخضر فاتح */
[data-theme="green"] {
    --bg:           #d6ead9;
    --surface:      #f5faf6;
    --surface-2:    #e8f2ea;
    --surface-3:    #d3e5d8;
    --border:       #a9cbb2;
    --text:         #0c2214;
    --muted:        #33503c;
    --faint:        #557260;
    --accent:       #15803d;
    --accent-2:     #166534;
    --accent-bg:    rgba(21, 128, 61, .12);
    --accent-text:  #14532d;
    --hover-border: #7fa98a;
    --glow:         #eef7f0;
}
