/* بوابة الرسائل ورموز الدخول — قنوات SMS وواتساب (0263).
   منقول من نموذج التصميم المعتمد (design-previews/otp-channels). كل ما عداه
   من اللوحة نفسها (panel/kpi-row/tag/data-tbl/btn/inp)، والأصناف هنا كلّها
   مسبوقة بـog- فلا تُصادم صنفاً عامّاً في app.css. */

:root {
  --og-wa: #1f8a5c; --og-wa-bg: #e6f5ee; --og-wa-line: #bfe4d0;
  --og-sms: #3d7fd1; --og-sms-bg: #e8f0fb; --og-sms-line: #c5d8f2;
}
:root[data-theme="dark"] {
  --og-wa: #6fd1a8; --og-wa-bg: #14291f; --og-wa-line: #28553f;
  --og-sms: #7fb3ec; --og-sms-bg: #152437; --og-sms-line: #2a4566;
}

.og bdi[dir=ltr], .og .ltr { direction: ltr; unicode-bidi: isolate; }
.og .num { font-variant-numeric: tabular-nums; }
.og .tag.sms { background: var(--og-sms-bg); color: var(--og-sms); border: 1px solid var(--og-sms-line); }
.og .tag.wa { background: var(--og-wa-bg); color: var(--og-wa); border: 1px solid var(--og-wa-line); }
.og .tag.role { background: var(--surface-3); color: var(--text); border: 1px solid var(--line-2); }
.og .tag .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.og .btn svg { width: 14px; height: 14px; }
.og .btn.danger { background: var(--crit); color: #fff; border-color: transparent; }
.og .btn.ghost { background: transparent; }

/* تنبيه القفل: لا رموز تُرسل */
.og-lock { background: var(--crit); color: #fff; border-radius: 12px; padding: 13px 15px; margin-bottom: 14px; display: flex; gap: 12px; align-items: flex-start; }
.og-lock svg { width: 26px; height: 26px; flex: 0 0 auto; margin-top: 2px; }
.og-lock .t { font-weight: 800; font-size: 15px; font-family: var(--fdisplay); }
.og-lock .d { font-size: 12.5px; color: rgba(255, 255, 255, .88); }
.og-readonly { font-size: 12px; color: var(--muted); font-weight: 700; border: 1px dashed var(--border); border-radius: 10px; padding: 8px 12px; margin-bottom: 14px; }

/* الاستراتيجية */
.og-modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.og-mode { display: flex; gap: 10px; align-items: flex-start; text-align: right; padding: 12px 13px; border: 1px solid var(--border); background: var(--surface-2); border-radius: 12px; font: inherit; color: inherit; cursor: pointer; }
.og-mode:hover:not(:disabled) { border-color: var(--primary-light); }
.og-mode:disabled { cursor: default; }
.og-mode .rd { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--faint); flex: 0 0 auto; margin-top: 3px; display: grid; place-items: center; }
.og-mode b { display: block; font-size: 13.5px; font-weight: 800; font-family: var(--fdisplay); }
.og-mode span { display: block; font-size: 11.5px; color: var(--muted); font-weight: 600; line-height: 1.55; margin-top: 2px; }
.og-mode[aria-checked=true] { border-color: var(--primary); background: var(--surface); box-shadow: inset 0 0 0 1px var(--primary); }
.og-mode[aria-checked=true] .rd { border-color: var(--primary); }
.og-mode[aria-checked=true] .rd::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }
.og-subh { font-size: 11px; color: var(--faint); font-weight: 800; margin: 16px 0 8px; }
.og-order { display: flex; align-items: stretch; gap: 8px; flex-wrap: wrap; }
.og-slot { flex: 1 1 220px; display: flex; align-items: center; gap: 10px; border: 1px solid var(--border); border-radius: 12px; padding: 9px 12px; background: var(--surface); min-width: 0; }
.og-slot .n { width: 24px; height: 24px; border-radius: 7px; background: color-mix(in srgb, var(--c-settings) 22%, transparent); color: var(--text); font-weight: 800; font-size: 12px; display: grid; place-items: center; flex: 0 0 auto; font-family: var(--fdisplay); }
.og-slot .nm { font-weight: 800; font-size: 13px; }
.og-slot .sm { font-size: 11px; color: var(--faint); font-weight: 600; display: block; }
.og-slot.off { opacity: .55; border-style: dashed; }
.og-swap { align-self: center; flex: 0 0 auto; }
.og-arrow { align-self: center; color: var(--faint); font-size: 11px; font-weight: 700; text-align: center; flex: 0 0 auto; line-height: 1.3; }
.og-trig { display: flex; flex-direction: column; gap: 8px; }
.og-trig label { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; flex-wrap: wrap; }
.og-trig input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--primary); }
.og-trig .og-sec { width: 64px; min-width: 0; text-align: center; }
.og-pick-row { display: flex; gap: 8px; flex-wrap: wrap; }
.og-pick { display: flex; align-items: center; gap: 8px; padding: 8px 13px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); font: inherit; font-size: 13px; font-weight: 700; color: inherit; cursor: pointer; }
.og-pick[aria-checked=true] { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.og-explain { margin-top: 16px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); padding: 12px 14px; }
.og-explain .lead { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; font-weight: 700; line-height: 1.75; }
.og-explain .lead svg { width: 18px; height: 18px; flex: 0 0 auto; color: var(--primary); margin-top: 4px; }
.og-explain.crit { background: var(--crit-bg); border-color: var(--crit-line); }
.og-explain.crit .lead, .og-explain.crit .lead svg { color: var(--crit); }
.og-notes { list-style: none; margin: 8px 0 0; padding: 8px 0 0; border-top: 1px solid var(--border-soft); display: flex; flex-direction: column; gap: 5px; }
.og-notes li { font-size: 12px; font-weight: 600; color: var(--muted); display: flex; gap: 7px; align-items: baseline; }
.og-notes li::before { content: ""; width: 6px; height: 6px; border-radius: 2px; background: var(--faint); flex: 0 0 auto; transform: translateY(-1px); }
.og-notes li.warn { color: var(--warn); } .og-notes li.warn::before { background: var(--warn); }
.og-notes li.crit { color: var(--crit); } .og-notes li.crit::before { background: var(--crit); }
.og-audit { font-size: 11.5px; color: var(--faint); font-weight: 600; }
.og-audit b { color: var(--muted); }
.og-hist { margin: 10px 0 0; padding: 0; list-style: none; font-size: 11.5px; color: var(--muted); display: flex; flex-direction: column; gap: 3px; }
.og-link { background: none; border: none; padding: 0; color: var(--primary); font: inherit; font-weight: 700; font-size: 11.5px; cursor: pointer; }

.og-rescue { margin-top: 10px; display: flex; gap: 8px; align-items: flex-start; font-size: 12px; font-weight: 700; color: var(--good); background: var(--good-bg); border: 1px solid var(--good-line); border-radius: 10px; padding: 8px 11px; }
.og-rescue svg { width: 15px; height: 15px; flex: 0 0 auto; margin-top: 2px; }
.og-alert { display: flex; gap: 10px; align-items: flex-start; background: var(--crit); color: #fff; border-radius: 11px; padding: 10px 12px; margin-bottom: 10px; }
.og-alert svg { width: 20px; height: 20px; flex: 0 0 auto; margin-top: 2px; }
.og-alert .t { font-weight: 800; font-size: 13px; }
.og-alert .d { font-size: 11.5px; color: rgba(255, 255, 255, .9); overflow-wrap: anywhere; }

/* بطاقات القنوات */
.og-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; margin-bottom: 16px; }
.og-grid > .panel { margin-bottom: 0; }
.og-ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: 0 0 auto; }
.og-ic svg { width: 18px; height: 18px; }
.og-ic.sms { background: var(--og-sms-bg); color: var(--og-sms); }
.og-ic.wa { background: var(--og-wa-bg); color: var(--og-wa); }
.og-title { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.og-title h3 { white-space: nowrap; }
.og-title .tags { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 3px; }
.og-card.disabled .og-facts { opacity: .62; }
.og-sw { width: 42px; height: 24px; border-radius: 999px; border: none; background: var(--surface-3); box-shadow: 0 0 0 1px var(--line-2) inset; position: relative; flex: 0 0 auto; padding: 0; transition: background var(--t) var(--ease), box-shadow var(--t); cursor: pointer; }
.og-sw::after { content: ""; position: absolute; width: 18px; height: 18px; background: var(--ink-3); border-radius: 50%; top: 3px; right: 3px; box-shadow: 0 2px 6px rgba(0, 0, 0, .35); transition: right var(--t) var(--spring), background var(--t); }
.og-sw[aria-checked=true] { background: var(--good); box-shadow: 0 6px 16px -8px var(--good); }
.og-sw[aria-checked=true]::after { right: 21px; background: #fff; }
.og-sw:disabled { opacity: .45; cursor: not-allowed; }
.og-sw:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.og-swwrap { display: flex; align-items: center; gap: 8px; font-size: 11.5px; font-weight: 800; color: var(--muted); }
.og-facts { display: grid; grid-template-columns: minmax(118px, auto) 1fr; margin: 0; }
.og-facts dt, .og-facts dd { padding: 9px 0; border-bottom: 1px solid var(--border-soft); margin: 0; font-size: 12.5px; }
.og-facts dt { color: var(--faint); font-weight: 700; padding-inline-end: 12px; }
.og-facts dd { font-weight: 700; min-width: 0; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; overflow-wrap: anywhere; }
.og-facts dt:last-of-type, .og-facts dd:last-of-type { border-bottom: none; }
.og-facts .big { font-family: var(--fdisplay); font-size: 17px; font-weight: 800; }
.og-facts .sub { color: var(--muted); font-weight: 600; font-size: 11.5px; }
.og-mono { font-family: ui-monospace, Consolas, monospace; font-size: 11.5px; color: var(--muted); direction: ltr; unicode-bidi: isolate; overflow-wrap: anywhere; }
.og-rate { display: flex; align-items: center; gap: 8px; width: 100%; }
.og-rate .bar { flex: 1; height: 6px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border-soft); overflow: hidden; max-width: 160px; }
.og-rate .bar i { display: block; height: 100%; background: var(--good); }
.og-err { color: var(--crit); font-weight: 600; font-size: 11.5px; }
.og-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 12px 18px; border-top: 1px solid var(--border-soft); background: var(--surface-2); }
.og-foot .sp { margin-inline-start: auto; }
.og-form { display: flex; flex-direction: column; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border-soft); }
.og-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.og-row .inp { flex: 1 1 170px; min-width: 0; }
.og-row .inp.ltr { direction: ltr; text-align: left; }
.og-field { display: flex; flex-direction: column; gap: 4px; flex: 1 1 200px; min-width: 0; font-size: 11.5px; font-weight: 700; color: var(--faint); }
.og-field .inp { width: 100%; min-width: 0; direction: ltr; text-align: left; }
.og-res { font-size: 12px; font-weight: 700; border-radius: 9px; padding: 8px 11px; border: 1px solid; overflow-wrap: anywhere; }
.og-res.ok { background: var(--good-bg); border-color: var(--good-line); color: var(--good); }
.og-res.bad { background: var(--crit-bg); border-color: var(--crit-line); color: var(--crit); }
.og-res.wait { background: var(--surface-2); border-color: var(--border); color: var(--muted); }
.og-res .og-mono { color: inherit; opacity: .8; }
.og-hint { font-size: 11px; color: var(--faint); font-weight: 600; }
.og-copy { display: flex; align-items: center; gap: 6px; min-width: 0; width: 100%; }
.og-copy .og-mono { flex: 1; min-width: 0; background: var(--surface-2); border: 1px solid var(--border-soft); border-radius: 7px; padding: 4px 8px; }

/* منتقي اسم المُرسِل */
.og-picker { position: relative; width: 100%; }
.og-picker-btn { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 6px 10px; font: inherit; font-weight: 800; font-size: 13px; color: inherit; cursor: pointer; }
.og-picker-btn:hover:not(:disabled) { border-color: var(--primary); }
.og-picker-btn:disabled { cursor: default; }
.og-picker-btn svg { width: 12px; height: 12px; color: var(--faint); }
.og-picker-list { position: absolute; top: calc(100% + 4px); inset-inline: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 11px; box-shadow: var(--shadow-lg, var(--shadow)); z-index: 15; padding: 5px; max-height: 320px; overflow-y: auto; }
.og-opt { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 9px; border-radius: 8px; background: none; border: none; text-align: right; font: inherit; font-size: 13px; font-weight: 700; color: inherit; cursor: pointer; }
.og-opt:hover:not(:disabled) { background: var(--surface-2); }
.og-opt:disabled { cursor: not-allowed; color: var(--faint); }
.og-opt .tags { margin-inline-start: auto; display: flex; gap: 4px; flex-wrap: wrap; }
.og-opt .ck { width: 14px; color: var(--primary); flex: 0 0 auto; }
.og-sep { font-size: 10.5px; color: var(--faint); font-weight: 800; padding: 7px 9px 3px; border-top: 1px solid var(--border-soft); margin-top: 4px; }
.og-sender-note { font-size: 11.5px; color: var(--warn); font-weight: 700; width: 100%; }

/* معاينة الرسالة */
.og-preview { margin-top: 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border-soft); padding: 10px 12px; }
.og-preview .pv-h { font-size: 10.5px; color: var(--faint); font-weight: 800; margin-bottom: 6px; }
.og-bubble { max-width: 330px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 8px 11px; font-size: 12.5px; line-height: 1.7; white-space: pre-line; }
.og-bubble .from { font-size: 11px; font-weight: 800; color: var(--og-sms); direction: ltr; unicode-bidi: isolate; white-space: normal; }
.og-bubble.wa .from { color: var(--og-wa); }
.og-bubble .copy { margin-top: 7px; border-top: 1px solid var(--border-soft); padding-top: 6px; text-align: center; font-weight: 800; color: var(--og-sms); font-size: 12px; }

/* السجل */
.og-filters { display: flex; gap: 6px; flex-wrap: wrap; }
.og-chip { padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--glass); font: inherit; font-size: 12px; color: var(--muted); font-weight: 700; cursor: pointer; }
.og-chip.active { background: var(--surface-3); color: var(--text); border-color: color-mix(in srgb, var(--c-settings) 40%, transparent); }
.og-log tr.fb td:first-child { box-shadow: inset -3px 0 0 var(--warn); }
.og-via { display: block; font-size: 10.5px; color: var(--faint); font-weight: 600; margin-top: 2px; max-width: 260px; }
.og-chcell { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }

/* شريط الحفظ: ملتصق بأسفل المحتوى (لا يحسب عرض الشريط الجانبي) */
.og-savebar { position: sticky; bottom: 16px; z-index: 30; background: color-mix(in srgb, var(--surface-2) 92%, transparent); backdrop-filter: blur(12px); border: 1px solid var(--line-2); color: var(--text); border-radius: 14px; box-shadow: 0 20px 40px -16px rgba(0, 0, 0, .8); animation: og-in var(--t-slow) var(--spring) both; padding: 11px 14px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 16px; }
.og-savebar[hidden] { display: none; }
.og-savebar.crit { background: linear-gradient(100deg, var(--crit-bg), color-mix(in srgb, var(--surface-2) 92%, transparent) 70%); border-color: var(--crit-line); }
@keyframes og-in { from { transform: translateY(24px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .og-savebar { animation: none; } }
.og-savebar .msg { font-size: 13px; font-weight: 800; }
.og-savebar .chg { font-size: 11.5px; color: var(--muted); font-weight: 600; flex: 1 1 260px; min-width: 0; }
.og-savebar .btn { background: var(--glass); color: var(--text); border-color: var(--line-2); }
.og-savebar .btn.save { background: var(--brand-grad); color: #fff; border-color: transparent; box-shadow: 0 10px 24px -12px rgba(169, 127, 214, .8); }
.og-savebar.crit .btn.save { background: var(--crit); color: #1b0b12; }

/* نافذة التأكيد */
.og-dlg-back { position: fixed; inset: 0; background: rgba(10, 4, 18, .6); z-index: 80; display: grid; place-items: center; padding: 16px; }
.og-dlg-back[hidden] { display: none; }
.og-dlg { width: 100%; max-width: 460px; background: linear-gradient(180deg, var(--surface-2), var(--surface)); border: 1px solid var(--crit-line); border-radius: 16px; box-shadow: var(--shadow-lg, var(--shadow)); overflow: hidden; }
.og-dlg-h { background: var(--crit); color: #fff; padding: 14px 18px; display: flex; gap: 10px; align-items: center; }
.og-dlg-h svg { width: 22px; height: 22px; flex: 0 0 auto; }
.og-dlg-h h4 { margin: 0; font-family: var(--fdisplay); font-size: 16px; font-weight: 800; }
.og-dlg-b { padding: 16px 18px; font-size: 13px; line-height: 1.85; }
.og-dlg-b ul { margin: 8px 0 0; padding-inline-start: 18px; color: var(--muted); font-size: 12.5px; }
.og-dlg-f { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--border-soft); flex-wrap: wrap; }

@media (max-width: 1180px) { .og-modes { grid-template-columns: 1fr; } .og-grid { grid-template-columns: 1fr; } }
@media (max-width: 600px) {
  .og-facts { grid-template-columns: 1fr; }
  .og-facts dt { border-bottom: none; padding-bottom: 0; }
  .og-facts dd { padding-top: 2px; }
  .og-order { flex-direction: column; } .og-swap { align-self: flex-start; } .og-arrow { text-align: right; }
  .og-foot, .og-form { padding: 12px 14px; }
}
