/* ============================================================
   HDB COPIA E COLA – Design System
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── Variables ─────────────────────────────────────────────── */
:root {
  --bg-base:       #0a0d14;
  --bg-surface:    #111520;
  --bg-elevated:   #181d2e;
  --bg-card:       #1e2438;
  --bg-hover:      #252c42;

  --accent-1:      #4f8ef7;
  --accent-2:      #7c5af7;
  --accent-glow:   rgba(79, 142, 247, 0.18);
  --accent-grad:   linear-gradient(135deg, #4f8ef7 0%, #7c5af7 100%);

  --text-primary:   #e8eaf2;
  --text-secondary: #8b93b0;
  --text-muted:     #4e5672;
  --text-inverse:   #ffffff;

  --border:        rgba(255,255,255,0.07);
  --border-accent: rgba(79,142,247,0.35);

  --code-bg:       #0d1117;
  --code-border:   rgba(255,255,255,0.08);

  --success:       #22d3a0;
  --warning:       #f5a623;
  --danger:        #f75a5a;

  --sidebar-w:     280px;
  --header-h:      64px;
  --radius:        12px;
  --radius-sm:     8px;
  --transition:    0.2s ease;
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
}
a { color: var(--accent-1); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-hover); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-1); }

/* ══════════════════════════════════════════════════════════════
   LAYOUT
══════════════════════════════════════════════════════════════ */

.layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ───────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-header {
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.logo-icon {
  width: 36px; height: 36px;
  background: var(--accent-grad);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  box-shadow: 0 0 20px var(--accent-glow);
  flex-shrink: 0;
}

.logo-text {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.logo-sub {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
  display: block;
  margin-top: 1px;
}

.sidebar-search {
  margin-top: 16px;
  position: relative;
}

.sidebar-search input {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px 8px 34px;
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition);
}
.sidebar-search input::placeholder { color: var(--text-muted); }
.sidebar-search input:focus { border-color: var(--accent-1); }

.sidebar-search .search-icon {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 14px;
  pointer-events: none;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0;
}

/* Module accordion */
.module-group { margin-bottom: 4px; }

.module-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  cursor: pointer;
  user-select: none;
  border-radius: 0;
  transition: background var(--transition);
}
.module-header:hover { background: var(--bg-elevated); }

.module-info { display: flex; align-items: center; gap: 8px; }

.module-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent-grad);
  flex-shrink: 0;
}

.module-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.module-count {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-card);
  padding: 1px 7px;
  border-radius: 99px;
}

.module-chevron {
  font-size: 10px;
  color: var(--text-muted);
  transition: transform var(--transition);
}
.module-group.open .module-chevron { transform: rotate(180deg); }

.module-items {
  display: none;
  padding: 4px 0;
}
.module-group.open .module-items { display: block; }

/* Nav Item */
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px 9px 32px;
  cursor: pointer;
  border-radius: 0;
  transition: background var(--transition);
  position: relative;
  border-left: 3px solid transparent;
}
.nav-item:hover { background: var(--bg-elevated); }
.nav-item.active {
  background: var(--accent-glow);
  border-left-color: var(--accent-1);
}
.nav-item.active .nav-item-title { color: var(--accent-1); }

.nav-item-icon {
  font-size: 14px;
  flex-shrink: 0;
}

.nav-item-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  line-height: 1.3;
  flex: 1;
}
.nav-item.active .nav-item-icon { color: var(--accent-1); }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-footer-text {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.5;
}

/* ── Main Content ──────────────────────────────────────────── */
#main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Top Header ────────────────────────────────────────────── */
#topbar {
  height: var(--header-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(12px);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

#hamburger {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
}
#hamburger:hover { background: var(--bg-elevated); color: var(--text-primary); }

#breadcrumb {
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
#breadcrumb .bc-sep { color: var(--text-muted); opacity: 0.4; }
#breadcrumb .bc-active { color: var(--text-secondary); }

.topbar-right { display: flex; align-items: center; gap: 8px; }

.topbar-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-1);
  background: var(--accent-glow);
  border: 1px solid var(--border-accent);
  padding: 3px 10px;
  border-radius: 99px;
}

/* ── Content Area ──────────────────────────────────────────── */
#content-area {
  flex: 1;
  padding: 40px 48px;
  max-width: 1000px;
  width: 100%;
}

/* ── Welcome Screen ────────────────────────────────────────── */
#welcome-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - var(--header-h));
  text-align: center;
  padding: 60px 40px;
}

.welcome-icon {
  font-size: 64px;
  margin-bottom: 24px;
  filter: drop-shadow(0 0 30px var(--accent-glow));
}

.welcome-title {
  font-size: 36px;
  font-weight: 800;
  background: var(--accent-grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 12px;
}

.welcome-sub {
  font-size: 16px;
  color: var(--text-secondary);
  max-width: 480px;
  margin-bottom: 40px;
  line-height: 1.7;
}

.welcome-stats {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  justify-content: center;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 28px;
  text-align: center;
  min-width: 120px;
  transition: transform var(--transition), border-color var(--transition);
}
.stat-card:hover { transform: translateY(-2px); border-color: var(--border-accent); }

.stat-number {
  font-size: 28px;
  font-weight: 800;
  background: var(--accent-grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  font-weight: 500;
}

/* ── Activity View ─────────────────────────────────────────── */
#activity-view { display: none; }

.activity-header {
  margin-bottom: 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.activity-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.tag {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 99px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  letter-spacing: 0.04em;
}
.tag.accent {
  background: var(--accent-glow);
  border-color: var(--border-accent);
  color: var(--accent-1);
}

.activity-title {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
  margin-bottom: 6px;
}

.activity-subtitle {
  font-size: 15px;
  color: var(--text-secondary);
}

/* PDF Banner */
.pdf-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, rgba(79,142,247,0.1) 0%, rgba(124,90,247,0.1) 100%);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 32px;
  flex-wrap: wrap;
  gap: 12px;
}

.pdf-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pdf-icon {
  font-size: 28px;
}

.pdf-text-main {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.pdf-text-sub {
  font-size: 12px;
  color: var(--text-muted);
}

.pdf-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  border: none;
  text-decoration: none !important;
}

.btn-primary {
  background: var(--accent-grad);
  color: white;
  box-shadow: 0 4px 15px var(--accent-glow);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(79,142,247,0.35);
  color: white;
}

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

/* ══════════════════════════════════════════════════════════════
   MARKDOWN RENDERED CONTENT
══════════════════════════════════════════════════════════════ */

#md-content { line-height: 1.75; }

#md-content h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--border);
}

#md-content h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 40px 0 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
#md-content h2::before {
  content: '';
  display: block;
  width: 4px; height: 20px;
  background: var(--accent-grad);
  border-radius: 99px;
  flex-shrink: 0;
}

#md-content h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 28px 0 12px;
}

#md-content p {
  color: var(--text-secondary);
  margin-bottom: 14px;
  font-size: 14px;
}

#md-content ul, #md-content ol {
  color: var(--text-secondary);
  margin: 12px 0 12px 20px;
  font-size: 14px;
}
#md-content li { margin-bottom: 6px; }

#md-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 36px 0;
}

/* Inline code */
#md-content code:not(pre code) {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12.5px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 5px;
  color: var(--accent-1);
}

/* Code blocks */
#md-content pre {
  position: relative;
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: var(--radius);
  overflow: hidden;
  margin: 16px 0;
}

.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: rgba(255,255,255,0.03);
  border-bottom: 1px solid var(--code-border);
}

.code-lang {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.code-lang::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent-1);
  opacity: 0.6;
}

.btn-copy {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-copy:hover {
  background: var(--accent-glow);
  border-color: var(--border-accent);
  color: var(--accent-1);
}
.btn-copy.copied {
  background: rgba(34, 211, 160, 0.12);
  border-color: rgba(34, 211, 160, 0.35);
  color: var(--success);
}

#md-content pre code {
  display: block;
  padding: 16px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  line-height: 1.7;
  color: #cdd6f4;
  overflow-x: auto;
  background: none !important;
}

/* Highlight.js theme override (Catppuccin-inspired) */
.hljs-keyword  { color: #cba6f7; }
.hljs-string   { color: #a6e3a1; }
.hljs-comment  { color: #585b70; font-style: italic; }
.hljs-number   { color: #fab387; }
.hljs-built_in { color: #89dceb; }
.hljs-variable { color: #f38ba8; }
.hljs-attr     { color: #89b4fa; }
.hljs-title    { color: #f9e2af; }
.hljs-operator { color: #94e2d5; }
.hljs-params   { color: #cdd6f4; }
.hljs-function { color: #89b4fa; }
.hljs-literal  { color: #fab387; }

/* Blockquotes (Tarefas) */
#md-content blockquote {
  background: rgba(245, 166, 35, 0.08);
  border: 1px solid rgba(245, 166, 35, 0.25);
  border-left: 4px solid var(--warning);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin: 20px 0;
  color: #f5e6c0;
  font-size: 14px;
}

#md-content blockquote p {
  color: #f5e6c0;
  margin-bottom: 6px;
}
#md-content blockquote p:last-child { margin-bottom: 0; }

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE MOBILE
══════════════════════════════════════════════════════════════ */

#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 99;
  backdrop-filter: blur(4px);
}

@media (max-width: 768px) {
  #sidebar {
    transform: translateX(-100%);
  }
  #sidebar.open {
    transform: translateX(0);
    box-shadow: 8px 0 40px rgba(0,0,0,0.5);
  }
  #sidebar-overlay.visible { display: block; }
  #main { margin-left: 0; }
  #hamburger { display: flex; }
  #content-area { padding: 24px 20px; }
  #topbar { padding: 0 16px; }
  .welcome-title { font-size: 26px; }
  .activity-title { font-size: 20px; }
  .pdf-banner { flex-direction: column; }
}

@media (max-width: 480px) {
  .welcome-stats { gap: 12px; }
  .stat-card { padding: 14px 18px; min-width: 90px; }
  #md-content pre code { font-size: 12px; }
}

/* ── Loading Spinner ───────────────────────────────────────── */
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent-1);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 60px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast Notification ────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 24px; right: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border-accent);
  color: var(--text-primary);
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 9999;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
}
#toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* ── Animations ────────────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeIn 0.3s ease forwards; }
