/* =====================================================================
   Sarasota Networks — Documentation Portal Stylesheet
   ===================================================================== */

:root {
  --bg:         #0f1117;
  --sidebar:    #13161f;
  --surface:    #1a1d27;
  --surface-2:  #1f2335;
  --border:     #252840;
  --border-lt:  #2e3250;
  --text:       #e2e5f0;
  --text-muted: #8b8fa8;
  --text-subtle:#4e5270;
  --blue:       #185FA5;
  --blue-lt:    #378ADD;
  --blue-dim:   rgba(55,138,221,.12);
  --teal:       #1D9E75;
  --teal-lt:    #25c490;
  --teal-dim:   rgba(29,158,117,.12);
  --amber:      #d4882a;
  --amber-lt:   #f0a535;
  --amber-dim:  rgba(212,136,42,.12);
  --red-lt:     #e05252;
  --red-dim:    rgba(224,82,82,.12);
  --radius:     8px;
  --radius-sm:  4px;
  --radius-lg:  14px;
  --shadow:     0 2px 12px rgba(0,0,0,.45);
  --shadow-lg:  0 8px 40px rgba(0,0,0,.65);
  --topbar-h:   60px;
  --sidebar-w:  234px;
  --content-max:760px;
  --font:       -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Inter', sans-serif;
  --font-mono:  'SFMono-Regular', 'Consolas', 'Liberation Mono', monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: var(--blue-lt); text-decoration: none; }
a:hover { color: var(--text); }

/* =====================================================================
   App chrome — topbar
   ===================================================================== */

.app-topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: var(--sidebar);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  z-index: 200;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: .95rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -.2px;
  flex-shrink: 0;
}
.topbar-brand-sub {
  color: var(--blue-lt);
  font-size: .85rem;
  font-weight: 600;
}

.topbar-spacer { flex: 1; }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

.topbar-clock {
  font-size: .8rem;
  color: var(--text-subtle);
  font-variant-numeric: tabular-nums;
}

.topbar-user {
  font-size: .82rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.topbar-btn {
  font-size: .8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
  text-decoration: none;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  transition: color .12s, background .12s;
}
.topbar-btn:hover { color: var(--text); background: var(--surface); border-color: var(--border); }

/* =====================================================================
   App chrome — sidebar
   ===================================================================== */

.app-sidebar {
  position: fixed;
  top: var(--topbar-h);
  left: 0;
  width: var(--sidebar-w);
  height: calc(100vh - var(--topbar-h));
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 20px 0 60px;
  z-index: 100;
}

.app-sidebar::-webkit-scrollbar { width: 4px; }
.app-sidebar::-webkit-scrollbar-track { background: transparent; }
.app-sidebar::-webkit-scrollbar-thumb { background: var(--border-lt); border-radius: 2px; }

.sidebar-section { padding: 0 12px 20px; }

.sidebar-label {
  font-size: .67rem;
  font-weight: 700;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--text-subtle);
  padding: 0 8px;
  margin-bottom: 4px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  font-size: .845rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: background .12s, color .12s;
}
.sidebar-link:hover { background: var(--surface-2); color: var(--text); }
.sidebar-link.active { background: var(--blue-dim); color: var(--blue-lt); font-weight: 500; }

.sidebar-back {
  font-size: .8rem;
  color: var(--text-subtle);
  padding: 6px 8px;
  margin-bottom: 4px;
}
.sidebar-back:hover { color: var(--text-muted); background: none; }

.sidebar-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0 8px 16px;
}

/* TOC sub-links (used inside guide TOC) */
.toc-link {
  display: block;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  font-size: .845rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: background .12s, color .12s;
}
.toc-link:hover { background: var(--surface-2); color: var(--text); }
.toc-link.active { background: var(--blue-dim); color: var(--blue-lt); font-weight: 500; }

.toc-sub {
  display: block;
  padding: 4px 8px 4px 22px;
  border-radius: var(--radius-sm);
  font-size: .8rem;
  color: var(--text-subtle);
  text-decoration: none;
  transition: background .12s, color .12s;
}
.toc-sub:hover { background: var(--surface-2); color: var(--text-muted); }
.toc-sub.active { color: var(--blue-lt); }

.toc-section { padding: 0 12px; margin-bottom: 16px; }
.toc-section-label {
  font-size: .67rem;
  font-weight: 700;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--text-subtle);
  padding: 0 8px;
  margin-bottom: 4px;
}

/* =====================================================================
   Page shell
   ===================================================================== */

.page-shell {
  margin-left: var(--sidebar-w);
  padding-top: var(--topbar-h);
  min-height: 100vh;
}

.main-content {
  padding: 44px 52px 100px;
}

/* Prose content width constraint */
.docs-body {
  max-width: var(--content-max);
}

/* =====================================================================
   Login / error pages (no sidebar)
   ===================================================================== */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border-lt);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  box-shadow: var(--shadow-lg);
}

.login-brand { margin-bottom: 28px; }

.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.login-tagline {
  font-size: .8rem;
  color: var(--text-subtle);
  margin: 0;
  padding-left: 38px;
}

.login-heading {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 20px;
}

.access-denied { text-align: center; }
.ad-icon {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: rgba(224,82,82,.1);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
  color: var(--red-lt);
}
.access-denied h2 { font-size: 1.1rem; font-weight: 700; margin-bottom: 10px; }
.access-denied p { font-size: .875rem; color: var(--text-muted); }

/* =====================================================================
   Buttons
   ===================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: background .12s, border-color .12s, color .12s;
  font-family: var(--font);
  line-height: 1.4;
  white-space: nowrap;
}
.btn-primary   { background: var(--blue); color: #fff; border-color: var(--blue); }
.btn-primary:hover { background: #1a6bbf; color: #fff; }
.btn-secondary { background: var(--surface-2); color: var(--text-muted); border-color: var(--border-lt); }
.btn-secondary:hover { color: var(--text); }
.btn-danger    { background: var(--red-dim); color: var(--red-lt); border-color: rgba(224,82,82,.35); }
.btn-danger:hover { background: rgba(224,82,82,.22); }
.btn-ghost     { background: none; color: var(--text-muted); border-color: transparent; }
.btn-ghost:hover { color: var(--text); background: var(--surface-2); }
.btn-sm        { padding: 5px 12px; font-size: .8rem; }
.btn-full      { width: 100%; justify-content: center; }

/* =====================================================================
   Forms
   ===================================================================== */

.form-group  { margin-bottom: 14px; }
.form-label  { display: block; font-size: .8rem; font-weight: 600; color: var(--text-muted); margin-bottom: 5px; letter-spacing: .2px; }
.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--border-lt);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: .875rem;
  font-family: var(--font);
  transition: border-color .12s, box-shadow .12s;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--blue-lt);
  box-shadow: 0 0 0 2px rgba(55,138,221,.15);
}
.form-textarea { resize: vertical; min-height: 72px; }
.form-hint { font-size: .775rem; color: var(--text-subtle); margin-top: 4px; }
.req { color: var(--red-lt); }

/* =====================================================================
   Alerts
   ===================================================================== */

.alert {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: .875rem;
  align-items: flex-start;
}
.alert-success { background: var(--teal-dim);  border: 1px solid rgba(29,158,117,.25); color: var(--teal-lt); }
.alert-error   { background: var(--red-dim);   border: 1px solid rgba(224,82,82,.25);  color: var(--red-lt);  }

/* =====================================================================
   Badges
   ===================================================================== */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: .73rem;
  font-weight: 600;
  white-space: nowrap;
  line-height: 1.4;
}
.badge-admin      { background: var(--blue-dim);         color: var(--blue-lt); }
.badge-technician { background: var(--blue-dim);         color: #7ec8f5; }
.badge-editor     { background: var(--blue-dim);         color: #7ec8f5; }
.badge-client     { background: var(--teal-dim);         color: var(--teal-lt); }
.badge-readonly   { background: var(--border);           color: var(--text-muted); }
.badge-inactive   { background: var(--border);           color: var(--text-subtle); }
.badge-public     { background: var(--teal-dim);         color: var(--teal-lt); }
.badge-private    { background: var(--border);           color: var(--text-subtle); }
.badge-link       { background: var(--blue-dim);         color: var(--blue-lt); }
.badge-file       { background: var(--amber-dim);        color: var(--amber-lt); }
.badge-active     { background: var(--teal-dim);         color: var(--teal-lt); }

/* =====================================================================
   Modals
   ===================================================================== */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0,0,0,.65);
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border-lt);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
}
.modal-title  { font-size: 1rem; font-weight: 700; }
.modal-close  { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 1.4rem; padding: 0; line-height: 1; }
.modal-close:hover { color: var(--text); }
.modal-body   { padding: 18px 20px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* =====================================================================
   Tables
   ===================================================================== */

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 24px;
}
.table-scroll { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
table thead th {
  text-align: left;
  padding: 8px 12px;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--text-subtle);
  border-bottom: 1px solid var(--border);
  background: var(--sidebar);
  white-space: nowrap;
}
table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  vertical-align: middle;
}
table tbody tr:last-child td { border-bottom: none; }
table tbody tr:hover { background: rgba(255,255,255,.02); }

.td-name { color: var(--text); font-weight: 500; }
.td-muted { color: var(--text-subtle); }
.td-right { text-align: right; }
.td-actions { white-space: nowrap; }
.td-sub { font-size: .78rem; color: var(--text-subtle); margin-top: 2px; }
.tr-inactive td { opacity: .45; }

.table-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.table-title { font-size: 1.25rem; font-weight: 700; letter-spacing: -.2px; }

/* =====================================================================
   Page header
   ===================================================================== */

.page-header { margin-bottom: 28px; }
.page-title  { font-size: 1.4rem; font-weight: 800; letter-spacing: -.3px; margin-bottom: 4px; }
.page-subtitle { font-size: .875rem; color: var(--text-muted); }

/* =====================================================================
   Document grid (documents.php)
   ===================================================================== */

.doc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.doc-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  transition: border-color .15s;
}
.doc-card:hover { border-color: var(--border-lt); }

.doc-card-icon {
  flex-shrink: 0;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: var(--blue-dim);
  border-radius: var(--radius-sm);
  color: var(--blue-lt);
}

.doc-card-body { flex: 1; min-width: 0; }
.doc-card-title { font-weight: 600; font-size: .9rem; color: var(--text); margin-bottom: 3px; }
.doc-card-desc  { font-size: .8rem; color: var(--text-muted); line-height: 1.5; }

.doc-badge-private {
  display: inline-block;
  font-size: .7rem;
  padding: 1px 7px;
  border-radius: 20px;
  background: var(--border);
  color: var(--text-subtle);
  margin-top: 5px;
}

.doc-card-action {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  font-size: .78rem;
  font-weight: 600;
  color: var(--blue-lt);
  text-decoration: none;
  white-space: nowrap;
  align-self: center;
  background: none;
  border: none;
  cursor: pointer;
}
.doc-card-action:hover { color: var(--text); }

/* Doc admin table */
.doc-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.doc-table th {
  text-align: left; padding: 8px 12px;
  font-size: .7rem; font-weight: 700; letter-spacing: .5px; text-transform: uppercase;
  color: var(--text-subtle); border-bottom: 1px solid var(--border);
  background: var(--sidebar);
}
.doc-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); color: var(--text-muted); vertical-align: middle; }
.doc-table tr:last-child td { border-bottom: none; }
.doc-table td:first-child { color: var(--text); }
.doc-table tr.inactive td { opacity: .45; }

.btn-reorder { background: none; border: 1px solid var(--border); color: var(--text-muted); cursor: pointer; border-radius: 3px; padding: 1px 5px; font-size: .75rem; }
.btn-reorder:hover { border-color: var(--blue-lt); color: var(--blue-lt); }
.btn-warning { background: var(--amber-dim); color: var(--amber); border: 1px solid rgba(212,136,42,.4); }
.btn-warning:hover { background: rgba(212,136,42,.25); }

/* =====================================================================
   Docs prose content
   ===================================================================== */

.docs-section {
  padding-top: 12px;
  margin-bottom: 56px;
  scroll-margin-top: calc(var(--topbar-h) + 20px);
}
.docs-section + .docs-section {
  border-top: 1px solid var(--border);
  padding-top: 48px;
}

h1.docs-h1 {
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: -.4px;
  line-height: 1.2;
  color: var(--text);
  margin-bottom: 12px;
}

h2.docs-h2 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -.2px;
  color: var(--text);
  margin: 32px 0 12px;
}

h3.docs-h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin: 24px 0 8px;
}

.docs-lead {
  font-size: 1.05rem;
  color: var(--text-muted);
  line-height: 1.7;
  margin-bottom: 24px;
}

p {
  color: var(--text-muted);
  line-height: 1.75;
  margin-bottom: 14px;
}
p:last-child { margin-bottom: 0; }

ul, ol {
  color: var(--text-muted);
  padding-left: 20px;
  margin-bottom: 14px;
  line-height: 1.75;
}
li { margin-bottom: 4px; }
li strong { color: var(--text); }

code {
  font-family: var(--font-mono);
  font-size: .825em;
  background: var(--surface-2);
  color: var(--teal-lt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px 6px;
}

pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  overflow-x: auto;
  margin-bottom: 16px;
  font-family: var(--font-mono);
  font-size: .85rem;
  line-height: 1.6;
  color: var(--text-muted);
}
pre code { background: none; border: none; padding: 0; color: inherit; font-size: inherit; }

.callout {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: .9rem;
  line-height: 1.6;
}
.callout-icon { flex-shrink: 0; margin-top: 2px; }
.callout-info    { background: var(--blue-dim);              border: 1px solid rgba(55,138,221,.25); color: var(--text-muted); }
.callout-info    .callout-icon { color: var(--blue-lt); }
.callout-tip     { background: var(--teal-dim);              border: 1px solid rgba(29,158,117,.25); color: var(--text-muted); }
.callout-tip     .callout-icon { color: var(--teal-lt); }
.callout-success { background: var(--teal-dim);              border: 1px solid rgba(29,158,117,.25); color: var(--text-muted); }
.callout-success .callout-icon { color: var(--teal-lt); }
.callout-warn    { background: var(--amber-dim);             border: 1px solid rgba(212,136,42,.25); color: var(--text-muted); }
.callout-warn    .callout-icon { color: var(--amber-lt); }
.callout p { margin: 0; color: inherit; }

.role-table { width: 100%; border-collapse: collapse; margin-bottom: 16px; font-size: .875rem; }
.role-table th {
  text-align: left; padding: 8px 12px;
  font-size: .7rem; font-weight: 700; letter-spacing: .5px; text-transform: uppercase;
  color: var(--text-subtle); border-bottom: 1px solid var(--border);
}
.role-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); color: var(--text-muted); vertical-align: top; }
.role-table tr:last-child td { border-bottom: none; }
.role-table td:first-child { color: var(--text); font-weight: 500; }

.steps { counter-reset: step; list-style: none; padding: 0; margin-bottom: 16px; }
.steps li {
  counter-increment: step;
  display: flex;
  gap: 14px;
  margin-bottom: 14px;
  align-items: flex-start;
  color: var(--text-muted);
  line-height: 1.65;
}
.steps li::before {
  content: counter(step);
  display: flex; align-items: center; justify-content: center;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--blue-dim);
  border: 1px solid rgba(55,138,221,.3);
  color: var(--blue-lt);
  font-size: .78rem; font-weight: 700;
  flex-shrink: 0; margin-top: 2px;
}

.docs-version {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .75rem;
  color: var(--text-subtle);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2px 10px;
  margin-bottom: 16px;
}

/* =====================================================================
   Roles page (admin inline forms)
   ===================================================================== */

.form-select-sm { padding: 5px 10px; font-size: .8rem; height: auto; width: auto; min-width: 130px; }
.inline-role-form { margin: 0; }
.role-group-row td { background: var(--bg) !important; }

/* =====================================================================
   Responsive
   ===================================================================== */

@media (max-width: 860px) {
  .app-sidebar { display: none; }
  .page-shell  { margin-left: 0; }
  .main-content { padding: 28px 20px 64px; }
  h1.docs-h1 { font-size: 1.5rem; }
}
