/* ============================================
   Raffaello Documentation Site - Styles
   Modern, Beautiful, Bilingual
   ============================================ */

/* CSS Variables */
:root {
  /* Colors */
  --color-primary: #6366f1;
  --color-primary-dark: #4f46e5;
  --color-primary-light: #818cf8;
  --color-secondary: #10b981;
  --color-warning: #f59e0b;
  --color-danger: #ef4444;

  /* Backgrounds */
  --bg-gradient-start: #f8fafc;
  --bg-gradient-end: #e2e8f0;
  --bg-card: #ffffff;
  --bg-code: #1e293b;
  --bg-sidebar: #f1f5f9;

  /* Text */
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --text-inverse: #f8fafc;

  /* Borders */
  --border-color: #e2e8f0;
  --border-radius: 12px;
  --border-radius-sm: 8px;
  --border-radius-lg: 16px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

  /* Typography */
  --font-sans: 'Inter', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* Spacing */
  --header-height: 64px;
  --sidebar-width: 280px;
  --toc-width: 220px;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 350ms ease;
}

/* Dark Mode */
[data-theme="dark"] {
  --bg-gradient-start: #0f172a;
  --bg-gradient-end: #1e293b;
  --bg-card: #1e293b;
  --bg-sidebar: #0f172a;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border-color: #334155;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-primary);
  background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
  min-height: 100vh;
}

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

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

/* ============================================
   Header
   ============================================ */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  z-index: 100;
}

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

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

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

.logo:hover {
  color: var(--text-primary);
}

.logo-img {
  width: 36px;
  height: 36px;
}

.nav {
  display: flex;
  align-items: center;
  gap: 32px;
}

.nav-link {
  color: var(--text-secondary);
  font-weight: 500;
  padding: 8px 0;
  position: relative;
}

.nav-link::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--color-primary);
  transform: scaleX(0);
  transition: transform var(--transition-fast);
}

.nav-link:hover,
.nav-link.active {
  color: var(--color-primary);
}

.nav-link:hover::after,
.nav-link.active::after {
  transform: scaleX(1);
}

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

.lang-switch {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 9999px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition-fast);
}

.lang-switch:hover {
  border-color: var(--color-primary);
}

.lang-en, .lang-zh {
  transition: color var(--transition-fast);
}

.lang-divider {
  color: var(--text-muted);
}

[data-lang="en"] .lang-en {
  color: var(--color-primary);
  font-weight: 600;
}

[data-lang="zh"] .lang-zh {
  color: var(--color-primary);
  font-weight: 600;
}

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

.theme-toggle:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.icon-moon {
  display: none;
}

[data-theme="dark"] .icon-sun {
  display: none;
}

[data-theme="dark"] .icon-moon {
  display: block;
}

/* ============================================
   Main Content
   ============================================ */
.main {
  padding-top: var(--header-height);
  min-height: 100vh;
}

/* ============================================
   Home Section - Hero
   ============================================ */
.home-section {
  padding: 0 24px;
}

.hero {
  max-width: 1200px;
  margin: 0 auto;
  padding: 80px 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 60px;
  align-items: center;
}

.hero-badge {
  display: inline-block;
  padding: 6px 16px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(99, 102, 241, 0.2));
  color: var(--color-primary);
  font-size: 14px;
  font-weight: 600;
  border-radius: 9999px;
  margin-bottom: 24px;
}

.hero-title {
  font-size: 3.5rem;
  font-weight: 700;
  line-height: 1.1;
  margin-bottom: 24px;
}

.hero-title-highlight {
  display: block;
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-description {
  font-size: 1.25rem;
  color: var(--text-secondary);
  margin-bottom: 32px;
  max-width: 500px;
}

.hero-actions {
  display: flex;
  gap: 16px;
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
  color: white;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
  color: white;
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.btn-lg {
  padding: 16px 32px;
  font-size: 18px;
}

.hero-visual {
  display: flex;
  justify-content: center;
  align-items: center;
}

.hero-image {
  max-width: 100%;
  height: auto;
  filter: drop-shadow(0 20px 40px rgba(99, 102, 241, 0.2));
}

.hero-mascot {
  max-width: 400px;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-15px); }
}

/* ============================================
   Home Section - Features
   ============================================ */
.features {
  max-width: 1200px;
  margin: 0 auto;
  padding: 80px 0;
}

.section-title {
  font-size: 2.5rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 16px;
}

.section-subtitle {
  font-size: 1.125rem;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 48px;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
  margin-top: 48px;
}

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

.feature-card:hover {
  transform: translateY(-8px);
  box-shadow: var(--shadow-xl);
  border-color: transparent;
}

.feature-icon {
  width: 64px;
  height: 64px;
  border-radius: var(--border-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}

.feature-icon-parallel {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(99, 102, 241, 0.2));
  color: var(--color-primary);
}

.feature-icon-agents {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(16, 185, 129, 0.2));
  color: var(--color-secondary);
}

.feature-icon-merge {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.1), rgba(245, 158, 11, 0.2));
  color: var(--color-warning);
}

.feature-icon-workflow {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.1), rgba(239, 68, 68, 0.2));
  color: var(--color-danger);
}

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

.feature-description {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

/* ============================================
   Home Section - Architecture Preview
   ============================================ */
.architecture-preview {
  max-width: 1200px;
  margin: 0 auto;
  padding: 80px 0;
}

.architecture-diagram {
  display: flex;
  justify-content: center;
  margin-top: 48px;
}

.architecture-image {
  max-width: 100%;
  height: auto;
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-xl);
}

/* ============================================
   Home Section - Comparison
   ============================================ */
.comparison-section {
  max-width: 1200px;
  margin: 0 auto;
  padding: 80px 0;
}

.comparison-container {
  display: flex;
  justify-content: center;
  margin-top: 48px;
}

.comparison-image {
  max-width: 100%;
  height: auto;
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-xl);
}

/* ============================================
   Home Section - CTA
   ============================================ */
.cta-section {
  max-width: 800px;
  margin: 0 auto;
  padding: 80px 24px;
  text-align: center;
}

.cta-title {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 16px;
}

.cta-description {
  font-size: 1.25rem;
  color: var(--text-secondary);
  margin-bottom: 32px;
}

/* ============================================
   Documentation Section
   ============================================ */
.docs-section {
  display: flex;
  min-height: calc(100vh - var(--header-height));
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  position: fixed;
  top: var(--header-height);
  left: 0;
  bottom: 0;
  overflow-y: auto;
  transition: transform var(--transition-normal);
  z-index: 50;
}

.sidebar-header {
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-title {
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: var(--text-secondary);
}

.sidebar-nav {
  padding: 16px;
}

.sidebar-link {
  display: block;
  padding: 12px 16px;
  color: var(--text-secondary);
  font-weight: 500;
  border-radius: var(--border-radius-sm);
  margin-bottom: 4px;
  transition: all var(--transition-fast);
}

.sidebar-link:hover {
  background: rgba(99, 102, 241, 0.1);
  color: var(--color-primary);
}

.sidebar-link.active {
  background: var(--color-primary);
  color: white;
}

/* Content */
.content {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  min-width: 0;
}

.content-header {
  padding: 24px 32px 0;
}

.breadcrumb {
  font-size: 0.875rem;
  color: var(--text-muted);
}

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

.breadcrumb span {
  margin: 0 8px;
}

/* Article */
.article {
  flex: 1;
  max-width: 800px;
  padding: 24px 32px 80px;
  min-width: 0;
}

.article h1 {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
}

.article h2 {
  font-size: 1.75rem;
  font-weight: 600;
  margin-top: 48px;
  margin-bottom: 16px;
  padding-top: 24px;
  border-top: 1px solid var(--border-color);
}

.article h3 {
  font-size: 1.375rem;
  font-weight: 600;
  margin-top: 32px;
  margin-bottom: 12px;
}

.article h4 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-top: 24px;
  margin-bottom: 8px;
}

.article p {
  margin-bottom: 16px;
}

.article ul, .article ol {
  margin-bottom: 16px;
  padding-left: 24px;
}

.article li {
  margin-bottom: 8px;
}

.article code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--bg-code);
  color: #e2e8f0;
  padding: 2px 6px;
  border-radius: 4px;
}

.article pre {
  background: var(--bg-code);
  border-radius: var(--border-radius);
  padding: 20px;
  overflow-x: auto;
  margin-bottom: 24px;
}

.article pre code {
  background: none;
  padding: 0;
  font-size: 0.875rem;
  line-height: 1.7;
}

.article blockquote {
  border-left: 4px solid var(--color-primary);
  padding-left: 20px;
  margin: 24px 0;
  color: var(--text-secondary);
  font-style: italic;
}

.article table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
}

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

.article th {
  font-weight: 600;
  background: var(--bg-sidebar);
}

.article img {
  max-width: 100%;
  height: auto;
  border-radius: var(--border-radius);
  margin: 16px 0;
}

.article a {
  color: var(--color-primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.article a:hover {
  text-decoration: none;
}

/* Table of Contents */
.toc {
  width: var(--toc-width);
  padding: 24px;
  position: sticky;
  top: calc(var(--header-height) + 24px);
  max-height: calc(100vh - var(--header-height) - 48px);
  overflow-y: auto;
}

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

.toc-nav a {
  display: block;
  padding: 6px 0;
  font-size: 0.875rem;
  color: var(--text-secondary);
  transition: color var(--transition-fast);
}

.toc-nav a:hover,
.toc-nav a.active {
  color: var(--color-primary);
}

.toc-nav a.toc-h3 {
  padding-left: 16px;
  font-size: 0.8125rem;
}

/* ============================================
   Footer
   ============================================ */
.footer {
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
  padding: 48px 24px;
  text-align: center;
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
}

.footer-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 16px;
}

.footer-logo-img {
  width: 32px;
  height: 32px;
}

.footer-logo-text {
  font-weight: 700;
  font-size: 1.25rem;
}

.footer-text {
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.footer-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.footer-links a {
  color: var(--text-secondary);
}

.footer-links a:hover {
  color: var(--color-primary);
}

.footer-divider {
  color: var(--text-muted);
}

/* ============================================
   Responsive Design
   ============================================ */
@media (max-width: 1200px) {
  .hero {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .hero-description {
    margin-left: auto;
    margin-right: auto;
  }

  .hero-actions {
    justify-content: center;
  }

  .hero-visual {
    order: -1;
  }

  .hero-image {
    max-width: 500px;
  }

  .features-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .toc {
    display: none;
  }
}

@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
  }

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

  .sidebar-toggle {
    display: block;
  }

  .content {
    margin-left: 0;
  }

  .nav {
    display: none;
  }
}

@media (max-width: 640px) {
  .hero {
    padding: 40px 0;
  }

  .hero-title {
    font-size: 2.5rem;
  }

  .hero-description {
    font-size: 1rem;
  }

  .hero-actions {
    flex-direction: column;
  }

  .features-grid {
    grid-template-columns: 1fr;
  }

  .section-title {
    font-size: 2rem;
  }

  .cta-title {
    font-size: 1.75rem;
  }

  .article {
    padding: 16px 20px 60px;
  }

  .article h1 {
    font-size: 2rem;
  }

  .article h2 {
    font-size: 1.5rem;
  }
}

/* ============================================
   Scrollbar Styling
   ============================================ */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-gradient-start);
}

::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* ============================================
   Animations
   ============================================ */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.hero-content {
  animation: fadeIn 0.6s ease-out;
}

.hero-visual {
  animation: fadeIn 0.6s ease-out 0.2s both;
}

.feature-card {
  animation: fadeIn 0.6s ease-out;
  animation-fill-mode: both;
}

.feature-card:nth-child(1) { animation-delay: 0.1s; }
.feature-card:nth-child(2) { animation-delay: 0.2s; }
.feature-card:nth-child(3) { animation-delay: 0.3s; }
.feature-card:nth-child(4) { animation-delay: 0.4s; }

/* Loading state */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
}

.loading::after {
  content: '';
  width: 32px;
  height: 32px;
  border: 3px solid var(--border-color);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
