/* ==========================================================================
   KanMail Help Center — self-contained styles
   Dark theme mirrors the app palette (frontend/css/styles.css :root tokens).
   No external dependencies. Icons are inline SVG / emoji, fonts are system.
   ========================================================================== */

:root {
  /* Core palette — copied from the app so the help center matches the UI. */
  --primary:        #3b82f6;
  --primary-dark:   #2563eb;
  --accent:         #6366f1;
  --success:        #22c55e;
  --warning:        #f59e0b;
  --danger:         #ef4444;
  --ok:             #34d399;

  --bg-deep:        #0f172a;  /* chrome / sticky bars  */
  --bg-dark:        #1e293b;  /* page background       */
  --bg-card:        #334155;  /* panels / cards        */
  --bg-lane:        #253247;  /* wells, code blocks    */
  --bg-light:       #475569;  /* hover / chips         */

  --text-primary:   #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted:     #9aa7b4;
  --border-color:   #3f5168;

  --shadow:         0 4px 6px -1px rgba(0, 0, 0, .3);
  --shadow-lg:      0 12px 30px -6px rgba(0, 0, 0, .55);

  --radius-md:      8px;
  --radius-lg:      12px;
  --r-pill:         999px;

  --sidebar-w:      260px;
  --header-h:       56px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-primary);
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(99, 102, 241, .12), transparent 60%),
    radial-gradient(900px 500px at -10% 10%, rgba(59, 130, 246, .10), transparent 55%),
    var(--bg-dark);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ----------------------------------------------------------- Top bar ----- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 18px;
  background: rgba(15, 23, 42, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-color);
}
.topbar .logo { display: flex; align-items: center; gap: 10px; }
.topbar .logo img { height: 30px; width: auto; display: block; }
.topbar .logo .tag {
  font-weight: 600;
  letter-spacing: .3px;
  color: var(--text-secondary);
  font-size: .95rem;
  padding-left: 12px;
  border-left: 1px solid var(--border-color);
}
.topbar .spacer { flex: 1; }
.topbar .back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: var(--radius-md);
  background: var(--primary);
  color: #fff;
  font-size: .85rem;
  font-weight: 600;
}
.topbar .back-link:hover { background: var(--primary-dark); text-decoration: none; }

/* mobile menu toggle (hidden on desktop) */
.menu-toggle {
  display: none;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: var(--radius-md);
  padding: 7px 11px;
  font-size: 1rem;
  cursor: pointer;
}

/* ----------------------------------------------------------- Layout ------ */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  align-items: start;
  max-width: 1180px;
  margin: 0 auto;
}

/* --------------------------------------------------------- Sidebar ------- */
.sidebar {
  position: sticky;
  top: var(--header-h);
  align-self: start;
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 18px 12px 40px;
  border-right: 1px solid var(--border-color);
}
.search-box { position: relative; margin: 4px 6px 16px; }
.search-box input {
  width: 100%;
  padding: 9px 12px 9px 34px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-deep);
  color: var(--text-primary);
  font-size: .9rem;
}
.search-box input:focus { outline: none; border-color: var(--primary); }
.search-box .ico {
  position: absolute;
  left: 11px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: .85rem;
}

.nav-group { margin-bottom: 18px; }
.nav-group > .nav-group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 4px 10px;
  margin-bottom: 4px;
}
.nav-group a {
  display: block;
  padding: 7px 12px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: .9rem;
  border-left: 2px solid transparent;
}
.nav-group a:hover { background: var(--bg-card); color: var(--text-primary); text-decoration: none; }
.nav-group a.active {
  background: rgba(59, 130, 246, .14);
  color: var(--text-primary);
  border-left-color: var(--primary);
}

/* --------------------------------------------------------- Content ------- */
.content {
  padding: 28px 40px 80px;
  min-width: 0;
}
.hero {
  background: linear-gradient(135deg, rgba(59,130,246,.18), rgba(99,102,241,.12));
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 28px 30px;
  margin-bottom: 30px;
  box-shadow: var(--shadow);
}
.hero h1 { margin: 0 0 6px; font-size: 1.9rem; letter-spacing: -.01em; }
.hero p  { margin: 0; color: var(--text-secondary); max-width: 60ch; }

/* tab chips (User / Admin / FAQ) */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 28px;
  position: sticky;
  top: var(--header-h);
  z-index: 20;
  padding: 12px 0;
  background: linear-gradient(var(--bg-dark) 70%, transparent);
}
.tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.tab:hover { color: var(--text-primary); }
.tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* section panels (one per tab) */
.panel { display: none; }
.panel.active { display: block; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

section[id] { scroll-margin-top: calc(var(--header-h) + 70px); }

.content h2 {
  font-size: 1.45rem;
  margin: 38px 0 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}
.content h2:first-of-type { margin-top: 6px; }
.content h3 { font-size: 1.12rem; margin: 26px 0 8px; color: var(--text-primary); }
.content p, .content li { color: #d7e0ea; }
.content ul, .content ol { padding-left: 22px; }
.content li { margin: 4px 0; }
.lead { color: var(--text-secondary); font-size: 1.02rem; }

/* inline + block code */
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .85em;
  background: var(--bg-lane);
  border: 1px solid var(--border-color);
  border-radius: 5px;
  padding: 1px 6px;
  color: #e2e8f0;
}
pre {
  background: var(--bg-deep);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  overflow-x: auto;
  font-size: .85rem;
  line-height: 1.5;
}
pre code { background: none; border: none; padding: 0; }

/* kbd */
kbd {
  font-family: ui-monospace, monospace;
  font-size: .8em;
  background: var(--bg-light);
  border: 1px solid var(--border-color);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 6px;
}

/* cards / callouts */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  margin: 16px 0;
  box-shadow: var(--shadow);
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
  margin: 16px 0;
}
.grid .card { margin: 0; }
.card h3 { margin-top: 0; }

.callout {
  border-radius: var(--radius-md);
  padding: 13px 16px 13px 18px;
  margin: 16px 0;
  border-left: 4px solid var(--primary);
  background: rgba(59, 130, 246, .10);
  font-size: .94rem;
}
.callout.tip    { border-left-color: var(--success); background: rgba(34,197,94,.10); }
.callout.warn   { border-left-color: var(--warning); background: rgba(245,158,11,.10); }
.callout.danger { border-left-color: var(--danger);  background: rgba(239,68,68,.10); }
.callout strong { color: var(--text-primary); }

/* lane chips */
.lanes { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.lane-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 13px;
  border-radius: var(--r-pill);
  font-size: .82rem;
  font-weight: 600;
  background: var(--bg-lane);
  border: 1px solid var(--border-color);
}
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

/* status pipeline */
.pipeline { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 14px 0; }
.pill {
  display: inline-block;
  padding: 4px 13px;
  border-radius: var(--r-pill);
  font-size: .8rem;
  font-weight: 600;
  background: var(--bg-lane);
  border: 1px solid var(--border-color);
}
.pill.paid { background: rgba(52,211,153,.16); border-color: rgba(52,211,153,.5); color: var(--ok); }
.pipeline .arrow { color: var(--text-muted); font-weight: 700; }

/* tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: .9rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border-color); vertical-align: top; }
th { background: var(--bg-deep); font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-secondary); }
tr:last-child td { border-bottom: none; }
td code { white-space: nowrap; }

/* numbered steps */
ol.steps { counter-reset: step; list-style: none; padding-left: 0; }
ol.steps > li {
  position: relative;
  padding: 4px 0 14px 44px;
  margin: 0;
}
ol.steps > li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: 0; top: 2px;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: .85rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
ol.steps > li:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 13px; top: 32px; bottom: 4px;
  width: 2px;
  background: var(--border-color);
}

/* FAQ accordion */
.faq details {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin: 10px 0;
  overflow: hidden;
}
.faq summary {
  cursor: pointer;
  padding: 14px 18px;
  font-weight: 600;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
  user-select: none;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::before {
  content: "+";
  color: var(--primary);
  font-weight: 700;
  font-size: 1.2rem;
  width: 16px;
  flex: 0 0 16px;
  text-align: center;
}
.faq details[open] summary::before { content: "\2212"; } /* minus */
.faq details[open] summary { border-bottom: 1px solid var(--border-color); }
.faq .answer { padding: 14px 18px 16px; color: #d7e0ea; }
.faq .answer p:first-child { margin-top: 0; }
.faq .answer p:last-child { margin-bottom: 0; }

mark {
  background: rgba(245, 158, 11, .35);
  color: var(--text-primary);
  border-radius: 3px;
  padding: 0 2px;
}

/* "no results" notice for search */
.no-results {
  display: none;
  padding: 18px;
  color: var(--text-secondary);
  font-style: italic;
}

footer.help-footer {
  border-top: 1px solid var(--border-color);
  margin-top: 50px;
  padding-top: 18px;
  color: var(--text-muted);
  font-size: .82rem;
}

/* --------------------------------------------------------- Responsive ---- */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .menu-toggle { display: inline-flex; align-items: center; }
  .sidebar {
    position: fixed;
    top: var(--header-h);
    left: 0;
    width: min(86vw, var(--sidebar-w));
    height: calc(100vh - var(--header-h));
    background: var(--bg-deep);
    border-right: 1px solid var(--border-color);
    transform: translateX(-105%);
    transition: transform .22s ease;
    z-index: 40;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: none; }
  .content { padding: 20px 18px 70px; }
  .tabs { top: var(--header-h); }
  .scrim {
    display: none;
    position: fixed;
    inset: var(--header-h) 0 0 0;
    background: rgba(0,0,0,.5);
    z-index: 35;
  }
  .scrim.show { display: block; }
}
@media (max-width: 560px) {
  .topbar .logo .tag { display: none; }
  .hero h1 { font-size: 1.5rem; }
  .content h2 { font-size: 1.25rem; }
  .tab { padding: 8px 14px; font-size: .85rem; }
}
