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

body {
  font-family: var(--font-family);
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Container */
.app-container {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 16px 20px 60px 20px;
  flex: 1;
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 12px;
  z-index: 100;
  backdrop-filter: blur(12px);
  gap: 14px;
}

.header-brand-wrap,
.brand-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  flex-shrink: 0;
}

.brand-avatar {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid var(--primary);
  flex-shrink: 0;
  box-shadow: 0 0 10px var(--primary-glow);
}

.brand-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  display: block;
}

.brand-titles {
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-main);
  transition: color var(--transition-fast);
}

.header-brand-wrap:hover .brand-name,
.brand-wrap:hover .brand-name {
  color: var(--primary);
}

/* Subsections Navigation Menu in Header */
.header-nav-menu {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-card);
  padding: 4px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
}

.header-nav-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  text-decoration: none;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.header-nav-item:hover {
  color: var(--text-main);
  background: var(--bg-card-hover);
}

.header-nav-item.active {
  color: #ffffff;
  background-color: var(--primary);
  box-shadow: 0 1px 8px var(--primary-glow);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.brand-highlight,
.brand-name-en {
  color: var(--primary);
  font-weight: 900;
}

.brand-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Stats in header */
.header-stats {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stat-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 700;
}

.stat-streak {
  color: #f97316;
}

.stat-xp {
  color: #fbbf24;
}

/* Header utility buttons */
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-icon {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-icon:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-focus);
  transform: translateY(-1px);
}

/* General Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background-color: #0284c7;
  color: #ffffff;
  border: none;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.35);
  font-weight: 700;
}

.btn-primary:hover {
  background-color: #0369a1;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.45);
  transform: translateY(-1px);
}

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

.btn-secondary:hover {
  background-color: var(--bg-card-hover);
  border-color: var(--border-card);
}

.btn-outline {
  background-color: transparent;
  color: var(--text-main);
  border: 1px solid var(--border-card);
}

.btn-outline:hover {
  background-color: var(--bg-card);
  border-color: var(--text-muted);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
}

.btn-xs {
  padding: 4px 10px;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

/* HERO SECTION WITH FULL CLASSROOM BACKGROUND ILLUSTRATION */
.hero-card {
  position: relative;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  margin-bottom: 28px;
  min-height: 240px;
  display: flex;
  align-items: center;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  background-color: var(--bg-surface);
  background-clip: padding-box;
}

.hero-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: right 10%;
  background-repeat: no-repeat;
  z-index: 0;
  pointer-events: none;
}

.hero-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    rgba(15, 23, 42, 0.98) 0%,
    rgba(15, 23, 42, 0.90) 45%,
    rgba(15, 23, 42, 0.45) 62%,
    rgba(15, 23, 42, 0) 75%,
    rgba(15, 23, 42, 0) 100%
  );
  pointer-events: none;
  z-index: 1;
}

[data-theme="light"] .hero-card::before {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.98) 0%,
    rgba(255, 255, 255, 0.92) 45%,
    rgba(255, 255, 255, 0.45) 62%,
    rgba(255, 255, 255, 0) 75%,
    rgba(255, 255, 255, 0) 100%
  );
}

.hero-content {
  max-width: 560px;
  z-index: 2;
  position: relative;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background-color: var(--badge-bg);
  color: var(--badge-text);
  font-size: 0.8rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  margin-bottom: 10px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.hero-title {
  font-size: 1.85rem;
  font-weight: 900;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
  line-height: 1.25;
}

.hero-desc {
  font-size: 0.98rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* QUICK ACTION TABS / CARDS / PANEL */
.quick-actions-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin: 28px 0 36px 0;
}

.quick-actions-panel,
.quick-actions-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  max-width: 680px;
  margin: 28px 0 36px 0;
}

@media (max-width: 680px) {
  .quick-actions-panel,
  .quick-actions-grid {
    grid-template-columns: 1fr;
    max-width: 100%;
    margin: 20px 0 28px 0;
  }
}

.action-tile {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: all var(--transition-normal);
  text-decoration: none;
  color: inherit;
}

.action-tile:hover {
  background-color: var(--bg-card);
  border-color: rgba(2, 132, 199, 0.5);
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

.action-icon-box {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  flex-shrink: 0;
}

.icon-box-purple {
  background: rgba(139, 92, 246, 0.15);
  color: #a78bfa;
}

.icon-box-rose {
  background: rgba(244, 63, 94, 0.15);
  color: #fb7185;
}

.icon-box-emerald {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
}

.action-info {
  display: flex;
  flex-direction: column;
}

.action-title {
  font-weight: 800;
  font-size: 0.95rem;
}

.action-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* TOPICS SECTION & HEADERS */
#topics-section,
.topics-section {
  margin-top: 8px;
  margin-bottom: 40px;
}

.section-header,
.section-header-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 36px;
  margin-bottom: 24px;
  padding: 0 10px;
  flex-wrap: wrap;
  gap: 12px;
}

.section-title {
  font-size: 1.4rem;
  font-weight: 900;
  letter-spacing: -0.5px;
  margin: 0;
  color: var(--text-main);
  line-height: 1.25;
}

.section-desc {
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 6px 0 0 0;
}

.topics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 20px;
  margin-top: 6px;
}

.topic-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  transition: all var(--transition-normal);
  position: relative;
  overflow: hidden;
}

.topic-card:hover {
  border-color: var(--border-card);
  background-color: var(--bg-card);
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.topic-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  min-height: 24px;
}

.topic-icon,
.topic-card-icon {
  display: none !important;
}

.topic-stars {
  display: flex;
  gap: 3px;
  font-size: 1.1rem;
}

.topic-star-filled {
  color: #f59e0b;
}

.topic-star-empty {
  color: var(--border-subtle);
}

.topic-card-body {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.topic-card-title,
.topic-title {
  font-size: 1.15rem;
  font-weight: 800;
  margin-bottom: 6px;
  color: var(--text-main);
}

.topic-card-subtitle,
.topic-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 16px;
  flex: 1;
}

.topic-meta {
  margin-bottom: 16px;
}

.topic-progress-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.topic-progress-bar {
  width: 100%;
  height: 6px;
  background-color: var(--bg-app);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.topic-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary) 0%, #06b6d4 100%);
  border-radius: var(--radius-full);
  transition: width var(--transition-normal);
}

.topic-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.topic-card-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.topic-card-stars {
  display: inline-flex;
  gap: 2px;
  font-size: 0.95rem;
  color: #f59e0b;
}

.topic-card-stats {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.topic-card-actions,
.topic-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: auto;
  margin-left: auto;
}

/* Unified Card Action Buttons - Solid Belasá, No Gradients */
.topic-card .btn-primary,
.topic-card-actions .btn-primary,
.topic-actions .btn-primary,
.btn-quiz-action,
.btn-start-quiz {
  background-color: #0284c7 !important;
  color: #ffffff !important;
  border: none !important;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.35) !important;
  font-weight: 700 !important;
}

.topic-card .btn-primary:hover,
.topic-card-actions .btn-primary:hover,
.topic-actions .btn-primary:hover,
.btn-quiz-action:hover,
.btn-start-quiz:hover {
  background-color: #0369a1 !important;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.45) !important;
  transform: translateY(-1px) !important;
}

.btn-theory-action,
.btn-open-theory {
  background-color: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  padding: 6px 10px;
  font-size: 1rem;
  line-height: 1;
  min-width: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.btn-theory-action:hover,
.btn-open-theory:hover {
  background-color: var(--bg-card-hover);
  border-color: rgba(2, 132, 199, 0.5);
  color: #38bdf8;
  transform: translateY(-1px);
}

/* Footer */
.app-footer {
  margin-top: 40px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-dim);
  padding: 20px 0;
  border-top: 1px solid var(--border-subtle);
  line-height: 1.6;
}

.app-footer a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.app-footer a:hover {
  color: var(--primary);
  text-decoration: underline;
}

/* Utilities */
.hidden {
  display: none !important;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .app-header {
    padding: 10px 14px;
    gap: 10px;
    flex-wrap: wrap;
  }

  .header-brand-wrap,
  .brand-wrap {
    order: 1;
  }

  .header-right {
    order: 2;
    margin-left: auto;
  }

  .header-nav-menu {
    order: 3;
    width: 100%;
    justify-content: center;
    overflow-x: auto;
    scrollbar-width: none;
    padding: 3px;
  }

  .header-nav-menu::-webkit-scrollbar {
    display: none;
  }

  .header-nav-item {
    padding: 5px 12px;
    font-size: 0.8rem;
  }
}

@media (max-width: 640px) {
  .app-container {
    padding: 12px 14px 50px 14px;
  }

  .brand-name {
    font-size: 1rem;
  }

  .hero-card {
    padding: 24px 18px;
    min-height: auto;
  }

  .hero-teacher-wrap {
    width: 90px;
    height: 90px;
  }

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

  .topic-actions {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .header-stats {
    gap: 6px;
  }

  .stat-pill {
    padding: 4px 8px;
    font-size: 0.78rem;
  }

  .header-nav-item {
    padding: 5px 8px;
    font-size: 0.76rem;
    gap: 4px;
  }
}
