/* ==========================================================================
   Database Guide for Non-Tech Users - Design System & Stylesheet
   ========================================================================== */

/* Google Fonts Import */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@300;400;500;600;700;800&family=Fira+Code:wght@400;500;600&display=swap');

/* CSS Root Variables (Theme colors & tokens) */
:root {
  /* Color Palette - Light Mode */
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;
  --bg-card: #ffffff;
  --bg-hover: #e2e8f0;
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-inverted: #ffffff;
  
  --accent-primary: #2563eb;
  --accent-primary-hover: #1d4ed8;
  --accent-light: #eff6ff;
  --accent-border: #bfdbfe;
  
  --accent-secondary: #0d9488;
  --accent-secondary-light: #ccfbf1;
  
  --accent-purple: #7c3aed;
  --accent-purple-light: #f3e8ff;
  
  --accent-amber: #d97706;
  --accent-amber-light: #fef3c7;
  
  --border-color: #e2e8f0;
  --border-color-strong: #cbd5e1;
  
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;
  
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --font-main: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-code: 'Fira Code', monospace;
}

/* Dark Theme Overrides */
[data-theme="dark"] {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --bg-card: #1e293b;
  --bg-hover: #334155;
  
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-inverted: #0f172a;
  
  --accent-primary: #3b82f6;
  --accent-primary-hover: #60a5fa;
  --accent-light: rgba(59, 130, 246, 0.15);
  --accent-border: rgba(59, 130, 246, 0.3);
  
  --accent-secondary: #14b8a6;
  --accent-secondary-light: rgba(20, 184, 166, 0.15);
  
  --accent-purple: #a855f7;
  --accent-purple-light: rgba(168, 85, 247, 0.15);
  
  --accent-amber: #f59e0b;
  --accent-amber-light: rgba(245, 158, 11, 0.15);
  
  --border-color: #334155;
  --border-color-strong: #475569;
  
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
}

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

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

body {
  font-family: var(--font-main);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.7;
  letter-spacing: -0.01em;
  transition: background-color 0.3s ease, color 0.3s ease;
  word-break: keep-all;
}

/* Header & Navigation Bar */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  transition: var(--transition);
}

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

.nav-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 800;
  font-size: 1.25rem;
  color: var(--accent-primary);
  text-decoration: none;
}

.nav-brand svg {
  width: 28px;
  height: 28px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  list-style: none;
}

.nav-links a {
  text-decoration: none;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.95rem;
  transition: var(--transition);
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-sm);
}

.nav-links a:hover {
  color: var(--accent-primary);
  background-color: var(--accent-light);
}

/* Theme Toggle Button */
.theme-toggle-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  transition: var(--transition);
}

.theme-toggle-btn:hover {
  background-color: var(--bg-hover);
  transform: translateY(-1px);
}

/* Main Container Layout */
.page-wrapper {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 2.5rem;
}

/* Floating Sidebar TOC */
.sidebar {
  position: sticky;
  top: 5rem;
  height: fit-content;
}

.toc-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.toc-title {
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.toc-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.toc-list a {
  display: block;
  padding: 0.5rem 0.75rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  border-radius: var(--radius-sm);
  border-left: 3px solid transparent;
  transition: var(--transition);
}

.toc-list a:hover, .toc-list a.active {
  color: var(--accent-primary);
  background-color: var(--accent-light);
  border-left-color: var(--accent-primary);
  font-weight: 600;
}

/* Content Area */
.content-area {
  min-width: 0;
}

/* Hero Section */
.hero-section {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.08) 0%, rgba(13, 148, 136, 0.08) 100%);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-lg);
  padding: 3rem 2.5rem;
  margin-bottom: 3rem;
  position: relative;
  overflow: hidden;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.85rem;
  background-color: var(--accent-light);
  border: 1px solid var(--accent-border);
  color: var(--accent-primary);
  font-size: 0.85rem;
  font-weight: 700;
  border-radius: var(--radius-full);
  margin-bottom: 1.25rem;
}

.hero-title {
  font-size: 2.25rem;
  font-weight: 800;
  line-height: 1.3;
  margin-bottom: 1rem;
  color: var(--text-primary);
}

.hero-title span {
  color: var(--accent-primary);
  background: linear-gradient(120deg, var(--accent-primary), var(--accent-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-subtitle {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-bottom: 2rem;
  max-width: 750px;
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
}

.meta-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 500;
}

.meta-item svg {
  color: var(--accent-primary);
}

/* Section Cards */
.guide-section {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  margin-bottom: 2.5rem;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.guide-section:hover {
  box-shadow: var(--shadow-md);
}

.section-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.75rem;
  padding-bottom: 1.25rem;
  border-bottom: 2px solid var(--bg-tertiary);
}

.section-number {
  width: 42px;
  height: 42px;
  background-color: var(--accent-primary);
  color: white;
  font-weight: 800;
  font-size: 1.2rem;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.section-title-wrap h2 {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}

.section-title-wrap p {
  font-size: 0.95rem;
  color: var(--text-muted);
}

/* Visual Analogy Box */
.analogy-box {
  background: var(--bg-tertiary);
  border-left: 4px solid var(--accent-secondary);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: 1.5rem;
  margin: 1.5rem 0;
}

.analogy-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  color: var(--accent-secondary);
  margin-bottom: 0.75rem;
  font-size: 1rem;
}

.analogy-content {
  font-size: 1rem;
  color: var(--text-secondary);
  line-height: 1.7;
}

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

.comp-card {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  text-align: center;
  transition: var(--transition);
}

.comp-card:hover {
  transform: translateY(-4px);
  border-color: var(--accent-border);
}

.comp-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
  font-size: 1.5rem;
}

.comp-icon.memo { background-color: #fee2e2; color: #dc2626; }
.comp-icon.excel { background-color: #dcfce7; color: #16a34a; }
.comp-icon.db { background-color: #dbeafe; color: #2563eb; }

[data-theme="dark"] .comp-icon.memo { background-color: rgba(220, 38, 38, 0.2); }
[data-theme="dark"] .comp-icon.excel { background-color: rgba(22, 163, 74, 0.2); }
[data-theme="dark"] .comp-icon.db { background-color: rgba(37, 99, 235, 0.2); }

.comp-card h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.comp-card p {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* Feature Grid */
.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-top: 1.5rem;
}

.feature-card {
  padding: 1.25rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background-color: var(--bg-secondary);
}

.feature-card .feat-num {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--accent-primary);
  text-transform: uppercase;
  margin-bottom: 0.3rem;
}

.feature-card h4 {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.feature-card p {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* DB Types Tabs & Cards */
.type-tabs {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.75rem;
}

.type-tab-btn {
  padding: 0.6rem 1.2rem;
  border: 1px solid var(--border-color);
  background-color: var(--bg-tertiary);
  color: var(--text-secondary);
  border-radius: var(--radius-full);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.type-tab-btn:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.type-tab-btn.active {
  background-color: var(--accent-primary);
  color: white;
  border-color: var(--accent-primary);
}

.db-type-detail {
  display: none;
  animation: fadeIn 0.3s ease-in-out forwards;
}

.db-type-detail.active {
  display: block;
}

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

.db-card-main {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.75rem;
  background-color: var(--bg-primary);
}

.db-card-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.db-tag {
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 700;
}

.db-tag.rdb { background-color: var(--accent-light); color: var(--accent-primary); }
.db-tag.nosql { background-color: var(--accent-purple-light); color: var(--accent-purple); }

.db-card-main h3 {
  font-size: 1.35rem;
  font-weight: 700;
}

.db-card-main p.desc {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
}

.examples-badge-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.db-brand-badge {
  padding: 0.4rem 0.8rem;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color-strong);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* Interactive SQL Playground */
.crud-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin: 1.5rem 0;
}

@media (max-width: 768px) {
  .crud-container {
    grid-template-columns: 1fr;
  }
}

.crud-selector {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.crud-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
}

.crud-btn:hover {
  border-color: var(--accent-primary);
  background-color: var(--accent-light);
}

.crud-btn.active {
  border-color: var(--accent-primary);
  background-color: var(--accent-light);
  box-shadow: 0 0 0 2px var(--accent-primary);
}

.crud-badge {
  font-family: var(--font-code);
  font-size: 0.8rem;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  color: white;
  font-weight: 700;
}

.crud-badge.c { background-color: #16a34a; }
.crud-badge.r { background-color: #2563eb; }
.crud-badge.u { background-color: #d97706; }
.crud-badge.d { background-color: #dc2626; }

.crud-display {
  background-color: #0f172a;
  color: #f8fafc;
  border-radius: var(--radius-md);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow-md);
}

.code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: #94a3b8;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #334155;
}

.code-block {
  font-family: var(--font-code);
  font-size: 1rem;
  color: #60a5fa;
  background-color: #1e293b;
  padding: 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  white-space: pre-wrap;
  word-break: break-all;
}

.crud-explanation {
  font-size: 0.9rem;
  color: #cbd5e1;
  line-height: 1.6;
}

/* Service Flow Visualizer */
.flow-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 2rem 0;
  padding: 1.5rem;
  background-color: var(--bg-tertiary);
  border-radius: var(--radius-md);
  overflow-x: auto;
}

.flow-step {
  flex: 1;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem 1rem;
  text-align: center;
  min-width: 140px;
}

.flow-step-num {
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--accent-primary);
  margin-bottom: 0.2rem;
}

.flow-step-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
}

.flow-step-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.flow-arrow {
  font-size: 1.5rem;
  color: var(--text-muted);
  font-weight: 800;
}

/* Quiz Section */
.quiz-wrapper {
  background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-tertiary) 100%);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.75rem;
  margin-top: 1.5rem;
}

.quiz-question {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  color: var(--text-primary);
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.quiz-option-btn {
  padding: 0.85rem 1.2rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background-color: var(--bg-card);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  text-align: left;
  transition: var(--transition);
}

.quiz-option-btn:hover {
  background-color: var(--bg-hover);
  border-color: var(--accent-primary);
}

.quiz-option-btn.correct {
  background-color: #dcfce7 !important;
  border-color: #16a34a !important;
  color: #15803d !important;
  font-weight: 700;
}

.quiz-option-btn.wrong {
  background-color: #fee2e2 !important;
  border-color: #dc2626 !important;
  color: #b91c1c !important;
}

.quiz-feedback {
  margin-top: 1rem;
  padding: 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  display: none;
}

.quiz-feedback.show {
  display: block;
}

.quiz-feedback.success {
  background-color: #dcfce7;
  color: #15803d;
  border: 1px solid #86efac;
}

.quiz-feedback.error {
  background-color: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fca5a5;
}

/* Summary Box */
.summary-card {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  color: white;
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  margin-top: 3rem;
  box-shadow: var(--shadow-lg);
}

.summary-card h3 {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 1.25rem;
  color: #60a5fa;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.summary-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.summary-list li {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  font-size: 1.05rem;
  line-height: 1.6;
}

.summary-list li svg {
  color: #10b981;
  flex-shrink: 0;
  margin-top: 0.2rem;
}

/* Footer */
footer {
  margin-top: 4rem;
  padding: 2.5rem 0;
  border-top: 1px solid var(--border-color);
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Responsive Media Queries */
@media (max-width: 992px) {
  .page-wrapper {
    grid-template-columns: 1fr;
  }
  
  .sidebar {
    display: none; /* Mobile navigation bar or top quick links can be used */
  }
}

@media (max-width: 640px) {
  .hero-section {
    padding: 2rem 1.5rem;
  }
  
  .hero-title {
    font-size: 1.75rem;
  }
  
  .guide-section {
    padding: 1.5rem;
  }
  
  .flow-container {
    flex-direction: column;
  }
  
  .flow-arrow {
    transform: rotate(90deg);
  }
}
