/* ============================================================
   NFlow Tools — global styles
   Ported from the original PHP tool theme + layout additions
   (sidebar shell, header, footer, mobile drawer)
   ============================================================ */

:root {
  --brand: #208CCC;
  --brand-light: #2b9fdb;
  --brand-dark: #176ba0;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e5e9f0;
  --card: #ffffff;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background:
    radial-gradient(1200px 600px at 100% -10%, #e6f1fb 0%, rgba(230,241,251,0) 60%),
    radial-gradient(1000px 500px at -10% 0%, #eef6ff 0%, rgba(238,246,255,0) 55%),
    linear-gradient(180deg, #f7f9fc 0%, #eef2f7 100%);
  background-attachment: fixed;
  color: var(--ink);
  min-height: 100vh;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, .serif-heading { font-family: 'DM Serif Display', serif; letter-spacing: -0.01em; }
.body-serif { font-family: 'Source Serif 4', Georgia, serif; }

.text-brand { color: var(--brand); }
.border-brand { border-color: var(--brand); }
.bg-brand { background: var(--brand); }
.bg-brand:hover { background: var(--brand-light); }

/* ---------- Layout shell ---------- */

:root {
  --sidebar-w: 272px;
}

/* Slim mobile top bar. Hidden on desktop where the sidebar carries the brand. */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255,255,255,0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(6px);
  display: flex;
}
.site-header-inner {
  display: flex; align-items: center; gap: 14px;
  width: 100%; margin: 0 auto; padding: 10px 16px;
}
.site-header .brand-link { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; }
.site-header .brand-link img { height: 26px; width: auto; display: block; }
.menu-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 10px; cursor: pointer;
  border: 1px solid #d4dbe6; background: #fff; color: #334155;
}

.site-shell { display: flex; min-height: 100vh; }

/* ---------- Sidebar (full-height rail) ---------- */

.site-sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 70;
  width: var(--sidebar-w);
  background: #ffffff;
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.sidebar-brand {
  padding: 20px 20px 18px;
  border-bottom: 1px solid var(--line);
}
.sidebar-brand .sidebar-logo { display: block; text-decoration: none; }
.sidebar-brand .sidebar-logo img { height: 30px; width: auto; display: block; }

.sidebar-nav {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: 12px 12px 20px;
  scrollbar-width: thin;
}
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: #d5dde8; border-radius: 6px; }

.site-sidebar h4 {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.8px; color: #a3afbf; margin: 16px 0 5px 10px;
}
.sidebar-group:first-of-type h4 { margin-top: 6px; }
.sidebar-link {
  position: relative;
  display: flex; align-items: center; gap: 9px;
  padding: 7px 10px; border-radius: 9px;
  color: #475569; font-size: 13px; font-weight: 500;
  text-decoration: none; transition: background .13s, color .13s;
}
.sidebar-link:hover { background: #f0f5fa; color: #1e293b; }
.sidebar-link.active { background: rgba(32,140,204,0.1); color: var(--brand); font-weight: 600; }
.sidebar-link.active::before {
  content: ''; position: absolute; left: -12px; top: 6px; bottom: 6px;
  width: 3px; border-radius: 0 4px 4px 0; background: var(--brand);
}
.sidebar-link .lucide { width: 15px; height: 15px; stroke-width: 2; flex-shrink: 0; }
.sidebar-link-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-count {
  font-size: 10.5px; font-weight: 700; color: #94a3b8;
  background: #f1f5f9; border: 1px solid #e6ebf2;
  padding: 1px 7px; border-radius: 999px;
}
.sidebar-link#sidebarAllLink { margin-bottom: 4px; }

.sidebar-foot {
  border-top: 1px solid var(--line);
  padding: 12px 14px;
}
.sidebar-cta {
  display: flex; align-items: center; gap: 7px;
  font-size: 12px; color: #64748b; text-decoration: none; padding: 8px 10px;
  border-radius: 8px; transition: color .15s, background .15s;
}
.sidebar-cta:hover { color: var(--brand); background: #f0f5fa; }

.sidebar-close {
  position: absolute; top: 14px; right: 14px;
  width: 34px; height: 34px; border-radius: 9px;
  align-items: center; justify-content: center;
  border: 1px solid #d4dbe6; background: #fff; color: #475569; cursor: pointer;
}

/* ---------- Main column ---------- */

.site-main {
  flex: 1; min-width: 0;
  width: 100%;
  margin: 0 auto;
  max-width: 1180px;
  padding: 44px 28px 72px;
}

.page-toolbar {
  display: flex; align-items: center; gap: 14px;
  margin: -18px 0 30px;
}
.crumbs { display: flex; align-items: center; gap: 6px; min-width: 0; }
.crumbs a {
  color: #8a97a8; font-size: 12.5px; font-weight: 600; text-decoration: none;
  transition: color .15s;
}
.crumbs a:hover { color: var(--brand); }
.crumb-sep { display: inline-flex; color: #c2cbd8; }
.crumb-current {
  color: #475569; font-size: 12.5px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---------- Drawer (mobile) ---------- */

.drawer-backdrop {
  position: fixed; inset: 0; z-index: 60; display: none;
  background: rgba(15,23,42,0.35);
}
.drawer-backdrop.open { display: block; }

@media (min-width: 1024px) {
  .site-header { display: none; }
  .site-shell { margin-left: var(--sidebar-w); }
  .site-footer { margin-left: var(--sidebar-w); }
}

.site-footer {
  border-top: 1px solid var(--line);
  text-align: center; padding: 26px 16px 34px;
  color: #94a3b8; font-size: 13px;
}
.site-footer a { color: #64748b; text-decoration: none; transition: color .15s; }
.site-footer a:hover { color: var(--brand); }

@media (max-width: 1023px) {
  .site-sidebar {
    left: calc(-1 * var(--sidebar-w));
    top: 0; bottom: 0; height: 100%;
    width: var(--sidebar-w);
    box-shadow: 0 20px 50px rgba(15,23,42,0.2);
    transition: left .22s ease;
  }
  .site-sidebar.open { left: 0; }
  .site-main { padding: 34px 16px 56px; }
  .page-toolbar { margin-top: -8px; }
}

/* ---------- Cards ---------- */

.glass {
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: 0 1px 2px rgba(15,23,42,0.04), 0 10px 28px rgba(15,23,42,0.05);
  border-radius: 16px;
  transition: box-shadow .2s ease, transform .2s ease;
}
.glass:hover { box-shadow: 0 4px 10px rgba(15,23,42,0.06), 0 18px 40px rgba(15,23,42,0.08); }

.glass-light { background: #ffffff; border: 1px solid #eef2f7; border-radius: 14px; }

.result-card {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 1px 2px rgba(15,23,42,0.04);
}

.card-hover { transition: transform .18s ease, box-shadow .18s ease; }
.card-hover:hover { transform: translateY(-3px); box-shadow: 0 14px 38px rgba(15,23,42,0.1); }

/* ---------- Inputs ---------- */

.input-field {
  width: 100%;
  background: #ffffff;
  border: 1px solid #d4dbe6;
  border-radius: 10px;
  padding: 12px 16px;
  color: #0f172a;
  font-size: 14px;
  transition: border-color .15s, box-shadow .15s, background .15s;
  outline: none;
}
.input-field:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(32,140,204,0.15); }
.input-field::placeholder { color: #9aa6b6; }
textarea.input-field { resize: vertical; min-height: 110px; line-height: 1.6; }

select.input-field {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
  cursor: pointer;
}
select.input-field option { background: #ffffff; color: #0f172a; padding: 8px 10px; }
select.input-field optgroup { background: #f1f5f9; color: #64748b; }

input[type="range"] {
  height: 6px; border-radius: 999px; background: #d8dee7; outline: none; cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%;
  background: var(--brand); cursor: pointer; border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(15,23,42,0.25);
}
input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%; background: var(--brand);
  cursor: pointer; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(15,23,42,0.25);
}

.chart-container { position: relative; width: 100%; max-height: 320px; }
.chart-container canvas { max-height: 320px !important; }

/* ---------- Buttons ---------- */

.btn-primary {
  background: var(--brand);
  color: #fff;
  border: 1px solid var(--brand);
  border-radius: 10px;
  padding: 12px 26px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .1s, box-shadow .15s;
  box-shadow: 0 6px 16px rgba(32,140,204,0.25);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-primary:hover { background: var(--brand-light); border-color: var(--brand-light); transform: translateY(-1px); box-shadow: 0 10px 22px rgba(32,140,204,0.3); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: .65; cursor: not-allowed; }

.btn-ghost {
  background: #ffffff;
  color: #334155;
  border: 1px solid #d4dbe6;
  border-radius: 10px;
  padding: 12px 26px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-ghost:hover { background: #f1f5f9; border-color: #c2ccda; }

.label-text {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #64748b;
  margin-bottom: 6px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #64748b;
  font-size: 13px;
  transition: color .15s;
  text-decoration: none;
  margin-bottom: 22px;
  font-weight: 500;
}
.back-link:hover { color: var(--brand); }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 13px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(32,140,204,0.1);
  color: var(--brand);
  border: 1px solid rgba(32,140,204,0.18);
}

.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 15px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
}
.copy-btn:hover { background: var(--brand); color: #fff; border-color: var(--brand); }

.status-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.status-dot.green { background: #16a34a; }
.status-dot.red { background: #dc2626; }
.status-dot.yellow { background: #d97706; }

/* ---------- Reading content ---------- */

.content-section p { margin-bottom: 1.1rem; line-height: 1.8; color: #475569; }
.content-section ul { margin-bottom: 1.1rem; padding-left: 0; }
.content-section li { margin-bottom: 0.6rem; padding-left: 1.6rem; position: relative; color: #475569; line-height: 1.65; list-style: none; }
.content-section li::before {
  content: ''; position: absolute; left: 0; top: 11px; width: 7px; height: 7px;
  border-radius: 50%; background: var(--brand); opacity: 0.55;
}
.content-section h3 { color: #0f172a; margin: 1.4rem 0 0.6rem; font-size: 1.15rem; }

/* Dark code blocks (kept dark for readability on light pages) */
.code-block {
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 14px;
  padding: 18px 20px;
  overflow-x: auto;
  font-family: 'SFMono-Regular', ui-monospace, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.7;
  border: 1px solid #1e293b;
  white-space: pre-wrap;
  word-break: break-all;
}
.code-block .tok-brand { color: #7dd3fc; }
.code-block .tok-green { color: #86efac; }
.code-block .tok-yellow { color: #fde68a; }
.code-block .tok-dim { color: #94a3b8; }

/* ---------- Extras ---------- */

.soft-divide { border-color: var(--line); }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c3cdda; border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: #aab7c6; }

summary::-webkit-details-marker { display: none; }
details > summary { cursor: pointer; }

.chev { transition: transform .2s; display: inline-flex; }
details[open] > summary .chev { transform: rotate(90deg); }

.spinner {
  display: inline-block; width: 18px; height: 18px;
  border: 2px solid rgba(15,23,42,0.15); border-top-color: #fff;
  border-radius: 50%; animation: spin 0.6s linear infinite;
}
.animate-spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.animate-fade-in { animation: fadeIn 0.25s ease-out; }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
.slide-up { animation: slideUp 0.4s ease forwards; }

/* Toast */
.nflow-toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 90;
  background: #fff; border: 1px solid var(--line);
  box-shadow: 0 10px 28px rgba(15,23,42,0.12);
  padding: 12px 18px; border-radius: 12px;
  font-size: 14px; color: #0f172a; max-width: 360px;
  animation: fadeIn 0.25s ease-out;
}

@media print {
  .site-header, .site-sidebar, .site-footer, .menu-toggle { display: none; }
  .site-main { padding: 0; }
}
