/* =====================================================
   DHANAM FINANCE - Enterprise Documentation System
   Professional CSS Design System
   ===================================================== */

/* CSS Variables - Design Tokens */
:root {
  /* Colors - Light Theme */
  --color-primary: #2563eb;
  --color-primary-dark: #1d4ed8;
  --color-primary-light: #3b82f6;
  --color-secondary: #7c3aed;
  --color-accent: #06b6d4;
  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-error: #ef4444;
  
  /* Backgrounds */
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-tertiary: #f1f5f9;
  --bg-code: #1e293b;
  --bg-sidebar: #f8fafc;
  --bg-card: #ffffff;
  
  /* Text Colors */
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-tertiary: #64748b;
  --text-inverse: #ffffff;
  --text-code: #e2e8f0;
  
  /* Borders */
  --border-color: #e2e8f0;
  --border-light: #f1f5f9;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  
  /* Spacing */
  --sidebar-width: 280px;
  --header-height: 64px;
  --content-max-width: 900px;
  
  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  
  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 300ms ease;
  
  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
}

/* Dark Theme */
[data-theme="dark"] {
  --color-primary: #3b82f6;
  --color-primary-dark: #2563eb;
  --color-primary-light: #60a5fa;
  
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --bg-code: #0d1117;
  --bg-sidebar: #1e293b;
  --bg-card: #1e293b;
  
  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-tertiary: #94a3b8;
  
  --border-color: #334155;
  --border-light: #1e293b;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.7;
  min-height: 100vh;
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--color-primary-dark);
  text-decoration: underline;
}

/* =====================================================
   Layout Structure
   ===================================================== */
.docs-layout {
  display: flex;
  min-height: 100vh;
}

/* Header */
.docs-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  z-index: 100;
  display: flex;
  align-items: center;
  padding: 0 24px;
  backdrop-filter: blur(8px);
  background: rgba(255, 255, 255, 0.95);
}

[data-theme="dark"] .docs-header {
  background: rgba(15, 23, 42, 0.95);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--text-primary);
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 1.1rem;
}

.version-badge {
  font-size: 0.75rem;
  padding: 4px 8px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-weight: 500;
}

.header-center {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 0 32px;
}

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

/* Search */
.search-container {
  position: relative;
  width: 100%;
  max-width: 480px;
}

.search-input {
  width: 100%;
  padding: 10px 16px 10px 44px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  font-size: 0.9rem;
  color: var(--text-primary);
  transition: all var(--transition-fast);
}

.search-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

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

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  width: 18px;
  height: 18px;
}

.search-shortcut {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.75rem;
  padding: 2px 6px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  color: var(--text-tertiary);
  font-family: var(--font-mono);
}

/* Theme Toggle */
.theme-toggle {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.theme-toggle:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

/* Sidebar */
.docs-sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  width: var(--sidebar-width);
  height: calc(100vh - var(--header-height));
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  overflow-y: auto;
  padding: 24px 0;
  z-index: 50;
}

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

.sidebar-title {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  padding: 0 24px;
  margin-bottom: 8px;
}

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

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 24px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  transition: all var(--transition-fast);
  border-left: 3px solid transparent;
}

.sidebar-link:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  text-decoration: none;
}

.sidebar-link.active {
  background: rgba(37, 99, 235, 0.1);
  color: var(--color-primary);
  border-left-color: var(--color-primary);
  font-weight: 500;
}

.sidebar-link-icon {
  width: 18px;
  height: 18px;
  opacity: 0.7;
}

.sidebar-submenu {
  list-style: none;
  margin-left: 32px;
}

.sidebar-submenu .sidebar-link {
  padding: 6px 24px 6px 16px;
  font-size: 0.85rem;
  border-left: none;
}

/* Main Content */
.docs-main {
  margin-left: var(--sidebar-width);
  margin-top: var(--header-height);
  min-height: calc(100vh - var(--header-height));
  padding: 40px;
  background: var(--bg-primary);
}

.docs-content {
  max-width: var(--content-max-width);
  margin: 0 auto;
}

/* Breadcrumbs */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  color: var(--text-tertiary);
  margin-bottom: 24px;
}

.breadcrumb-separator {
  color: var(--border-color);
}

.breadcrumb-link {
  color: var(--text-tertiary);
}

.breadcrumb-link:hover {
  color: var(--color-primary);
}

.breadcrumb-current {
  color: var(--text-secondary);
}

/* =====================================================
   Typography
   ===================================================== */
h1, h2, h3, h4, h5, h6 {
  color: var(--text-primary);
  font-weight: 600;
  line-height: 1.3;
  margin-top: 2em;
  margin-bottom: 0.75em;
}

h1:first-child, h2:first-child, h3:first-child {
  margin-top: 0;
}

h1 {
  font-size: 2.25rem;
  font-weight: 700;
  letter-spacing: -0.025em;
}

h2 {
  font-size: 1.75rem;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

h3 {
  font-size: 1.375rem;
}

h4 {
  font-size: 1.125rem;
}

p {
  margin-bottom: 1.25em;
}

ul, ol {
  margin-bottom: 1.25em;
  padding-left: 1.5em;
}

li {
  margin-bottom: 0.5em;
}

/* =====================================================
   Code Blocks
   ===================================================== */
code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  color: var(--color-primary);
}

pre {
  background: var(--bg-code);
  border-radius: var(--radius-md);
  padding: 20px;
  overflow-x: auto;
  margin-bottom: 1.5em;
  position: relative;
}

pre code {
  background: none;
  padding: 0;
  color: var(--text-code);
  font-size: 0.875rem;
  line-height: 1.6;
}

.code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.05);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-tertiary);
}

.copy-button {
  padding: 4px 8px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: 0.75rem;
  transition: all var(--transition-fast);
}

.copy-button:hover {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}

/* =====================================================
   Tables
   ===================================================== */
table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5em;
  font-size: 0.9rem;
}

th, td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

th {
  background: var(--bg-secondary);
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

tr:hover td {
  background: var(--bg-secondary);
}

/* =====================================================
   Cards & Boxes
   ===================================================== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.feature-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: all var(--transition-base);
}

.feature-card:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.feature-icon {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  font-size: 1.5rem;
}

.feature-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.feature-description {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* =====================================================
   Alerts & Callouts
   ===================================================== */
.alert {
  padding: 16px 20px;
  border-radius: var(--radius-md);
  margin-bottom: 1.5em;
  border-left: 4px solid;
}

.alert-info {
  background: rgba(6, 182, 212, 0.1);
  border-color: var(--color-accent);
}

.alert-success {
  background: rgba(16, 185, 129, 0.1);
  border-color: var(--color-success);
}

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

.alert-error {
  background: rgba(239, 68, 68, 0.1);
  border-color: var(--color-error);
}

.alert-title {
  font-weight: 600;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.alert-content {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* =====================================================
   Badges & Tags
   ===================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 9999px;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.badge-primary {
  background: rgba(37, 99, 235, 0.1);
  color: var(--color-primary);
}

.badge-success {
  background: rgba(16, 185, 129, 0.1);
  color: var(--color-success);
}

.badge-warning {
  background: rgba(245, 158, 11, 0.1);
  color: var(--color-warning);
}

.badge-error {
  background: rgba(239, 68, 68, 0.1);
  color: var(--color-error);
}

.method-badge {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}

.method-get {
  background: rgba(16, 185, 129, 0.1);
  color: var(--color-success);
}

.method-post {
  background: rgba(37, 99, 235, 0.1);
  color: var(--color-primary);
}

.method-put {
  background: rgba(245, 158, 11, 0.1);
  color: var(--color-warning);
}

.method-delete {
  background: rgba(239, 68, 68, 0.1);
  color: var(--color-error);
}

/* =====================================================
   API Endpoint Styling
   ===================================================== */
.endpoint {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 24px;
  overflow: hidden;
}

.endpoint-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
}

.endpoint-path {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--text-primary);
}

.endpoint-body {
  padding: 20px;
}

.endpoint-description {
  margin-bottom: 16px;
  color: var(--text-secondary);
}

/* =====================================================
   Mermaid Diagrams
   ===================================================== */
.mermaid {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 24px;
  margin-bottom: 24px;
  text-align: center;
}

/* =====================================================
   Table of Contents
   ===================================================== */
.toc {
  position: sticky;
  top: calc(var(--header-height) + 24px);
  padding: 20px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
}

.toc-title {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  margin-bottom: 12px;
}

.toc-list {
  list-style: none;
  padding: 0;
}

.toc-link {
  display: block;
  padding: 6px 0;
  color: var(--text-secondary);
  transition: color var(--transition-fast);
}

.toc-link:hover {
  color: var(--color-primary);
  text-decoration: none;
}

.toc-link.active {
  color: var(--color-primary);
  font-weight: 500;
}

/* =====================================================
   Landing Page Hero
   ===================================================== */
.hero {
  text-align: center;
  padding: 80px 40px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  color: white;
  border-radius: var(--radius-xl);
  margin-bottom: 48px;
}

.hero h1 {
  font-size: 3rem;
  color: white;
  margin-bottom: 16px;
}

.hero-subtitle {
  font-size: 1.25rem;
  opacity: 0.9;
  max-width: 600px;
  margin: 0 auto 32px;
}

.hero-buttons {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  font-size: 1rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  border: none;
}

.btn-primary {
  background: white;
  color: var(--color-primary);
}

.btn-primary:hover {
  background: var(--bg-secondary);
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.3);
  text-decoration: none;
}

/* =====================================================
   Search Modal
   ===================================================== */
.search-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 100px 20px;
  z-index: 200;
}

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

.search-modal-content {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 600px;
  max-height: 70vh;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.search-modal-input {
  width: 100%;
  padding: 20px 24px;
  border: none;
  font-size: 1.1rem;
  background: transparent;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-color);
}

.search-modal-input:focus {
  outline: none;
}

.search-results {
  max-height: calc(70vh - 70px);
  overflow-y: auto;
  padding: 12px;
}

.search-result-item {
  display: block;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  color: var(--text-primary);
  transition: background var(--transition-fast);
}

.search-result-item:hover {
  background: var(--bg-secondary);
  text-decoration: none;
}

.search-result-title {
  font-weight: 600;
  margin-bottom: 4px;
}

.search-result-excerpt {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* =====================================================
   Responsive Design
   ===================================================== */
@media (max-width: 1024px) {
  .docs-sidebar {
    transform: translateX(-100%);
    transition: transform var(--transition-base);
  }
  
  .docs-sidebar.open {
    transform: translateX(0);
  }
  
  .docs-main {
    margin-left: 0;
  }
  
  .header-center {
    display: none;
  }
}

@media (max-width: 768px) {
  .hero {
    padding: 48px 24px;
  }
  
  .hero h1 {
    font-size: 2rem;
  }
  
  h1 {
    font-size: 1.75rem;
  }
  
  h2 {
    font-size: 1.5rem;
  }
  
  .docs-main {
    padding: 24px;
  }
  
  .card-grid {
    grid-template-columns: 1fr;
  }
}

/* =====================================================
   Print Styles
   ===================================================== */
@media print {
  .docs-header,
  .docs-sidebar,
  .theme-toggle {
    display: none !important;
  }
  
  .docs-main {
    margin-left: 0;
    margin-top: 0;
  }
}
