/* ============================================================================
   settings.css — redesigned admin Settings tab (left sidebar + clean cards).
   Everything is scoped under #tab-settings and uses sx- prefixed classes so it
   cannot collide with the rest of admin.css. Paired with settings.js (the
   sidebar switcher) and the #tab-settings markup in admin.html. The data logic
   (loadSettings/saveSettings/etc.) still lives in admin.js and is reused by ID.
   ========================================================================== */

#tab-settings .sx-wrap{max-width:1160px;margin:0 auto;
  --sx-brand:#0a2540; --sx-accent:#2f6bff; --sx-black:#111318;
  --sx-ink:#101a2b; --sx-ink2:#54607a; --sx-faint:#8a94a6;
  --sx-surface:#ffffff; --sx-surface2:#f6f8fc; --sx-surface3:#eef2f8;
  --sx-border:#e4e9f1; --sx-border2:#d7deea;
  --sx-good:#16a34a; --sx-req:#c0392b;
  --sx-shadow-sm:0 1px 2px rgba(16,32,64,.05);
  --sx-shadow:0 1px 3px rgba(16,32,64,.06),0 10px 24px rgba(16,32,64,.05);
  color:var(--sx-ink);font-size:14px;line-height:1.5;}
#tab-settings .sx-wrap *{box-sizing:border-box}

/* ── setup gate (JS renders the list; we only restyle) ── */
#tab-settings .setup-gate-banner{background:var(--sx-surface);border:1px solid var(--sx-border);
  border-radius:12px;box-shadow:var(--sx-shadow-sm);padding:18px 20px;margin:0 0 18px}
#tab-settings .setup-gate-top{display:flex;align-items:center;justify-content:space-between;gap:16px;flex-wrap:wrap}
#tab-settings .setup-gate-top strong{font-size:15px;font-weight:700;letter-spacing:-.01em;color:var(--sx-ink)}
#tab-settings .setup-gate-progress{display:flex;align-items:center;gap:12px}
#tab-settings #setupGateCount{font-size:12.5px;color:var(--sx-ink2);font-weight:600;white-space:nowrap}
#tab-settings .setup-gate-bar{width:120px;height:7px;border-radius:20px;background:var(--sx-surface3);overflow:hidden}
#tab-settings .setup-gate-bar i{display:block;height:100%;background:var(--sx-good);border-radius:20px;transition:width .3s ease}
#tab-settings .setup-gate-sub{margin:8px 0 0;font-size:12.5px;color:var(--sx-ink2)}
#tab-settings .setup-gate-list{list-style:none;margin:14px 0 0;padding:0;display:flex;flex-wrap:wrap;gap:10px 28px}
#tab-settings .setup-gate-list li{display:flex;align-items:center;gap:9px;font-size:13px;color:var(--sx-ink);white-space:nowrap}
#tab-settings .setup-gate-list li:not(.done){color:var(--sx-ink2)}
#tab-settings .setup-gate-list .gate-check{display:inline-flex;width:18px;height:18px;flex:0 0 auto;color:var(--sx-faint)}
#tab-settings .setup-gate-list li.done .gate-check{color:var(--sx-good)}
#tab-settings .setup-gate-list .gate-check svg{width:18px;height:18px;stroke:currentColor;fill:none}
#tab-settings .setup-gate-list .gate-detail{color:var(--sx-accent);font-weight:600}

/* ── shell: sidebar + content ── */
#tab-settings .sx-shell{display:grid;grid-template-columns:230px 1fr;gap:20px;align-items:start}
#tab-settings .sx-nav{position:sticky;top:14px;background:var(--sx-surface);border:1px solid var(--sx-border);
  border-radius:12px;box-shadow:var(--sx-shadow-sm);padding:8px;display:flex;flex-direction:column;gap:2px}
#tab-settings .sx-navbtn{display:flex;align-items:center;gap:11px;width:100%;text-align:left;cursor:pointer;
  border:0;background:transparent;color:var(--sx-ink2);font-size:13.5px;font-weight:550;font-family:inherit;
  padding:10px 12px;border-radius:9px;transition:background .12s,color .12s}
#tab-settings .sx-navbtn .sx-ni{display:inline-flex;width:18px;height:18px;flex:0 0 auto;color:var(--sx-ink);transition:color .12s}
#tab-settings .sx-navbtn .sx-ni svg{width:18px;height:18px;stroke:currentColor;fill:none}
#tab-settings .sx-navbtn:hover{background:var(--sx-surface2);color:var(--sx-ink)}
#tab-settings .sx-navbtn.on{background:var(--sx-black);color:#fff}
#tab-settings .sx-navbtn.on .sx-ni{color:#fff}
#tab-settings .sx-sep{height:1px;background:var(--sx-border);margin:6px 8px}

#tab-settings .sx-content{min-width:0;display:flex;flex-direction:column;gap:16px;padding-bottom:12px}
#tab-settings .sx-pane{display:none}
#tab-settings .sx-pane.on{display:flex;flex-direction:column;gap:16px}

/* ── cards (clean, no dark bars) ── */
#tab-settings .sx-card{background:var(--sx-surface);border:1px solid var(--sx-border);border-radius:12px;
  box-shadow:var(--sx-shadow-sm);overflow:hidden}
#tab-settings .sx-card-h{display:flex;align-items:flex-start;gap:12px;padding:16px 18px 14px;border-bottom:1px solid var(--sx-border)}
#tab-settings .sx-card-h .sx-hi{width:34px;height:34px;flex:0 0 auto;border-radius:9px;background:var(--sx-surface3);
  color:var(--sx-ink);display:grid;place-items:center}
#tab-settings .sx-card-h .sx-hi svg{width:17px;height:17px;stroke:currentColor;fill:none}
#tab-settings .sx-card-h h3{margin:0!important;padding:0!important;border:0!important;font-size:14.5px!important;
  font-weight:680!important;letter-spacing:-.01em;color:var(--sx-ink)!important;text-transform:none!important}
#tab-settings .sx-card-h p{margin:3px 0 0!important;font-size:12.5px!important;color:var(--sx-ink2)!important;line-height:1.45;font-weight:400!important}
#tab-settings .sx-card-b{padding:18px}

/* ── fields ── */
#tab-settings .sx-grid{display:grid;grid-template-columns:1fr 1fr;gap:14px 16px}
#tab-settings .sx-f{display:flex;flex-direction:column;gap:6px;min-width:0}
#tab-settings .sx-f.full{grid-column:1/-1}
#tab-settings .sx-f label{font-size:12px;font-weight:600;color:var(--sx-ink2)}
#tab-settings .sx-f .req{color:var(--sx-req)}
#tab-settings .sx-in{width:100%;height:40px;border:1px solid var(--sx-border2);border-radius:9px;background:var(--sx-surface);
  padding:0 12px;font-size:14px;color:var(--sx-ink);font-family:inherit;transition:border-color .12s,box-shadow .12s}
#tab-settings textarea.sx-in{height:auto;padding:10px 12px;resize:vertical;line-height:1.5}
#tab-settings select.sx-in{cursor:pointer}
#tab-settings .sx-in:focus{outline:none;border-color:var(--sx-accent);box-shadow:0 0 0 3px rgba(47,107,255,.14)}
#tab-settings .sx-in::placeholder{color:var(--sx-faint)}
#tab-settings .sx-in[readonly]{background:var(--sx-surface3);color:var(--sx-ink2)}
#tab-settings .sx-hint{font-size:11.5px;color:var(--sx-faint);line-height:1.45}
#tab-settings .sx-hint b{color:var(--sx-ink2);font-weight:650}
#tab-settings .sx-hint a{color:var(--sx-accent);text-decoration:none}

/* ── buttons ── */
#tab-settings .sx-btn{height:38px;padding:0 16px;border-radius:9px;border:1px solid transparent;font-size:13.5px;
  font-weight:640;cursor:pointer;display:inline-flex;align-items:center;gap:7px;font-family:inherit;transition:.12s}
#tab-settings .sx-btn svg{width:15px;height:15px;stroke:currentColor;fill:none}
#tab-settings .sx-btn-primary{background:var(--sx-black);color:#fff}
#tab-settings .sx-btn-primary:hover{background:#292d37}
#tab-settings .sx-btn-primary:disabled{background:var(--sx-border2);color:#fff;cursor:not-allowed}
#tab-settings .sx-btn-ghost{background:var(--sx-surface);border-color:var(--sx-border2);color:var(--sx-ink)}
#tab-settings .sx-btn-ghost:hover{background:var(--sx-surface2)}
#tab-settings .sx-btn-sm{height:32px;padding:0 12px;font-size:12.5px}

/* ── notes / lock / swatch / uploads / prefix ── */
#tab-settings .sx-note{display:flex;gap:9px;align-items:flex-start;background:#fbf3e3;border:1px solid #f3dcb4;
  border-radius:10px;padding:11px 13px;font-size:12.5px;color:#8a5a12;line-height:1.5}
#tab-settings .sx-note.info{background:#eef4ff;border-color:#d3e0fb;color:#2b4a86}
#tab-settings .sx-note .sx-ni{display:inline-flex;width:16px;height:16px;flex:0 0 auto;margin-top:1px}
#tab-settings .sx-note .sx-ni svg{width:16px;height:16px;stroke:currentColor;fill:none}
#tab-settings .sx-lock{font-size:12px;color:var(--sx-ink2);background:var(--sx-surface2);border:1px dashed var(--sx-border2);
  border-radius:9px;padding:10px 12px;margin-top:12px}
#tab-settings .sx-swatch{display:flex;align-items:center;gap:10px}
#tab-settings .sx-swatch input[type=color]{width:44px;height:40px;padding:0;border:1px solid var(--sx-border2);border-radius:9px;background:none;cursor:pointer}
#tab-settings .sx-up{display:flex;gap:14px;align-items:center;flex-wrap:wrap}
#tab-settings .sx-up .profile-preview,
#tab-settings .sx-up .company-logo-preview{width:64px;height:64px;border-radius:12px;border:1px dashed var(--sx-border2);
  background:var(--sx-surface2);display:grid;place-items:center;color:var(--sx-faint);font-size:11px;text-align:center;padding:6px;font-weight:600;overflow:hidden}
#tab-settings .sx-up .company-logo-preview{width:120px}
#tab-settings .sx-up .profile-preview img,#tab-settings .sx-up .company-logo-preview img{width:100%;height:100%;object-fit:cover}
#tab-settings .sx-up .image-upload-actions{display:flex;flex-direction:column;gap:6px}
#tab-settings .sx-up .upload-button{display:inline-flex;align-items:center;height:32px;padding:0 12px;border-radius:9px;
  border:1px solid var(--sx-border2);background:var(--sx-surface);color:var(--sx-ink);font-size:12.5px;font-weight:640;cursor:pointer;width:max-content}
#tab-settings .sx-up .upload-button:hover{background:var(--sx-surface2)}
#tab-settings .sx-up .upload-note{font-size:11.5px;color:var(--sx-faint)}
#tab-settings .sx-up .upload-status{font-size:11.5px;color:var(--sx-good)}
#tab-settings .sx-prefixprev{height:40px;display:inline-flex;align-items:center;padding:0 16px;border:1px solid var(--sx-border2);
  border-radius:9px;background:var(--sx-surface2);font-family:ui-monospace,Menlo,monospace;font-weight:700;letter-spacing:1px;color:var(--sx-brand)}

/* ── email: segmented provider toggle + steps ── */
#tab-settings .sx-seg{display:inline-flex;flex-wrap:wrap;background:var(--sx-surface2);border:1px solid var(--sx-border2);border-radius:10px;padding:3px;gap:3px}
#tab-settings .sx-segbtn{border:0;background:transparent;cursor:pointer;font-size:13px;font-weight:600;color:var(--sx-ink2);padding:8px 14px;border-radius:7px;transition:.12s;font-family:inherit}
#tab-settings .sx-segbtn.on{background:var(--sx-black);color:#fff;box-shadow:var(--sx-shadow-sm)}
#tab-settings .sx-estep{border:1px solid var(--sx-border);border-radius:11px;overflow:hidden;background:var(--sx-surface)}
#tab-settings .sx-estep + .sx-estep{margin-top:12px}
#tab-settings .sx-estep-h{display:flex;align-items:center;gap:11px;padding:13px 15px;background:var(--sx-surface2);border-bottom:1px solid var(--sx-border)}
#tab-settings .sx-estep-h .sx-n{width:24px;height:24px;flex:0 0 auto;border-radius:50%;background:var(--sx-brand);color:#fff;font-size:12px;font-weight:700;display:grid;place-items:center}
#tab-settings .sx-estep-h h4{margin:0;font-size:13.5px;font-weight:680;color:var(--sx-ink)}
#tab-settings .sx-estep-h p{margin:1px 0 0;font-size:12px;color:var(--sx-ink2)}
#tab-settings .sx-estep-b{padding:16px}

/* ── status line (test connection, prefix, etc.) ── */
#tab-settings .sx-status{font-size:12.5px;font-weight:600;display:inline-flex;align-items:center;gap:6px}

/* ── notifications toggle rows ── */
#tab-settings .sx-switchrow{display:flex;align-items:center;justify-content:space-between;gap:14px;padding:12px 0;border-top:1px solid var(--sx-border)}
#tab-settings .sx-switchrow:first-child{border-top:0}
#tab-settings .sx-switchrow .t{font-size:13.5px;font-weight:600;color:var(--sx-ink)}
#tab-settings .sx-switchrow .s{font-size:12px;color:var(--sx-ink2);margin-top:2px}

/* ── Quill (Terms editor) restyle to match ── */
#tab-settings .ql-toolbar.ql-snow{border-color:var(--sx-border2);border-top-left-radius:10px;border-top-right-radius:10px;background:var(--sx-surface2);padding:7px 8px}
#tab-settings .ql-container.ql-snow{border-color:var(--sx-border2);border-bottom-left-radius:10px;border-bottom-right-radius:10px;font-family:inherit}
#tab-settings .ql-editor{min-height:200px;font-size:13.5px;line-height:1.65;color:var(--sx-ink)}
#tab-settings .ql-editor.ql-blank::before{color:var(--sx-faint);font-style:normal;left:16px;right:16px}
#tab-settings .terms-drag-handle{display:flex;align-items:center;justify-content:center;gap:8px;padding:7px;
  border:1px solid var(--sx-border2);border-top:0;border-bottom-left-radius:10px;border-bottom-right-radius:10px;
  color:var(--sx-faint);font-size:11px;background:var(--sx-surface2);user-select:none;cursor:ns-resize}
#tab-settings .terms-drag-handle:hover{background:var(--sx-surface3);color:var(--sx-ink2)}
#tab-settings .terms-drag-grip{width:22px;height:0;border-top:2px solid currentColor;border-bottom:2px solid currentColor;height:6px;opacity:.5}
#tab-settings .terms-drag-label{letter-spacing:.02em}

/* ── sticky save bar ── */
#tab-settings .sx-savebar{position:sticky;bottom:0;margin-top:4px;background:rgba(255,255,255,.9);backdrop-filter:blur(8px);
  border:1px solid var(--sx-border);border-radius:12px;box-shadow:var(--sx-shadow);padding:11px 14px;display:flex;align-items:center;gap:12px;flex-wrap:wrap}
#tab-settings .sx-savemsg{font-size:12.5px;color:var(--sx-ink2)}
#tab-settings .sx-savemsg b{color:var(--sx-req)}
#tab-settings.sx-no-save .sx-savebar{display:none}

/* ── responsive ──────────────────────────────────────────────────────────
   Phones use a ~410–490px virtual viewport (the zoom hack in admin.html), so
   these breakpoints DO fire on real devices. The sidebar collapses to a full-
   width menu on top of the content; min-width:0 lets the single grid track
   shrink to the screen so nothing overflows sideways. */
@media (max-width:860px){
  #tab-settings .sx-wrap{max-width:100%}
  #tab-settings .sx-shell{grid-template-columns:1fr;gap:14px}
  /* Nav: a 2-column menu — every section stays visible (no off-screen scroll)
     and the track can shrink because the item is allowed to go below its
     content's intrinsic min-width. */
  #tab-settings .sx-nav{position:static;display:grid;grid-template-columns:1fr 1fr;gap:6px;min-width:0}
  #tab-settings .sx-sep{display:none}
  #tab-settings .sx-navbtn{min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  #tab-settings .sx-grid{grid-template-columns:1fr}
  /* Tighten chrome a touch to give fields more room on a narrow screen. */
  #tab-settings .sx-card-h{padding:14px 15px 12px}
  #tab-settings .sx-card-b{padding:15px}
  #tab-settings .sx-estep-b{padding:14px}
  #tab-settings .sx-savebar{padding:10px 12px}
}
/* Very small phones: stack the nav to a single column so long labels
   ("Notifications") never crowd. */
@media (max-width:430px){
  #tab-settings .sx-nav{grid-template-columns:1fr}
}
