/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

:root {
  --primary: #2563EB;
  --primary-hover: #1D4ED8;
  --secondary: #059669;
  --bg-color: #F5F7FB;
  --sidebar-bg: #FFFFFF;
  --text-dark: #172033;
  --text-light: #64748B;
  --border-color: #DDE4EE;
  --card-bg: #FFFFFF;
  --accent: #C2410C;
  --ink-muted: #334155;
  --formula-bg: #F8FAFC;
}

body {
  background-color: var(--bg-color);
  color: var(--text-dark);
}

.math-portal {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background-color: var(--sidebar-bg);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 1.5rem;
  box-shadow: 2px 0 10px rgba(0,0,0,0.02);
}

.brand {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2.5rem;
}

.logo-box {
  background: linear-gradient(135deg, var(--primary), #0F766E);
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.5rem;
  font-weight: bold;
  box-shadow: 0 4px 6px rgba(79, 70, 229, 0.2);
}

.brand h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-dark);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  color: var(--text-light);
  text-decoration: none;
  border-radius: 8px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.nav-item:hover {
  background-color: #F9FAFB;
  color: var(--text-dark);
}

.nav-item.active {
  background-color: #EEF2FF;
  color: var(--primary);
}

.nav-item.active i {
  color: var(--primary);
}

/* User Profile */
.user-profile {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}

.user-info .user-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.user-info .user-level {
  font-size: 0.8rem;
  color: var(--text-light);
}

/* Main Content */
.main-content {
  flex: 1;
  padding: 2.5rem;
  overflow-y: auto;
  position: relative;
}

.top-header {
  margin-bottom: 2.5rem;
}

.top-header h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  letter-spacing: -0.025em;
}

.top-header p {
  color: var(--text-light);
  font-size: 1.1rem;
}

.course-grid, .content-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
}

.overview-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(280px, 0.8fr);
  gap: 1.5rem;
  align-items: start;
  margin-bottom: 1.5rem;
}

.lesson-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 0.55fr);
  gap: 1.5rem;
  align-items: start;
}

.course-card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 1.5rem;
  border: 1px solid var(--border-color);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.insight-card,
.lesson-card,
.practice-card,
.tool-card,
.assignment-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.04);
}

.insight-card,
.lesson-card,
.practice-card,
.tool-card,
.assignment-card {
  padding: 1.5rem;
}

.insight-card h2,
.lesson-card h2,
.practice-card h2,
.tool-card h2,
.assignment-card h2,
.page-content h2 {
  font-size: 1.2rem;
  margin-bottom: 1rem;
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-top: 1.25rem;
}

.metric {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1rem;
  background: #F8FAFC;
}

.metric strong {
  display: block;
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
}

.metric span,
.topic-meta,
.small-note {
  color: var(--text-light);
  font-size: 0.9rem;
}

.topic-list,
.practice-list,
.step-list {
  display: grid;
  gap: 0.85rem;
}

.topic-item {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--border-color);
}

.topic-item:last-child {
  border-bottom: 0;
}

.topic-item strong {
  color: var(--text-dark);
}

.skill-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.skill-tags span,
.standard-tag {
  background: #E0F2FE;
  color: #075985;
  border: 1px solid #BAE6FD;
  border-radius: 999px;
  padding: 0.25rem 0.6rem;
  font-size: 0.82rem;
  font-weight: 600;
}

.course-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.course-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.course-card h3 {
  font-size: 1.25rem;
  font-weight: 600;
}

.chapter-count {
  font-size: 0.85rem;
  background-color: #F3F4F6;
  color: var(--text-dark);
  padding: 0.25rem 0.5rem;
  border-radius: 9999px;
  font-weight: 500;
}

.course-card p {
  color: var(--text-light);
  font-size: 0.95rem;
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

.course-card .next-task {
  color: var(--ink-muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.formula {
  display: block;
  background: var(--formula-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-dark);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 1rem;
  line-height: 1.6;
  padding: 0.85rem 1rem;
  margin: 0.75rem 0 1rem;
}

.worked-example {
  border-left: 4px solid var(--primary);
  background: #F8FAFC;
  padding: 1rem 1rem 1rem 1.25rem;
  border-radius: 0 8px 8px 0;
  margin: 1rem 0;
}

.worked-example h3,
.practice-card h3,
.tool-card h3 {
  font-size: 1rem;
  margin-bottom: 0.6rem;
}

.practice-list {
  list-style-position: inside;
  color: var(--ink-muted);
  line-height: 1.6;
}

.practice-list li {
  background: #F8FAFC;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.8rem 1rem;
}

.answer-chip {
  display: inline-block;
  margin-top: 0.5rem;
  color: var(--secondary);
  font-weight: 700;
}

.unit-banner {
  display: flex;
  gap: 1rem;
  align-items: center;
  background: #EFF6FF;
  border: 1px solid #BFDBFE;
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1.25rem;
}

.unit-banner i {
  color: var(--primary);
}

.progress-section {
  margin-bottom: 1.5rem;
}

.progress-bar-bg {
  width: 100%;
  height: 6px;
  background-color: #E5E7EB;
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.progress-bar-fill {
  height: 100%;
  background-color: var(--secondary);
  border-radius: 3px;
}

.progress-text {
  font-size: 0.85rem;
  color: var(--text-light);
  font-weight: 500;
}

.continue-btn {
  width: 100%;
  background-color: var(--primary);
  color: white;
  border: none;
  padding: 0.75rem;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s;
  font-size: 0.95rem;
}

.continue-btn:hover {
  background-color: var(--primary-hover);
}

/* Calculator Overlay Styles */
.calc-container {
  max-width: 400px;
  margin: 0 auto;
  background: white;
  border-radius: 20px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  padding: 2rem;
  border: 1px solid var(--border-color);
}

.calculator-layout {
  display: grid;
  grid-template-columns: minmax(300px, 420px) minmax(280px, 1fr);
  gap: 1.5rem;
  align-items: start;
}

.calc-container h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  text-align: center;
}

.display-area {
  background-color: #F9FAFB;
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1.5rem;
  border: 1px solid var(--border-color);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
}

#calc-input {
  width: 100%;
  background: transparent;
  border: none;
  font-size: 2rem;
  text-align: right;
  outline: none;
  color: var(--text-dark);
  font-family: inherit;
  margin-bottom: 0.5rem;
}

.result-preview {
  display: flex;
  justify-content: flex-end;
  min-height: 1.5rem;
}

.result-text {
  font-size: 1.25rem;
  color: var(--secondary);
  font-weight: 600;
}

.error-text {
  font-size: 0.9rem;
  color: #EF4444;
}

.scientific-keys {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
}

.btn {
  background-color: #F3F4F6;
  border: none;
  padding: 1rem;
  border-radius: 10px;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-dark);
  cursor: pointer;
  transition: all 0.1s ease;
  user-select: none;
}

.btn:hover {
  background-color: #E5E7EB;
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(1px);
}

.btn-clear {
  background-color: #FEE2E2;
  color: #EF4444;
}

.btn-clear:hover {
  background-color: #FECACA;
}

.btn-equals {
  background-color: var(--primary);
  color: white;
  grid-column: span 2;
}

.btn-equals:hover {
  background-color: var(--primary-hover);
}

/* Page specific content */
.page-content {
  background: white;
  padding: 2rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.page-content h2 {
  margin-bottom: 1rem;
}

.page-content p {
  margin-bottom: 1rem;
  color: var(--text-light);
  line-height: 1.6;
}

.page-content ul {
  color: var(--ink-muted);
  line-height: 1.7;
  padding-left: 1.25rem;
}

.geometry-lab {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.75fr);
  gap: 1.5rem;
  align-items: start;
}

.geo-stage {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  background: #FFFFFF;
}

.geo-stage svg {
  display: block;
  width: 100%;
  height: auto;
  touch-action: none;
}

.axis {
  stroke: #94A3B8;
  stroke-width: 1.5;
}

.triangle-fill {
  fill: rgba(37, 99, 235, 0.14);
}

.triangle-side {
  stroke: #2563EB;
  stroke-width: 3;
  stroke-linecap: round;
}

.drag-point {
  fill: #C2410C;
  stroke: white;
  stroke-width: 3;
  cursor: grab;
}

.drag-point:active {
  cursor: grabbing;
}

.point-label {
  fill: #172033;
  font-size: 14px;
  font-weight: 700;
  user-select: none;
}

.measurement-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.measurement-grid div {
  background: #F8FAFC;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.85rem;
}

.measurement-grid span {
  display: block;
  color: var(--text-light);
  font-size: 0.82rem;
  margin-bottom: 0.25rem;
}

.measurement-grid strong {
  font-size: 1.2rem;
}

/* Responsive */
@media (max-width: 768px) {
  .math-portal {
    flex-direction: column;
  }
  
  .sidebar {
    width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    padding: 1rem;
  }
  
  .brand {
    margin-bottom: 1rem;
  }
  
  .nav {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  
  .main-content {
    padding: 1rem;
  }

  .overview-grid,
  .lesson-grid,
  .geometry-lab,
  .calculator-layout,
  .metric-row {
    grid-template-columns: 1fr;
  }
}
