/* ==========================================================================
   FasORM Documentation Theme & Design System
   ========================================================================== */

:root {
  --bg-dark: #0b0f19;
  --bg-surface: #111827;
  --bg-card: rgba(17, 24, 39, 0.75);
  --bg-card-hover: rgba(31, 41, 55, 0.85);
  --border-color: #1f2937;
  --border-highlight: #374151;

  --text-main: #f9fafb;
  --text-muted: #9ca3af;
  --text-subtle: #6b7280;

  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-glow: rgba(99, 102, 241, 0.25);
  --accent-purple: #8b5cf6;
  --accent-cyan: #06b6d4;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;

  --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'Fira Code', Consolas, Monaco, "Andale Mono", monospace;

  --sidebar-width: 280px;
  --topbar-height: 64px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
}

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

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-sans);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

a:hover {
  color: var(--accent-purple);
}

/* ==========================================================================
   Layout Components
   ========================================================================== */

#app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-height);
  background: rgba(11, 15, 25, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  z-index: 1000;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
}

.header-brand .logo-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--primary), var(--accent-purple));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 1.1rem;
  box-shadow: 0 0 12px var(--primary-glow);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.search-trigger {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.search-trigger:hover {
  border-color: var(--primary);
  color: var(--text-main);
}

.kbd-shortcut {
  background: var(--bg-dark);
  border: 1px solid var(--border-highlight);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-size: 0.75rem;
  color: var(--text-subtle);
}

.version-badge {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

/* Sidebar */
#app-sidebar {
  position: fixed;
  top: var(--topbar-height);
  bottom: 0;
  left: 0;
  width: var(--sidebar-width);
  background: var(--bg-dark);
  border-right: 1px solid var(--border-color);
  overflow-y: auto;
  padding: 1.5rem 1rem;
  z-index: 900;
}

.sidebar-group {
  margin-bottom: 1.5rem;
}

.sidebar-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-subtle);
  margin-bottom: 0.5rem;
  padding-left: 0.5rem;
}

.sidebar-nav {
  list-style: none;
}

.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.15s ease;
}

.sidebar-nav li a:hover {
  background: var(--bg-surface);
  color: var(--text-main);
}

.sidebar-nav li a.active {
  background: var(--primary-glow);
  color: #fff;
  border-left: 3px solid var(--primary);
  font-weight: 600;
}

/* Main Content Area */
#app-main {
  margin-top: var(--topbar-height);
  margin-left: var(--sidebar-width);
  min-height: calc(100vh - var(--topbar-height));
  padding: 2.5rem 3rem 5rem 3rem;
  max-width: 1100px;
}

.doc-hero {
  margin-bottom: 3rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border-color);
}

.doc-hero h1 {
  font-size: 2.75rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #fff 30%, var(--text-muted));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 0.75rem;
}

.doc-hero p {
  font-size: 1.15rem;
  color: var(--text-muted);
  max-width: 750px;
}

/* Sections */
.doc-section {
  margin-bottom: 3.5rem;
}

.doc-section h2 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.doc-section h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 1.75rem 0 0.75rem 0;
  color: var(--text-main);
}

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

/* Cards Grid */
.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
  margin: 1.5rem 0;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  transition: all 0.25s ease;
}

.card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-highlight);
  transform: translateY(-2px);
}

.card-icon {
  width: 40px;
  height: 40px;
  background: var(--primary-glow);
  color: var(--primary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  margin-bottom: 1rem;
}

.card h3 {
  margin: 0 0 0.5rem 0;
  font-size: 1.1rem;
}

.card p {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0;
}

/* Callout Alerts */
.alert {
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  margin: 1.5rem 0;
  border-left: 4px solid;
  background: var(--bg-surface);
}

.alert-note {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.08);
}

.alert-tip {
  border-color: var(--accent-emerald);
  background: rgba(16, 185, 129, 0.08);
}

.alert-warning {
  border-color: var(--accent-amber);
  background: rgba(245, 158, 11, 0.08);
}

.alert-title {
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 0.3rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.alert-note .alert-title { color: var(--primary); }
.alert-tip .alert-title { color: var(--accent-emerald); }
.alert-warning .alert-title { color: var(--accent-amber); }

/* Code Blocks */
.code-container {
  position: relative;
  margin: 1.25rem 0;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  overflow: hidden;
  background: #060911;
}

.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1rem;
  background: #0e131f;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.8rem;
  color: var(--text-subtle);
  font-family: var(--font-mono);
}

.copy-btn {
  background: transparent;
  border: 1px solid var(--border-highlight);
  color: var(--text-muted);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.copy-btn:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

pre {
  padding: 1.25rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.5;
  color: #e2e8f0;
}

code {
  font-family: var(--font-mono);
}

:not(pre) > code {
  background: rgba(31, 41, 55, 0.8);
  color: var(--accent-cyan);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.85em;
  border: 1px solid var(--border-color);
}

/* Syntax Highlighting Tokens */
.token-kw { color: #f43f5e; font-weight: 600; }
.token-cls { color: #38bdf8; font-weight: 600; }
.token-str { color: #34d399; }
.token-num { color: #fbbf24; }
.token-fn { color: #a78bfa; }
.token-cm { color: #6b7280; font-style: italic; }

/* Table Styling */
.table-wrapper {
  overflow-x: auto;
  margin: 1.5rem 0;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

th {
  background: var(--bg-surface);
  color: var(--text-main);
  padding: 0.75rem 1rem;
  font-weight: 600;
  border-bottom: 1px solid var(--border-color);
}

td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-muted);
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: rgba(31, 41, 55, 0.4);
}

/* Search Modal */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 100px;
  z-index: 2000;
}

.modal-backdrop.active {
  display: flex;
}

.search-modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-highlight);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 600px;
  overflow: hidden;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
}

.search-input-box {
  display: flex;
  align-items: center;
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
  gap: 0.75rem;
}

.search-input-box input {
  background: transparent;
  border: none;
  outline: none;
  color: #fff;
  font-size: 1.1rem;
  width: 100%;
}

.search-results {
  max-height: 350px;
  overflow-y: auto;
  padding: 0.5rem;
}

.search-result-item {
  display: block;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: all 0.15s ease;
}

.search-result-item:hover {
  background: var(--primary-glow);
  color: #fff;
}

.search-result-item .res-title {
  font-weight: 600;
  color: var(--text-main);
}

.search-result-item .res-desc {
  font-size: 0.8rem;
  color: var(--text-subtle);
}

/* Responsive Breakpoints */
@media (max-width: 768px) {
  #app-sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }

  #app-sidebar.open {
    transform: translateX(0);
  }

  #app-main {
    margin-left: 0;
    padding: 1.5rem;
  }
}
