/* ==========================================================
   EasyBac — أنماط مشتركة
   ضعه في جذر الواجهة (بجانب chatfront.js) وأضف في <head>:
   <link rel="stylesheet" href="/easybac-theme.css">

   ملاحظة مهمة: الوضع اللطيف هنا "لمسة لونية" فقط (brand/gold…)،
   والخلفيات تأتي من الفاتح أو الليلي. لذلك يعمل مع الوضعين معاً.

   تعديل: كل محددات الوردي بدأت بـ :root كي تتغلب على
   :root { --brand… } و [data-theme="dark"] { … } المعرَّفة داخل كل صفحة
   (هذه تأتي بعد هذا الملف في الترتيب ولها نفس الخصوصية، فكانت تلغي الوردي).
   ========================================================== */

/* 1) لمسة الوردي — تُطبَّق فوق أي وضع */
:root[data-vibe="pink"] {
    --brand: #E94F8A;
    --brand-deep: #C2185B;
    --brand-soft: #FDE6F1;
    --gold: #FF6F91;
    --gold-soft: #FFE3EC;
    --emerald: #FF8FA3;
    --danger: #D6294B;
}

/* 2) وردي + فاتح */
:root[data-vibe="pink"][data-theme="light"] {
    --bg: #FFF5F8;
    --surface: #FFFFFF;
    --surface-2: #FFEFF5;
    --ink: #4A1942;
    --muted: #9C5F7B;
    --border: #F6D9E6;
    --eb-header-bg: #C2185B;
}

/* 3) وردي + ليلي */
:root[data-vibe="pink"][data-theme="dark"] {
    --brand: #FF7AAE;
    --brand-deep: #B0275E;
    --brand-soft: rgba(255, 122, 174, .16);
    --gold: #FF8FAF;
    --gold-soft: rgba(255, 143, 175, .14);
    --bg: #220A1A;
    --surface: #341127;
    --surface-2: #431A33;
    --ink: #FBE8F1;
    --muted: #D9A3BC;
    --border: #5A2644;
    --eb-header-bg: #5E1136;
}

/* لون الهيدر الموحد في بقية الحالات */
:root { --eb-header-bg: #0D2E6E; }
:root[data-theme="dark"] { --eb-header-bg: #0A1F4A; }

/* ==========================================================
   الهيدر الموحد
   ========================================================== */
.eb-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    min-height: 76px;
    padding: env(safe-area-inset-top, 0px) 24px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: var(--eb-header-bg);
    color: #fff;
    border-bottom: 3px solid var(--gold);
    box-shadow: 0 5px 18px rgba(5, 20, 50, .16);
}

.eb-header * { box-sizing: border-box; }
.eb-side { display: flex; align-items: center; gap: 12px; min-width: 0; }

.eb-back {
    display: inline-flex; align-items: center; gap: 8px;
    height: 42px; padding: 0 15px;
    background: rgba(255, 255, 255, .1);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, .18);
    border-radius: 11px;
    font-weight: 700; font-size: .85rem; font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    touch-action: manipulation;
}
.eb-back:hover { background: rgba(255, 255, 255, .18); }

.eb-title {
    display: flex; align-items: center; gap: 9px;
    min-width: 0;
    font-size: 1rem; font-weight: 800;
    color: #fff;
    margin: 0;
}
.eb-title i { color: var(--gold); flex: none; }
.eb-title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.eb-logo { display: inline-flex; align-items: center; line-height: 1; }
.eb-logo img { height: 38px; width: auto; display: block; object-fit: contain; }

/* زر الوضع الذكي */
.eb-mode { position: relative; }
.eb-mode-btn {
    width: 42px; height: 42px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, .2);
    background: rgba(255, 255, 255, .1);
    color: var(--gold);
    font-size: 1rem;
    cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    touch-action: manipulation;
}
.eb-mode-btn:hover { background: rgba(255, 255, 255, .18); }

.eb-pop {
    position: absolute;
    top: calc(100% + 10px);
    inset-inline-end: 0;            /* في RTL الزر على يسار الشاشة: تمتد النافذة نحو الداخل (يميناً) */
    width: 230px;
    max-width: calc(100vw - 24px);
    padding: 12px;
    background: var(--surface);
    color: var(--ink);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 18px 40px -18px rgba(0, 0, 0, .5);
    display: flex; flex-direction: column; gap: 10px;
    z-index: 1100;
}
.eb-pop[hidden] { display: none; }

.eb-seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.eb-seg button, .eb-vibe {
    height: 40px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--ink);
    font-family: inherit; font-weight: 700; font-size: .84rem;
    cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
}
.eb-seg button[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }

.eb-vibe { justify-content: space-between; padding: 0 12px; }
.eb-vibe i { color: #E94F8A; }
.eb-sw {
    width: 36px; height: 20px; border-radius: 20px;
    background: var(--border); position: relative; transition: background .2s;
}
.eb-sw::after {
    content: ""; position: absolute; top: 2px; inset-inline-start: 2px;
    width: 16px; height: 16px; border-radius: 50%; background: #fff;
    transition: inset-inline-start .2s;
}
.eb-vibe[aria-pressed="true"] .eb-sw { background: #E94F8A; }
.eb-vibe[aria-pressed="true"] .eb-sw::after { inset-inline-start: 18px; }

@media (max-width: 620px) {
    .eb-header { padding-inline: 12px; min-height: 64px; }
    .eb-logo img { height: 30px; }
    .eb-back { width: 42px; padding: 0; justify-content: center; }
    .eb-back span { display: none; }
    .eb-title { font-size: .9rem; }
}

@media (prefers-reduced-motion: reduce) {
    .eb-sw, .eb-sw::after { transition: none; }
}