/* ==== RESET ==== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "Inter", sans-serif;
  background: #020016;
  color: #f9fafb;
}

/* ==== THEME VARIABLES ==== */
:root {
  --bg-main: #020016;
  --bg-elevated: #050316;
  --bg-sidebar: #050015;
  --bg-hover: rgba(120, 119, 198, 0.18);
  --border-subtle: rgba(148, 163, 184, 0.2);

  --accent: #a855f7;
  --accent-alt: #6366f1;
  --accent-soft: rgba(168, 85, 247, 0.15);
  --accent-strong: #e879f9;

  --text-main: #e5e7eb;
  --text-muted: #9ca3af;
  --text-soft: #6b7280;

  --radius-md: 0.75rem;
  --radius-lg: 999px;
  --shadow-soft: 0 24px 60px rgba(15, 23, 42, 0.85);
}

body.light {
  --bg-main: #f9fafb;
  --bg-elevated: #ffffff;
  --bg-sidebar: #f5f3ff;
  --bg-hover: rgba(196, 181, 253, 0.4);
  --border-subtle: rgba(148, 163, 184, 0.6);

  --text-main: #020617;
  --text-muted: #4b5563;
  --text-soft: #6b7280;
}

/* ==== APP LAYOUT ==== */

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(192, 132, 252, 0.3), transparent 55%),
    radial-gradient(circle at bottom right, rgba(59, 130, 246, 0.25), transparent 55%),
    radial-gradient(circle at top right, rgba(236, 72, 153, 0.18), transparent 50%),
    var(--bg-main);
}

/* TOP NAVBAR */

.top-nav {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.75rem;
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border-subtle);
  background: linear-gradient(
      to bottom,
      rgba(5, 2, 30, 0.9),
      rgba(4, 1, 20, 0.85)
    );
}

.top-nav-left {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.logo-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: radial-gradient(circle, #f97316, #facc15);
  box-shadow: 0 0 25px rgba(250, 204, 21, 0.8);
  font-size: 0.9rem;
}

.logo-text {
  font-weight: 700;
  letter-spacing: 0.06em;
  font-size: 0.95rem;
  text-transform: uppercase;
}

.top-links {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.top-link {
  font-size: 0.85rem;
  color: var(--text-soft);
  text-decoration: none;
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  transition: all 0.18s ease;
}

.top-link:hover {
  background: rgba(148, 163, 184, 0.14);
  color: var(--text-main);
}

.top-link.active {
  background: var(--accent-soft);
  color: #f5f3ff;
  box-shadow: 0 0 18px rgba(196, 181, 253, 0.7);
}

.top-nav-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Search */

.search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  background: rgba(5, 3, 32, 0.98);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  border: 1px solid rgba(88, 28, 135, 0.9);
  min-width: 220px;
  max-width: 320px;
  box-shadow: 0 0 18px rgba(79, 70, 229, 0.6);
}

.search-input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-size: 0.85rem;
  flex: 1;
}

.search-input::placeholder {
  color: var(--text-soft);
}

.search-icon {
  font-size: 0.7rem;
  color: var(--text-soft);
  margin-right: 0.5rem;
}

/* Buttons */

.btn-pill {
  border-radius: 999px;
  border: none;
  padding: 0.35rem 0.95rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.18s ease;
  font-weight: 500;
}

.btn-pill.primary {
  background: linear-gradient(120deg, #f97316, #eab308, #22c55e);
  color: #020617;
  box-shadow: 0 0 26px rgba(251, 191, 36, 0.8);
}

.btn-pill.primary:hover {
  transform: translateY(-1px) scale(1.01);
  box-shadow: 0 0 30px rgba(251, 191, 36, 0.95);
}

.btn-pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #22c55e;
  box-shadow: 0 0 10px rgba(34, 197, 94, 0.9);
}

/* Icon button */

.icon-button {
  background: radial-gradient(circle at top, rgba(15, 23, 42, 1), rgba(15, 23, 42, 0.92));
  border-radius: 999px;
  border: 1px solid rgba(129, 140, 248, 0.9);
  color: #e5e7eb;
  font-size: 0.85rem;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.16s ease;
  box-shadow: 0 0 16px rgba(79, 70, 229, 0.7);
}

.icon-button:hover {
  background: rgba(30, 64, 175, 1);
  box-shadow: 0 0 22px rgba(129, 140, 248, 1);
}

/* ==== MAIN LAYOUT ==== */

.layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 210px;
  min-height: calc(100vh - 56px);
}

/* Sidebar */

.sidebar {
  padding: 1.5rem 1.25rem 1.75rem 1.75rem;
  border-right: 1px solid var(--border-subtle);
  background: linear-gradient(
      to bottom,
      rgba(15, 23, 42, 0.95),
      rgba(10, 10, 31, 0.98)
    );
  overflow-y: auto;
}

.sidebar-section + .sidebar-section {
  margin-top: 1.5rem;
}

.sidebar-section-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: rgba(148, 163, 184, 0.85);
  margin-bottom: 0.5rem;
}

.sidebar-subtitle {
  font-size: 0.78rem;
  color: rgba(148, 163, 184, 0.9);
  margin: 0.25rem 0 0.15rem;
}

.sidebar-link {
  display: block;
  padding: 0.4rem 0.75rem;
  border-radius: 0.6rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-decoration: none;
  margin-bottom: 0.1rem;
  position: relative;
  transition: all 0.18s ease;
}

.sidebar-link::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 1px solid transparent;
  pointer-events: none;
}

.sidebar-link:hover {
  background: rgba(24, 24, 60, 0.95);
  color: var(--text-main);
}

.sidebar-link.active {
  background: radial-gradient(circle at top left, rgba(147, 51, 234, 0.9), rgba(30, 64, 175, 1));
  color: #f9fafb;
  font-weight: 500;
  box-shadow:
    0 18px 40px rgba(15, 23, 42, 0.95),
    0 0 0 1px rgba(196, 181, 253, 0.7);
}

.sidebar-link.active::before {
  border-color: rgba(196, 181, 253, 0.95);
}

/* Content */

.content {
  padding: 1.75rem 2.5rem 2.5rem 2rem;
  max-width: 960px;
}

.content-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.5rem;
  gap: 1rem;
}

.breadcrumb {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--text-soft);
  margin-bottom: 0.4rem;
}

.page-subtitle {
  font-size: 0.85rem;
  color: var(--text-soft);
  margin-top: 0.2rem;
}

.content-header h1 {
  font-size: 1.7rem;
  letter-spacing: -0.03em;
  margin-bottom: 0.1rem;
}

.content-cta {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.8rem;
  color: #e5e7eb;
  text-decoration: none;
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  background: radial-gradient(circle at top left, rgba(129, 140, 248, 0.4), rgba(15, 23, 42, 0.95));
  border: 1px solid rgba(129, 140, 248, 0.8);
  transition: all 0.18s ease;
  box-shadow: 0 0 18px rgba(129, 140, 248, 0.7);
}

.content-cta:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 24px rgba(129, 140, 248, 0.95);
}

.content-cta .arrow {
  font-size: 1.1rem;
}

/* Tags / pills */

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.75rem;
}

.pill {
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  border: 1px solid rgba(148, 163, 184, 0.4);
  color: rgba(226, 232, 240, 0.9);
  background: rgba(15, 23, 42, 0.9);
}

/* Hero grid cards */

.hero-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.9rem;
  margin-bottom: 1.25rem;
}

.hero-card {
  border-radius: 0.9rem;
  padding: 0.9rem 1rem;
  background: radial-gradient(circle at top left, rgba(30, 64, 175, 0.8), rgba(15, 23, 42, 0.98));
  border: 1px solid rgba(129, 140, 248, 0.7);
  box-shadow: 0 15px 35px rgba(15, 23, 42, 0.9);
}

.hero-card h3 {
  font-size: 0.9rem;
  margin-bottom: 0.15rem;
}

.hero-card p {
  font-size: 0.78rem;
  color: rgba(226, 232, 240, 0.82);
}

/* Doc content */

.doc {
  border-radius: 1rem;
  padding: 1.75rem 2rem;
  background:
    radial-gradient(circle at top left, rgba(76, 29, 149, 0.55), transparent 55%),
    radial-gradient(circle at bottom right, rgba(15, 23, 42, 0.95), rgba(3, 7, 18, 1));
  border: 1px solid rgba(55, 65, 81, 0.95);
  box-shadow: var(--shadow-soft);
  line-height: 1.65;
  color: var(--text-main);
  font-size: 0.95rem;
}

.doc h2 {
  font-size: 1.1rem;
  margin-top: 1.1rem;
  margin-bottom: 0.4rem;
}

.doc h3 {
  font-size: 0.99rem;
  margin-top: 0.85rem;
  margin-bottom: 0.35rem;
}

.doc p {
  margin-bottom: 0.8rem;
  color: var(--text-muted);
}

.doc ul {
  margin: 0.4rem 0 0.8rem;
  padding-left: 1.25rem;
}

.doc li {
  margin-bottom: 0.3rem;
}

.doc code {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco,
    Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.86rem;
  background: rgba(15, 23, 42, 0.95);
  border-radius: 0.4rem;
  padding: 0.14rem 0.35rem;
  border: 1px solid rgba(55, 65, 81, 0.95);
}

.doc pre {
  background: radial-gradient(circle at top left, rgba(30, 64, 175, 0.8), rgba(15, 23, 42, 1));
  border-radius: 0.75rem;
  padding: 0.9rem 1rem;
  border: 1px solid rgba(55, 65, 81, 0.95);
  margin: 0.6rem 0 1rem;
  overflow-x: auto;
}

.doc pre code {
  background: transparent;
  border: none;
  padding: 0;
}

/* Callouts */

.callout {
  border-radius: 0.75rem;
  padding: 0.65rem 0.8rem;
  margin: 0.7rem 0 0.9rem;
  font-size: 0.85rem;
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
}

.callout-icon {
  font-size: 1rem;
  margin-top: 0.1rem;
}

.callout-body {
  flex: 1;
}

.callout.callout-tip {
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.6);
}

.callout.callout-warning {
  background: rgba(234, 179, 8, 0.08);
  border: 1px solid rgba(234, 179, 8, 0.6);
}

.callout.callout-danger {
  background: rgba(248, 113, 113, 0.08);
  border: 1px solid rgba(248, 113, 113, 0.6);
}

/* Meta */

.doc-meta {
  display: flex;
  gap: 1.5rem;
  margin-top: 1rem;
  font-size: 0.8rem;
  color: var(--text-soft);
}

.meta-item {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.meta-label {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.7rem;
}

.meta-value {
  color: var(--text-muted);
}

/* Prev/next nav */

.doc-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 1rem;
  gap: 0.75rem;
}

.doc-nav-btn {
  flex: 1;
  border-radius: 0.75rem;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: rgba(15, 23, 42, 0.9);
  color: var(--text-muted);
  padding: 0.6rem 0.9rem;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.18s ease;
}

.doc-nav-btn:hover:not(:disabled) {
  background: rgba(30, 64, 175, 0.8);
  color: #f9fafb;
  border-color: rgba(129, 140, 248, 0.85);
  box-shadow: 0 0 18px rgba(129, 140, 248, 0.8);
}

.doc-nav-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

/* Footer */

.doc-footer {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 1.5rem;
  font-size: 0.8rem;
  color: var(--text-soft);
}

.doc-footer a {
  color: #c4b5fd;
  text-decoration: none;
}

.doc-footer a:hover {
  text-decoration: underline;
}

.doc-footer .divider {
  opacity: 0.5;
}

/* TOC panel */

.toc-panel {
  padding: 1.5rem 1.75rem 1.5rem 1rem;
  border-left: 1px solid var(--border-subtle);
  font-size: 0.8rem;
  color: var(--text-soft);
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
  overflow-y: auto;
  background: radial-gradient(circle at top, rgba(30, 64, 175, 0.3), transparent 55%);
}

.toc-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  margin-bottom: 0.65rem;
}

.toc-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.toc-link {
  color: var(--text-soft);
  text-decoration: none;
  padding: 0.15rem 0.3rem;
  border-radius: 0.4rem;
  transition: all 0.15s ease;
}

.toc-link.level-2 {
  font-size: 0.78rem;
}

.toc-link.level-3 {
  font-size: 0.75rem;
  margin-left: 0.6rem;
}

.toc-link:hover {
  background: rgba(15, 23, 42, 0.9);
  color: var(--text-main);
}

.toc-link.active {
  color: #ede9fe;
  background: rgba(109, 40, 217, 0.85);
}

/* AUTH OVERLAY (for admin password) */

.auth-overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at top, rgba(15, 23, 42, 0.92), rgba(3, 7, 18, 0.98));
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.auth-overlay.hidden {
  display: none;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: radial-gradient(circle at top left, rgba(88, 28, 135, 0.75), rgba(15, 23, 42, 0.98));
  border-radius: 1rem;
  padding: 1.75rem 1.75rem 1.5rem;
  border: 1px solid rgba(196, 181, 253, 0.65);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.95);
}

.auth-card h2 {
  font-size: 1.1rem;
  margin-bottom: 0.3rem;
}

.auth-text {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.auth-input {
  border-radius: 0.7rem;
  border: 1px solid rgba(148, 163, 184, 0.6);
  background: rgba(15, 23, 42, 0.95);
  color: var(--text-main);
  padding: 0.55rem 0.75rem;
  font-size: 0.9rem;
}

.auth-input::placeholder {
  color: var(--text-soft);
}

.auth-button {
  border-radius: 0.7rem;
  border: none;
  background: linear-gradient(120deg, #a855f7, #6366f1);
  color: #f9fafb;
  font-size: 0.88rem;
  padding: 0.55rem 0.75rem;
  cursor: pointer;
  box-shadow: 0 0 18px rgba(129, 140, 248, 0.8);
  transition: all 0.18s ease;
}

.auth-button.small {
  font-size: 0.8rem;
  padding: 0.45rem 0.6rem;
  margin-top: 0.25rem;
}

.auth-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 24px rgba(167, 139, 250, 0.95);
}

.auth-error {
  min-height: 1.1rem;
  font-size: 0.8rem;
  color: #fecaca;
}

.auth-note {
  margin-top: 0.6rem;
  font-size: 0.78rem;
  color: var(--text-soft);
}

/* ADMIN LAYOUT */

.admin-layout {
  grid-template-columns: 260px minmax(0, 1.1fr) minmax(0, 1.1fr);
}

.admin-sidebar {
  border-right: 1px solid var(--border-subtle);
}

.admin-heading {
  font-size: 1rem;
  margin-bottom: 0.75rem;
}

.admin-subheading {
  font-size: 0.85rem;
  margin-top: 1rem;
  margin-bottom: 0.3rem;
}

.admin-list {
  margin-bottom: 0.5rem;
}

.admin-page-item {
  padding: 0.35rem 0.4rem;
  border-radius: 0.45rem;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text-muted);
  border: 1px solid transparent;
  margin-bottom: 0.15rem;
}

.admin-page-item span {
  flex: 1;
}

.admin-page-item button {
  margin-left: 0.3rem;
}

.admin-page-item:hover {
  border-color: rgba(148, 163, 184, 0.45);
  background: rgba(15, 23, 42, 0.9);
}

.admin-form {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.admin-title {
  font-size: 1.4rem;
  margin-bottom: 0.4rem;
}

.admin-section {
  margin-top: 1.25rem;
}

.admin-section-title {
  font-size: 1rem;
  margin-bottom: 0.4rem;
}

.admin-page-actions button {
  font-size: 0.7rem;
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  border: 1px solid rgba(148, 163, 184, 0.7);
  background: rgba(15, 23, 42, 0.95);
  color: var(--text-muted);
  cursor: pointer;
}

.admin-page-actions button:hover {
  border-color: rgba(248, 250, 252, 0.9);
  color: #f9fafb;
}

.admin-editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1.5rem;
  align-items: flex-start;
}

.admin-editor-card {
  background: rgba(15, 23, 42, 0.96);
  border-radius: 0.9rem;
  padding: 1rem 1.2rem;
  border: 1px solid rgba(55, 65, 81, 0.95);
  box-shadow: 0 16px 35px rgba(15, 23, 42, 0.9);
}

.admin-editor-card h2 {
  font-size: 1rem;
  margin-bottom: 0.5rem;
}

.admin-field-group {
  margin-bottom: 0.7rem;
}

.admin-label {
  font-size: 0.8rem;
  display: block;
  margin-bottom: 0.25rem;
  color: var(--text-soft);
}

.admin-input,
.admin-textarea {
  width: 100%;
  border-radius: 0.6rem;
  border: 1px solid rgba(55, 65, 81, 0.95);
  background: rgba(15, 23, 42, 0.97);
  color: var(--text-main);
  font-size: 0.85rem;
  padding: 0.45rem 0.6rem;
}

.admin-textarea {
  min-height: 140px;
  resize: vertical;
}

.hero-card-editor {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 0.5rem;
  padding: 0.5rem;
  border-radius: 0.6rem;
  background: rgba(15, 23, 42, 0.95);
  border: 1px dashed rgba(75, 85, 99, 0.9);
}

/* Preview */

.preview-wrapper {
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}

/* ==== RESPONSIVE ==== */

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 230px minmax(0, 1fr);
  }

  .admin-layout {
    grid-template-columns: 230px minmax(0, 1fr);
  }

  .toc-panel {
    display: none;
  }

  .content {
    padding-right: 1.5rem;
  }

  .admin-editor-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 780px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }

  .content {
    padding: 1.25rem;
  }

  .top-nav {
    padding-inline: 1rem;
  }

  .top-links {
    display: none;
  }

  .search-wrapper {
    display: none;
  }
}
