/* ============================================================
   WEBONICTECH Server Handbook — Professional Stylesheet
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ─── CSS VARIABLES ─────────────────────────────────────── */
:root {
  --primary:        #2563eb;
  --primary-dark:   #1d4ed8;
  --primary-light:  #dbeafe;
  --sidebar-bg:     #0f172a;
  --sidebar-text:   #cbd5e1;
  --sidebar-hover:  #1e293b;
  --sidebar-active: #2563eb;
  --sidebar-head:   #f1f5f9;
  --body-bg:        #f8fafc;
  --card-bg:        #ffffff;
  --text-primary:   #0f172a;
  --text-secondary: #475569;
  --text-muted:     #94a3b8;
  --border:         #e2e8f0;
  --border-dark:    #cbd5e1;
  --code-bg:        #1e1e2e;
  --code-text:      #cdd6f4;
  --warn-bg:        #fff7ed;
  --warn-border:    #f97316;
  --warn-text:      #9a3412;
  --danger-bg:      #fef2f2;
  --danger-border:  #ef4444;
  --danger-text:    #991b1b;
  --tip-bg:         #f0fdf4;
  --tip-border:     #22c55e;
  --tip-text:       #14532d;
  --info-bg:        #eff6ff;
  --info-border:    #3b82f6;
  --info-text:      #1e40af;
  --sidebar-w:      280px;
  --header-h:       60px;
  --radius:         8px;
  --radius-lg:      12px;
  --shadow:         0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:      0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg:      0 10px 15px rgba(0,0,0,.07), 0 4px 6px rgba(0,0,0,.05);
}

/* ─── RESET ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--body-bg);
  color: var(--text-primary);
  line-height: 1.7;
  overflow-x: hidden;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

/* ─── LAYOUT ─────────────────────────────────────────────── */
.layout {
  display: flex;
  min-height: 100vh;
}

/* ─── TOP HEADER BAR ─────────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--sidebar-bg);
  display: flex;
  align-items: center;
  padding: 0 24px;
  z-index: 1000;
  border-bottom: 1px solid #1e293b;
  gap: 16px;
}
.topbar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -.3px;
  text-decoration: none;
  flex-shrink: 0;
}
.topbar-logo:hover { text-decoration: none; }
.topbar-logo .logo-badge {
  background: var(--primary);
  color: #fff;
  padding: 3px 8px;
  border-radius: 5px;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
}
.topbar-title {
  color: var(--sidebar-text);
  font-size: .875rem;
  padding-left: 16px;
  border-left: 1px solid #334155;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-nav {
  margin-left: auto;
  display: flex;
  gap: 8px;
}
.topbar-nav a {
  color: var(--sidebar-text);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: .8125rem;
  font-weight: 500;
  transition: all .15s;
  text-decoration: none;
}
.topbar-nav a:hover { background: #1e293b; color: #fff; }
.topbar-nav a.active { background: var(--primary); color: #fff; }

/* Hamburger */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  font-size: 1.2rem;
  line-height: 1;
  flex-shrink: 0;
}
.menu-toggle:hover { background: #1e293b; }

/* ─── SIDEBAR ─────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: var(--header-h);
  left: 0;
  width: var(--sidebar-w);
  height: calc(100vh - var(--header-h));
  background: var(--sidebar-bg);
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 900;
  transition: transform .25s ease;
  border-right: 1px solid #1e293b;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: #334155; border-radius: 4px; }

.sidebar-nav { padding: 16px 0 32px; }

.nav-group { margin-bottom: 4px; }
.nav-group-label {
  display: block;
  padding: 10px 20px 6px;
  color: #64748b;
  font-size: .6875rem;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.nav-item {
  display: block;
  padding: 7px 20px;
  color: var(--sidebar-text);
  font-size: .8125rem;
  font-weight: 400;
  transition: all .12s;
  border-left: 2px solid transparent;
  text-decoration: none;
  line-height: 1.4;
}
.nav-item:hover {
  color: #f1f5f9;
  background: var(--sidebar-hover);
  text-decoration: none;
}
.nav-item.active {
  color: #fff;
  background: rgba(37, 99, 235, .15);
  border-left-color: var(--primary);
  font-weight: 500;
}
.nav-item.section {
  font-weight: 500;
  color: #e2e8f0;
  font-size: .8375rem;
}
.nav-item.sub {
  padding-left: 32px;
  font-size: .775rem;
  color: #94a3b8;
}
.nav-item.sub:hover { color: #e2e8f0; }

/* ─── MAIN CONTENT ────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  margin-top: var(--header-h);
  min-height: calc(100vh - var(--header-h));
  flex: 1;
  display: flex;
  flex-direction: column;
}
.content-wrapper {
  max-width: 900px;
  width: 100%;
  padding: 48px 56px;
  flex: 1;
}

/* ─── PAGE HEADER ─────────────────────────────────────────── */
.page-header {
  margin-bottom: 48px;
  padding-bottom: 32px;
  border-bottom: 2px solid var(--border);
}
.page-header .part-tag {
  display: inline-block;
  background: var(--primary-light);
  color: var(--primary-dark);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .5px;
  text-transform: uppercase;
  margin-bottom: 16px;
}
.page-header h1 {
  font-size: 2.25rem;
  font-weight: 800;
  line-height: 1.2;
  color: var(--text-primary);
  margin-bottom: 12px;
  letter-spacing: -.5px;
}
.page-header .subtitle {
  font-size: 1.0625rem;
  color: var(--text-secondary);
  font-weight: 400;
}
.page-header .meta {
  display: flex;
  gap: 24px;
  margin-top: 20px;
  flex-wrap: wrap;
}
.page-header .meta-item {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: .8125rem;
}

/* ─── TYPOGRAPHY ──────────────────────────────────────────── */
h1, h2, h3, h4, h5 {
  font-weight: 700;
  line-height: 1.3;
  color: var(--text-primary);
  letter-spacing: -.3px;
}
h1 { font-size: 2rem; margin: 48px 0 20px; }
h2 {
  font-size: 1.5rem;
  margin: 48px 0 16px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--border);
}
h2.section-title {
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  color: white !important;
  padding: 14px 20px;
  border-radius: var(--radius);
  border: none;
  margin-top: 56px;
  font-size: 1.25rem;
  letter-spacing: -.2px;
}
h3 {
  font-size: 1.125rem;
  margin: 32px 0 12px;
  color: var(--text-primary);
}
h4 { font-size: 1rem; margin: 24px 0 10px; color: var(--text-secondary); }
p { margin: 0 0 16px; color: var(--text-secondary); }
strong { color: var(--text-primary); font-weight: 600; }
em { color: var(--text-secondary); }

/* ─── LISTS ───────────────────────────────────────────────── */
ul, ol {
  margin: 0 0 16px;
  padding-left: 24px;
  color: var(--text-secondary);
}
li { margin-bottom: 6px; line-height: 1.65; }
li::marker { color: var(--primary); }
ul ul, ol ol, ul ol, ol ul { margin: 6px 0; }

/* Checklist */
ul.checklist { list-style: none; padding-left: 0; }
ul.checklist li { padding: 4px 0 4px 28px; position: relative; }
ul.checklist li::before {
  content: '□';
  position: absolute; left: 0;
  color: var(--primary);
  font-weight: 700;
}

/* ─── HORIZONTAL RULE ─────────────────────────────────────── */
hr {
  border: none;
  border-top: 2px solid var(--border);
  margin: 48px 0;
}

/* ─── CODE ────────────────────────────────────────────────── */
code {
  font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
  font-size: .875em;
  background: #f1f5f9;
  color: #be185d;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 500;
}
pre {
  background: var(--code-bg);
  border-radius: var(--radius-lg);
  padding: 0;
  margin: 16px 0 24px;
  overflow: hidden;
  box-shadow: var(--shadow-md);
  position: relative;
}
pre .code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #181825;
  padding: 10px 16px;
  border-bottom: 1px solid #313244;
}
pre .code-lang {
  font-family: 'JetBrains Mono', monospace;
  font-size: .7rem;
  color: #a6adc8;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
}
pre .code-dots { display: flex; gap: 6px; }
pre .code-dots span {
  width: 10px; height: 10px; border-radius: 50%;
}
pre .code-dots span:nth-child(1) { background: #f38ba8; }
pre .code-dots span:nth-child(2) { background: #a6e3a1; }
pre .code-dots span:nth-child(3) { background: #89b4fa; }
pre code {
  display: block;
  padding: 20px 20px 20px;
  color: var(--code-text);
  background: transparent;
  font-size: .8375rem;
  line-height: 1.7;
  overflow-x: auto;
  white-space: pre;
}
pre code .comment { color: #6c7086; font-style: italic; }
pre code .keyword { color: #cba6f7; }
pre code .string  { color: #a6e3a1; }
pre code .number  { color: #fab387; }
pre code .command { color: #89b4fa; }

/* Keyword-based simple highlighting */
.hljs-comment, .hljs-quote { color: #6c7086; font-style: italic; }
.hljs-keyword { color: #cba6f7; }
.hljs-string  { color: #a6e3a1; }
.hljs-number  { color: #fab387; }
.hljs-built_in { color: #89dceb; }
.hljs-title   { color: #89b4fa; }
.hljs-attr    { color: #f38ba8; }
.hljs-variable { color: #cdd6f4; }

/* ─── TABLES ──────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  margin: 16px 0 24px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
thead { background: var(--sidebar-bg); }
thead th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  font-size: .8rem;
  color: #e2e8f0;
  letter-spacing: .3px;
  text-transform: uppercase;
  white-space: nowrap;
}
tbody tr { border-top: 1px solid var(--border); transition: background .1s; }
tbody tr:hover { background: #f1f5f9; }
tbody td {
  padding: 11px 16px;
  color: var(--text-secondary);
  vertical-align: top;
}
tbody td:first-child { color: var(--text-primary); font-weight: 500; }
tbody td code { font-size: .8rem; }

/* ─── CALLOUT BOXES ───────────────────────────────────────── */
.callout {
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin: 20px 0 24px;
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.callout-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
  margin-top: 2px;
}
.callout-body { flex: 1; }
.callout-title {
  font-weight: 700;
  font-size: .875rem;
  margin-bottom: 4px;
  display: block;
}
.callout-body p { margin: 0; font-size: .875rem; line-height: 1.6; }

.callout.warning  { background: var(--warn-bg);   border-left: 4px solid var(--warn-border);   }
.callout.warning .callout-title, .callout.warning .callout-icon { color: var(--warn-border); }
.callout.warning .callout-body p { color: var(--warn-text); }

.callout.danger   { background: var(--danger-bg); border-left: 4px solid var(--danger-border); }
.callout.danger .callout-title, .callout.danger .callout-icon { color: var(--danger-border); }
.callout.danger .callout-body p { color: var(--danger-text); }

.callout.tip      { background: var(--tip-bg);    border-left: 4px solid var(--tip-border);    }
.callout.tip .callout-title, .callout.tip .callout-icon { color: #16a34a; }
.callout.tip .callout-body p { color: var(--tip-text); }

.callout.info     { background: var(--info-bg);   border-left: 4px solid var(--info-border);   }
.callout.info .callout-title, .callout.info .callout-icon { color: var(--primary); }
.callout.info .callout-body p { color: var(--info-text); }

/* ─── BLOCKQUOTE ──────────────────────────────────────────── */
blockquote {
  border-left: 4px solid var(--primary);
  background: var(--info-bg);
  padding: 14px 20px;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: 16px 0 24px;
  color: var(--info-text);
  font-size: .9375rem;
}
blockquote p { margin: 0; color: var(--info-text); }
blockquote strong { color: var(--primary-dark); }

/* ─── CARDS ───────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}
.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ─── DIAGRAM / ASCII FLOW ────────────────────────────────── */
.diagram {
  background: #0f172a;
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  margin: 16px 0 24px;
  overflow-x: auto;
  border: 1px solid #1e293b;
}
.diagram pre {
  background: transparent;
  box-shadow: none;
  margin: 0;
  padding: 0;
}
.diagram pre code {
  color: #94a3b8;
  font-size: .8rem;
  padding: 0;
  line-height: 1.9;
}

/* ─── COMPARISON TABLE BADGES ────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: .75rem;
  font-weight: 600;
}
.badge.green { background: #dcfce7; color: #15803d; }
.badge.red   { background: #fee2e2; color: #dc2626; }
.badge.blue  { background: #dbeafe; color: #2563eb; }
.badge.gray  { background: #f1f5f9; color: #475569; }

/* ─── PAGE NAV (prev/next) ────────────────────────────────── */
.page-nav {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 56px;
  padding-top: 32px;
  border-top: 2px solid var(--border);
}
.page-nav a {
  display: flex;
  flex-direction: column;
  padding: 16px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--card-bg);
  max-width: 48%;
  transition: all .15s;
  text-decoration: none;
  box-shadow: var(--shadow);
  gap: 4px;
}
.page-nav a:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  text-decoration: none;
}
.page-nav a .nav-direction {
  font-size: .75rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.page-nav a .nav-title {
  font-size: .9375rem;
  font-weight: 600;
  color: var(--primary);
}
.page-nav a.prev { align-items: flex-start; }
.page-nav a.next { align-items: flex-end; margin-left: auto; }

/* ─── FOOTER ──────────────────────────────────────────────── */
.site-footer {
  text-align: center;
  padding: 24px 56px;
  color: var(--text-muted);
  font-size: .8125rem;
  border-top: 1px solid var(--border);
  background: var(--card-bg);
}

/* ─── INDEX PAGE SPECIFIC ─────────────────────────────────── */
.hero {
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 50%, #1e293b 100%);
  border-radius: var(--radius-lg);
  padding: 56px 48px;
  margin-bottom: 48px;
  color: white;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute;
  top: -50%; right: -20%;
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(37,99,235,.3) 0%, transparent 70%);
  pointer-events: none;
}
.hero-tag {
  display: inline-block;
  background: rgba(37,99,235,.3);
  border: 1px solid rgba(37,99,235,.5);
  color: #93c5fd;
  padding: 5px 14px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 20px;
}
.hero h1 {
  font-size: 2.5rem;
  font-weight: 800;
  margin: 0 0 16px;
  letter-spacing: -.5px;
  color: white;
  line-height: 1.15;
}
.hero p { color: #94a3b8; font-size: 1.0625rem; max-width: 560px; margin-bottom: 0; }
.hero-meta {
  display: flex;
  gap: 24px;
  margin-top: 28px;
  flex-wrap: wrap;
}
.hero-meta span {
  background: rgba(255,255,255,.08);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: .8rem;
  color: #cbd5e1;
  display: flex;
  align-items: center;
  gap: 6px;
}

.parts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin-bottom: 48px;
}
.part-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
  transition: all .2s;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
  cursor: pointer;
}
.part-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
  text-decoration: none;
}
.part-card-num {
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  color: white;
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800;
  font-size: .9375rem;
}
.part-card h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}
.part-card p {
  font-size: .8375rem;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.5;
}
.part-card .part-sections {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}
.part-card .part-sections span {
  background: var(--primary-light);
  color: var(--primary-dark);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: .7rem;
  font-weight: 600;
}

/* ─── SEARCH BAR (decorative) ──────────────────────────────── */
.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--sidebar-hover);
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 8px 14px;
  margin: 16px 16px 8px;
}
.search-bar input {
  background: transparent;
  border: none;
  outline: none;
  color: #e2e8f0;
  font-size: .8125rem;
  width: 100%;
  font-family: inherit;
}
.search-bar input::placeholder { color: #64748b; }
.search-bar svg { color: #64748b; flex-shrink: 0; }

/* ─── SCROLL TO TOP ──────────────────────────────────────── */
.scroll-top {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 42px; height: 42px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  transition: all .2s;
  opacity: 0;
  pointer-events: none;
  z-index: 999;
}
.scroll-top.visible { opacity: 1; pointer-events: auto; }
.scroll-top:hover { background: var(--primary-dark); transform: translateY(-2px); }

/* ─── ANCHOR LINKS ────────────────────────────────────────── */
.anchor-link {
  opacity: 0;
  margin-left: 8px;
  font-size: .8em;
  color: var(--text-muted);
  transition: opacity .15s;
}
h2:hover .anchor-link,
h3:hover .anchor-link { opacity: 1; }

/* ─── PROGRESS BAR ────────────────────────────────────────── */
#reading-progress {
  position: fixed;
  top: var(--header-h);
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), #7c3aed);
  z-index: 1001;
  width: 0%;
  transition: width .1s;
}

/* ─── RESPONSIVE ──────────────────────────────────────────── */
@media (max-width: 1100px) {
  .content-wrapper { padding: 40px 40px; }
}

@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
  }
  .menu-toggle { display: flex; }
  .topbar-nav { display: none; }
  .content-wrapper { padding: 32px 24px; }
  .parts-grid { grid-template-columns: 1fr; }
  .page-header h1 { font-size: 1.75rem; }
  .hero { padding: 36px 28px; }
  .hero h1 { font-size: 1.875rem; }
  .page-nav { flex-direction: column; }
  .page-nav a { max-width: 100%; }
  .page-nav a.next { align-items: flex-start; }
}

@media (max-width: 600px) {
  .content-wrapper { padding: 24px 16px; }
  pre code { font-size: .75rem; }
  h2.section-title { font-size: 1.0625rem; }
}

/* ─── PRINT ──────────────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .page-nav, .scroll-top, #reading-progress { display: none !important; }
  .main-content { margin-left: 0; margin-top: 0; }
  .content-wrapper { padding: 24px; max-width: 100%; }
  pre { page-break-inside: avoid; }
  h2, h3 { page-break-after: avoid; }
}

/* ─── UTILITY ─────────────────────────────────────────────── */
.mt-0 { margin-top: 0 !important; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted) !important; }
.font-mono { font-family: 'JetBrains Mono', monospace; }
.divider { border: none; border-top: 1px solid var(--border); margin: 32px 0; }
