/* Custom premium styles for CMS Doc */

/* ----------------------------------------------------
   CSS Variables & Themes (HSL based)
---------------------------------------------------- */
:root {
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-title: 'Outfit', -apple-system, sans-serif;
  --font-code: 'Fira Code', monospace;

  /* Light Theme Colors */
  --bg-app: hsl(210, 20%, 98%);
  --bg-surface: hsl(0, 0%, 100%);
  --bg-sidebar: hsl(210, 20%, 96%);
  --border-color: hsl(210, 14%, 90%);
  
  --primary: hsl(221, 80%, 12%);
  --primary-hover: hsl(221, 80%, 8%);
  --accent: hsl(221, 83%, 53%);
  --accent-light: hsl(221, 83%, 93%);
  --accent-hover: hsl(221, 85%, 45%);
  
  --fg: hsl(215, 28%, 17%);
  --fg-muted: hsl(215, 16%, 47%);
  --fg-light: hsl(215, 16%, 60%);

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.05), 0 10px 10px -5px rgba(0, 0, 0, 0.02);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --code-bg: hsl(220, 13%, 18%);
  --code-fg: hsl(220, 14%, 85%);
  --code-keyword: hsl(286, 60%, 67%);
  --code-string: hsl(95, 38%, 62%);
  --code-comment: hsl(220, 10%, 48%);
  --code-number: hsl(29, 54%, 61%);
  --code-builtin: hsl(207, 82%, 66%);

  --alert-info-bg: hsl(210, 100%, 97%);
  --alert-info-border: hsl(210, 100%, 90%);
  --alert-info-text: hsl(210, 100%, 25%);

  --alert-warn-bg: hsl(38, 100%, 96%);
  --alert-warn-border: hsl(38, 100%, 88%);
  --alert-warn-text: hsl(38, 100%, 20%);
}

[data-theme="dark"] {
  /* Dark Theme Colors */
  --bg-app: hsl(240, 10%, 4%);
  --bg-surface: hsl(240, 10%, 9%);
  --bg-sidebar: hsl(240, 10%, 6%);
  --border-color: hsl(240, 6%, 15%);
  
  --primary: hsl(221, 83%, 55%);
  --primary-hover: hsl(221, 85%, 65%);
  --accent: hsl(221, 83%, 53%);
  --accent-light: hsl(221, 40%, 12%);
  --accent-hover: hsl(221, 85%, 45%);
  
  --fg: hsl(240, 5%, 90%);
  --fg-muted: hsl(240, 4%, 65%);
  --fg-light: hsl(240, 4%, 45%);

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4), 0 1px 3px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 10px 10px -5px rgba(0, 0, 0, 0.3);

  --code-bg: hsl(240, 10%, 6%);

  --alert-info-bg: hsl(210, 30%, 10%);
  --alert-info-border: hsl(210, 30%, 18%);
  --alert-info-text: hsl(210, 100%, 75%);

  --alert-warn-bg: hsl(38, 30%, 10%);
  --alert-warn-border: hsl(38, 30%, 18%);
  --alert-warn-text: hsl(38, 100%, 70%);
}

/* ----------------------------------------------------
   Reset & Global Styles
---------------------------------------------------- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-app);
  color: var(--fg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s ease;
}
a:hover {
  color: var(--accent-hover);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--fg-light);
}

/* ----------------------------------------------------
   Header Styling
---------------------------------------------------- */
.main-header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 64px;
  background-color: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  z-index: 100;
  transition: background-color 0.3s ease, border-bottom 0.3s ease;
}
[data-theme="dark"] .main-header {
  background-color: rgba(9, 9, 11, 0.8);
}

.header-container {
  max-width: 1440px;
  height: 100%;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  width: 26px;
  height: 26px;
  color: var(--accent);
}

.logo-text {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--fg);
  letter-spacing: -0.5px;
}

.logo-sub {
  color: var(--accent);
  font-weight: 500;
  font-size: 0.85rem;
  background: var(--accent-light);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  margin-left: 6px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.theme-btn {
  background: none;
  border: 1px solid var(--border-color);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  color: var(--fg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}
.theme-btn:hover {
  background-color: var(--border-color);
}
.theme-btn:active {
  transform: scale(0.95);
}

.theme-btn svg {
  width: 18px;
  height: 18px;
}

/* Toggle sun/moon based on current theme */
[data-theme="light"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: none; }

.mobile-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border-color);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  color: var(--fg);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.mobile-toggle:hover {
  background-color: var(--border-color);
}
.mobile-toggle svg {
  width: 20px;
  height: 20px;
}

/* ----------------------------------------------------
   Main Layout & Sidebar
---------------------------------------------------- */
.main-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
  padding-top: 64px;
}

.sidebar {
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  position: fixed;
  top: 64px;
  bottom: 0;
  width: 280px;
  overflow-y: auto;
  padding: 24px;
  z-index: 50;
  transition: transform 0.3s ease, background-color 0.3s ease, border-right 0.3s ease;
}

.sidebar-search {
  margin-bottom: 24px;
}

.search-box {
  display: flex;
  align-items: center;
  background-color: var(--bg-surface);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  gap: 8px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.search-icon {
  width: 16px;
  height: 16px;
  color: var(--fg-muted);
}

.search-box input {
  border: none;
  background: none;
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: var(--fg);
  outline: none;
  width: 100%;
}
.search-box input::placeholder {
  color: var(--fg-light);
}

/* Page Selector (Tabs inside Sidebar) */
.page-selector {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1.5px solid var(--border-color);
}

.page-tab-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  background: none;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-family: var(--font-title);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--fg-muted);
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
}

.page-tab-btn:hover {
  color: var(--fg);
  border-color: var(--fg-light);
  background-color: var(--bg-surface);
}

.page-tab-btn.active {
  color: var(--accent);
  border-color: var(--accent);
  background-color: var(--accent-light);
  box-shadow: var(--shadow-sm);
}

.tab-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.nav-section-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--fg-light);
  letter-spacing: 1px;
  margin-top: 12px;
  margin-bottom: 8px;
  padding-left: 14px;
  text-transform: uppercase;
}

.sidebar-nav ul {
  list-style: none;
  margin-bottom: 12px;
}

.sidebar-nav li {
  margin-bottom: 4px;
}

.nav-link {
  display: block;
  padding: 8px 14px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--fg-muted);
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
}
.nav-link:hover {
  color: var(--fg);
  background-color: var(--border-color);
}
.nav-link.active {
  color: var(--accent);
  background-color: var(--accent-light);
  font-weight: 600;
}

/* ----------------------------------------------------
   Content & Virtual Page switcher
---------------------------------------------------- */
.content {
  grid-column: 2;
  padding: 40px 24px 80px 24px;
  overflow-y: auto;
}

.content-container {
  max-width: 800px;
  margin: 0 auto;
}

.doc-page {
  animation: fadeIn 0.4s ease-out forwards;
}

.hidden {
  display: none !important;
}

.doc-section {
  scroll-margin-top: 90px;
  margin-bottom: 60px;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

h1 {
  font-family: var(--font-title);
  font-weight: 800;
  font-size: 2.25rem;
  color: var(--fg);
  letter-spacing: -0.8px;
  margin-bottom: 16px;
}

h2 {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 1.6rem;
  color: var(--fg);
  letter-spacing: -0.5px;
  margin-top: 40px;
  margin-bottom: 16px;
}

h3 {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--fg);
  margin-top: 32px;
  margin-bottom: 12px;
}

h4 {
  font-family: var(--font-title);
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--fg);
  margin-bottom: 10px;
}

h5 {
  display: flex;
  align-items: center;
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--fg);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

p {
  font-size: 0.95rem;
  color: var(--fg-muted);
  margin-bottom: 16px;
}

.section-lead {
  font-size: 1.1rem;
  line-height: 1.7;
  color: var(--fg);
  margin-bottom: 24px;
}

hr {
  border: 0;
  height: 1px;
  background-color: var(--border-color);
  margin: 48px 0;
}

/* Bullet lists */
ul, ol {
  margin-bottom: 18px;
  padding-left: 20px;
  color: var(--fg-muted);
  font-size: 0.95rem;
}

li {
  margin-bottom: 8px;
}

strong {
  color: var(--fg);
  font-weight: 600;
}

/* Inline file or link references */
.file-badge {
  background-color: var(--border-color);
  color: var(--fg);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-code);
  font-size: 0.8rem;
  font-weight: 500;
}

.file-link {
  color: var(--accent);
  text-decoration: underline;
}

/* ----------------------------------------------------
   Alert / Callout Cards
---------------------------------------------------- */
.info-alert, .warning-alert {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 16px 20px;
  border-radius: var(--radius-md);
  margin-bottom: 24px;
  border: 1px solid;
}

.info-alert {
  background-color: var(--alert-info-bg);
  border-color: var(--alert-info-border);
}
.alert-svg-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  margin-top: 2px;
}
.info-alert .alert-svg-icon {
  color: var(--alert-info-text);
}
.info-alert .alert-content {
  color: var(--alert-info-text);
  font-size: 0.9rem;
}

.warning-alert {
  background-color: var(--alert-warn-bg);
  border-color: var(--alert-warn-border);
}
.warning-alert .alert-svg-icon {
  color: var(--alert-warn-text);
}
.warning-alert .alert-content {
  color: var(--alert-warn-text);
  font-size: 0.9rem;
}

/* ----------------------------------------------------
   Grid Cards / Features
---------------------------------------------------- */
.grid-layout {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin: 24px 0;
}

.doc-card {
  background-color: var(--bg-surface);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.doc-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
}
.doc-card p {
  font-size: 0.85rem;
  margin-bottom: 12px;
}

.card-title-icon {
  width: 18px;
  height: 18px;
  vertical-align: middle;
  margin-right: 8px;
  display: inline-block;
  color: var(--accent);
}

.card-feature {
  background-color: var(--bg-surface);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-top: 24px;
}
.card-feature h4 {
  margin-bottom: 14px;
}
.card-feature ol {
  margin-bottom: 0;
}

/* ----------------------------------------------------
   Code Snippets styling
---------------------------------------------------- */
.code-container {
  background-color: var(--code-bg);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 24px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: rgba(0, 0, 0, 0.2);
  padding: 10px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.code-lang {
  font-size: 0.75rem;
  font-family: var(--font-code);
  font-weight: 500;
  color: var(--fg-light);
}

.copy-btn {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  outline: none;
  padding: 4px 10px;
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.copy-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: white;
}
.copy-btn:active {
  transform: scale(0.95);
}

pre {
  padding: 18px;
  overflow-x: auto;
  margin: 0;
}

code {
  font-family: var(--font-code);
  font-size: 0.82rem;
  color: var(--code-fg);
  tab-size: 2;
  -moz-tab-size: 2;
}

pre code {
  display: block;
}

/* Basic Syntax Highlights (Regex-applied by search or style matching, static for now, looks clean) */
pre code span.keyword { color: var(--code-keyword); }
pre code span.string { color: var(--code-string); }
pre code span.comment { color: var(--code-comment); }
pre code span.number { color: var(--code-number); }
pre code span.builtin { color: var(--code-builtin); }

.inline-code code {
  background-color: rgba(0, 0, 0, 0.05);
  color: var(--accent);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.8rem;
}
[data-theme="dark"] .inline-code code {
  background-color: rgba(255, 255, 255, 0.05);
}

/* Search Highlights */
.search-highlight {
  background-color: rgba(251, 191, 36, 0.3); /* Transparent amber */
  border-bottom: 2px solid rgb(251, 191, 36);
  padding: 1px 0;
  border-radius: 2px;
}

/* ----------------------------------------------------
   Responsive Breakpoints
---------------------------------------------------- */
@media (max-width: 1024px) {
  .main-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    transform: translateX(-100%);
    width: 280px;
    box-shadow: var(--shadow-lg);
    background-color: var(--bg-surface);
  }

  .sidebar.active {
    transform: translateX(0);
  }

  .content {
    grid-column: 1;
    padding: 30px 16px;
  }

  .mobile-toggle {
    display: flex;
  }
}
