/* BabylonCare — صفحة الإعدادات: تنسيق موحّد (شريط التنقّل، البطاقات، إشعارات تيليجرام، الربط والـAPI).
   يُحمَّل بعد styles.css وقبل mobile.css. قيود CSP: لا style="" — كل شيء أصناف. */

/* ───────── التنقّل بين الأقسام على الهاتف والتابلت: شرائح مضغوطة فوق المحتوى (لا قائمة طويلة تدفع المحتوى للأسفل) ───────── */
@media (max-width: 900px) {
  .settings-page { gap: 12px; }
  .settings-nav { display: flex; flex-wrap: wrap; gap: 8px; padding: 14px; position: static; }
  .settings-nav h2 { flex: 1 0 100%; margin: 0 2px 2px; font-size: 17px; }
  .settings-group { display: contents; }
  .settings-group > small { display: none; }
  .sn { width: auto; flex: 0 0 auto; padding: 8px 13px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-2); font-size: 13px; line-height: 1.3; }
  .sn.is-active { border-color: var(--brand); background: var(--accent-soft); }
  .settings-body { padding: 18px 16px; border-radius: 24px; }
}

/* ───────── أقسام الإعدادات: عنوان ثم بطاقات متناسقة ───────── */
.settings-body h3 { display: flex; align-items: center; gap: 8px; }
.dl-section > .settings-block { border: 1px solid var(--line); border-radius: 22px; background: var(--surface-2); padding: 18px; margin-top: 16px; }
.dl-section > .settings-block > h4:first-child { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dl-section > .settings-block .modal-sub { line-height: 1.7; }

/* ───────── إشعارات تيليجرام: مربعات (بطاقة لكل نوع) ───────── */
.tg-kinds { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; align-items: start; }
.tg-kind { border: 1px solid var(--line); border-radius: 20px; background: var(--surface); transition: border-color .15s, box-shadow .15s; }
.tg-kind:hover { border-color: var(--line2, var(--line)); box-shadow: var(--shadow); }
.tg-kind[open] { grid-column: 1 / -1; border-color: var(--brand); }
.tg-kind summary { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px 12px; align-items: start; padding: 14px; cursor: pointer; list-style: none; font-weight: 400; }
.tg-kind summary::-webkit-details-marker { display: none; }
.tg-kind summary:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; border-radius: 20px; }
.tg-ic { width: 40px; height: 40px; border-radius: 14px; display: grid; place-items: center; background: var(--accent-soft); color: var(--brand); }
.tg-ic .ic { width: 20px; height: 20px; margin: 0; }
.tg-title { display: grid; gap: 3px; min-width: 0; }
.tg-title b { font-size: 14.5px; font-weight: 700; line-height: 1.4; overflow-wrap: anywhere; }
.tg-title small { color: var(--ink-soft); font-size: 12.5px; line-height: 1.5; }
.tg-foot { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 8px; border-top: 1px dashed var(--line-soft); font-size: 12px; }
.tg-route { color: var(--ink-faint); font-weight: 600; }
.tg-edit { color: var(--brand); font-weight: 700; }
.tg-edit::after { content: ' ▾'; }
.tg-kind[open] .tg-edit::after { content: ' ▴'; }
.tg-kind.is-off .tg-ic { background: var(--surface-3, var(--surface-2)); color: var(--ink-faint); }
.tg-kind.is-off .tg-title { opacity: .6; }
.tg-sw { display: inline-flex; cursor: pointer; padding: 2px; }
.tg-sw input { position: absolute; opacity: 0; width: 0; height: 0; }
.tg-sw-track { width: 40px; height: 23px; border-radius: 999px; background: var(--track-off); position: relative; transition: background .15s; }
.tg-sw-track::after { content: ''; position: absolute; top: 3px; inset-inline-start: 3px; width: 17px; height: 17px; border-radius: 50%; background: #fff; transition: transform .25s var(--ease-spring); box-shadow: 0 1px 3px rgba(0, 0, 0, .25); }
.tg-sw input:checked + .tg-sw-track { background: var(--ok, #16a34a); }
.tg-sw input:checked + .tg-sw-track::after { transform: translateX(-17px); }
.tg-sw input:focus-visible + .tg-sw-track { outline: 2px solid var(--brand); outline-offset: 2px; }
.tg-kind .tg-body { padding: 14px; border-top: 1px solid var(--line-soft); }
@media (max-width: 560px) { .tg-kinds { grid-template-columns: 1fr; } }

/* ───────── ربط المتجر + Webhook + API: بطاقات منسّقة ───────── */
.sl-settings { display: grid; gap: 12px; }
.sl-settings > * { margin: 0; }
.sl-state-chip { margin-inline-start: auto; padding: 2px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700; background: var(--surface-3, var(--line)); color: var(--ink-soft); }
.sl-state-chip.is-ok { background: var(--ok-bg); color: var(--ok); }
.sl-settings .sl-howto-line { font-size: 13px; line-height: 1.7; }
.sl-settings .sl-key-actions { gap: 8px; align-items: center; }
.sl-settings .sl-revoke { color: var(--danger); }
.sl-settings .sl-site { padding: 12px 14px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); }
.sl-settings .sl-opt { padding: 2px 0; }
.sl-settings .sl-ratings { border: 1px solid var(--line); border-radius: 18px; padding: 10px 14px; background: var(--surface); }
.sl-settings .sl-secret { background: var(--warn-bg); }
.sl-settings .sl-secret .btn { justify-self: start; }

.ig-block h4 { margin-bottom: 4px; }
.ig-grid { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.ig-card { background: var(--surface); border-radius: 20px; padding: 14px 16px; }
.ig-logos { display: inline-flex; gap: 4px; flex: none; }
.ig-logos img { width: 24px; height: 24px; }
@container (max-width: 520px) { .ig-grid { grid-template-columns: minmax(0, 1fr); } }
@container (min-width: 1040px) { .ig-grid { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); } }

#wh-form .form-foot, #ak-new { margin-top: 2px; }
.ak-scopes { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; margin: 8px 0; }
.ak-scope { border-radius: 14px; padding: 8px 10px; background: var(--surface); align-items: flex-start; line-height: 1.5; }
.ak-row { background: var(--surface); }
.dl-section .toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
@media (min-width: 721px) { .dl-section .toolbar > input[type=text] { flex: 1 1 200px; min-width: 0; } }
@media (max-width: 720px) {
  .dl-section > .settings-block { padding: 14px; border-radius: 20px; }
  .ak-scopes { grid-template-columns: 1fr; }
  .ig-grid { grid-template-columns: 1fr; }
}

/* المفاتيح داخل الإعدادات: «تشغيل» = أخضر (الأحمر يوحي بخطر) */
.settings-body .switch.is-on { border-color: var(--ok-line); background: var(--ok-bg); }
.settings-body .switch input:checked + .switch-track { background: var(--ok, #16a34a); }
.settings-body .switch.sl-mini.is-on { background: none; border: 0; }
.settings-body .switch-text { min-width: 0; }
.ig-head b { flex: 1 1 7rem; }
.ig-chip { margin-inline-start: 0; }

/* حقول الملفات والمقاطع المتفرقة */
.settings-body input[type=file] { max-width: 100%; font: inherit; font-size: 13px; color: var(--ink-soft); }
.settings-body input[type=file]::file-selector-button { font: inherit; font-weight: 700; margin-inline-end: 10px; padding: 7px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink); cursor: pointer; }
.settings-body .table-scroll { max-width: 100%; }
.settings-body .sl-settings .switch.sl-mini input:checked + .switch-track { background: var(--ok, #16a34a); }
