/* ==========================================================================
   SISTEMA DE DISEÑO VISUAL - ING. JHONNATHA GOUVEIA
   Tokens Semánticos, Glassmorphism, Componentes y Accesibilidad WCAG 2.1 AA
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;700&family=Plus+Jakarta+Sans:wght@600;700;800&display=swap');

:root {
  --font-display: 'Plus Jakarta Sans', sans-serif;
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Modo Claro (Light Mode) */
  --bg-body: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #f1f5f9;
  --border-subtle: #e2e8f0;
  --border-medium: #cbd5e1;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-dim: #94a3b8;
  --accent-primary: #0284c7;
  --accent-hover: #0369a1;
  --accent-cyan: #0ea5e9;
  --accent-glow: rgba(14, 165, 233, 0.12);
  --card-shadow: 0 4px 20px -2px rgba(15, 23, 42, 0.05), 0 2px 6px -1px rgba(15, 23, 42, 0.03);
  --glass-bg: rgba(255, 255, 255, 0.85);
  --glass-border: rgba(226, 232, 240, 0.8);
}

html.dark, [data-theme="dark"] {
  /* Modo Oscuro (Dark Mode) */
  --bg-body: #030712;
  --bg-surface: #0b1329;
  --bg-surface-elevated: #111e3f;
  --border-subtle: #1e293b;
  --border-medium: #334155;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-dim: #64748b;
  --accent-primary: #38bdf8;
  --accent-hover: #0ea5e9;
  --accent-cyan: #38bdf8;
  --accent-glow: rgba(56, 189, 248, 0.15);
  --card-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
  --glass-bg: rgba(11, 19, 41, 0.85);
  --glass-border: rgba(30, 41, 59, 0.8);
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-body);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color 0.25s ease, color 0.25s ease;
  overflow-x: hidden;
}

h1, h2, h3, h4, .font-display {
  font-family: var(--font-display);
}

code, pre, .font-mono {
  font-family: var(--font-mono);
}

/* Glassmorphism Classes */
.glass-nav {
  background: var(--glass-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--glass-border);
}

.glass-card {
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--card-shadow);
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.glass-card:hover {
  border-color: var(--accent-cyan);
}

/* Hero Code Card */
.code-card {
  background: #0b1329;
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: 16px;
  box-shadow: 0 20px 40px -15px rgba(2, 132, 199, 0.35);
  color: #f8fafc;
}

/* Badges & Chips */
.chip-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 12px;
  border-radius: 9999px;
  background: rgba(2, 132, 199, 0.1);
  color: var(--accent-primary);
  border: 1px solid rgba(2, 132, 199, 0.25);
}

/* Text Gradient */
.text-gradient {
  background: linear-gradient(135deg, #0284c7 0%, #0ea5e9 50%, #38bdf8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Floating Action Button (FAB) */
.fab-bot {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  box-shadow: 0 8px 24px rgba(2, 132, 199, 0.45);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.fab-bot:hover {
  transform: scale(1.08) translateY(-2px);
  box-shadow: 0 12px 28px rgba(2, 132, 199, 0.6);
}

/* Bot Modal Popup */
.bot-modal {
  display: none;
  position: fixed;
  bottom: 90px;
  right: 24px;
  width: 360px;
  max-width: calc(100vw - 48px);
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: 18px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
  z-index: 1001;
  overflow: hidden;
  animation: slideUpFade 0.25s ease-out;
}

.bot-modal.active {
  display: block;
}

@keyframes slideUpFade {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Timeline Components */
.timeline-stem {
  position: relative;
  padding-left: 32px;
}

.timeline-stem::before {
  content: '';
  position: absolute;
  top: 8px;
  bottom: 8px;
  left: 10px;
  width: 2px;
  background: linear-gradient(to bottom, #0284c7, #0ea5e9, #38bdf8);
}

.timeline-dot {
  position: absolute;
  left: 2px;
  top: 6px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 3px solid #0284c7;
  box-shadow: 0 0 10px rgba(2, 132, 199, 0.5);
}

/* Accordion */
.accordion-header {
  cursor: pointer;
  user-select: none;
}

.accordion-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-out, opacity 0.25s ease;
  opacity: 0;
}

.accordion-body.open {
  max-height: 1500px;
  opacity: 1;
}

.accordion-chevron {
  transition: transform 0.25s ease;
}

.accordion-header.active .accordion-chevron {
  transform: rotate(180deg);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-body);
}
::-webkit-scrollbar-thumb {
  background: var(--border-medium);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent-primary);
}

/* ==========================================================================
   HIGH-CONTRAST THEME ADAPTATION FOR ACADEMIC CONTENT (SSA & AI MODULES)
   ========================================================================== */

.ssa-hero, .ai-hero {
  color: #ffffff !important;
  position: relative;
  z-index: 10;
}
.ssa-hero *, .ai-hero * {
  color: inherit;
}
.ssa-hero-title, .ai-hero h1 {
  color: #ffffff !important;
  text-shadow: 0 2px 10px rgba(0,0,0,0.5);
}
.ssa-intro-text, .ai-hero p {
  color: rgba(255, 255, 255, 0.95) !important;
}

/* Base styling for tables inside course modules */
.course-matrix-wrapper table, .ai-theory-block table {
  width: 100% !important;
  border-collapse: collapse;
  margin: 1.5rem 0;
  border-radius: 12px;
  overflow: hidden;
}

/* Light mode for course cards, accordions and content */
html:not(.dark) .course-matrix-wrapper,
html:not(.dark) .ssa-module-card, 
html:not(.dark) .ssa-micro-card, 
html:not(.dark) .ai-theory-block,
html:not(.dark) .ssa-content-card {
  background: #ffffff !important;
  color: #0f172a !important;
  border-color: #cbd5e1 !important;
}

html:not(.dark) .ssa-module-card h2, html:not(.dark) .ssa-module-card h3, html:not(.dark) .ssa-module-card h4,
html:not(.dark) .ai-theory-block h2, html:not(.dark) .ai-theory-block h3, html:not(.dark) .ai-theory-block h4,
html:not(.dark) .course-matrix-wrapper h2, html:not(.dark) .course-matrix-wrapper h3 {
  color: #0f172a !important;
}

html:not(.dark) .ssa-module-card p, html:not(.dark) .ai-theory-block p,
html:not(.dark) .ssa-module-card li, html:not(.dark) .ai-theory-block li,
html:not(.dark) .course-matrix-wrapper p, html:not(.dark) .course-matrix-wrapper li {
  color: #334155 !important;
}

/* Dark mode for course cards and content */
html.dark .course-matrix-wrapper,
html.dark .ssa-module-card, 
html.dark .ssa-micro-card, 
html.dark .ai-theory-block,
html.dark .ssa-content-card {
  background: #0b1329 !important;
  color: #f8fafc !important;
  border-color: #1e293b !important;
}

html.dark .ssa-module-card h2, html.dark .ssa-module-card h3, html.dark .ssa-module-card h4,
html.dark .ai-theory-block h2, html.dark .ai-theory-block h3, html.dark .ai-theory-block h4,
html.dark .course-matrix-wrapper h2, html.dark .course-matrix-wrapper h3 {
  color: #f8fafc !important;
}

html.dark .ssa-module-card p, html.dark .ai-theory-block p,
html.dark .ssa-module-card li, html.dark .ai-theory-block li,
html.dark .course-matrix-wrapper p, html.dark .course-matrix-wrapper li {
  color: #94a3b8 !important;
}

/* Academic Content Styling for Course Modules */
.academic-content h2, .academic-content h3, .academic-content h4 {
  font-family: var(--font-display);
  font-weight: 700;
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
}
html:not(.dark) .academic-content h2, 
html:not(.dark) .academic-content h3, 
html:not(.dark) .academic-content h4 {
  color: #0f172a;
}
html.dark .academic-content h2, 
html.dark .academic-content h3, 
html.dark .academic-content h4 {
  color: #f8fafc;
}

.academic-content p {
  line-height: 1.75;
  margin-bottom: 1rem;
}
html:not(.dark) .academic-content p {
  color: #334155;
}
html.dark .academic-content p {
  color: #cbd5e1;
}

.academic-content ul, .academic-content ol {
  margin-left: 1.25rem;
  margin-bottom: 1.25rem;
  line-height: 1.7;
}
.academic-content li {
  margin-bottom: 0.5rem;
}
html:not(.dark) .academic-content li {
  color: #334155;
}
html.dark .academic-content li {
  color: #cbd5e1;
}

.academic-content strong, .academic-content b {
  font-weight: 700;
}
html:not(.dark) .academic-content strong, html:not(.dark) .academic-content b {
  color: #0f172a;
}
html.dark .academic-content strong, html.dark .academic-content b {
  color: #ffffff;
}

.academic-content figure, .academic-content .ssa-image-wrap {
  margin: 1.75rem auto;
  text-align: center;
}
.academic-content figcaption, .academic-content .image-caption {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  margin-top: 0.5rem;
  color: #64748b;
}
html.dark .academic-content figcaption, html.dark .academic-content .image-caption {
  color: #94a3b8;
}
