:root {
  --primary: #2563eb;
  --primary-light: #93c5fd;
  --primary-dark: #1e40af;
  --secondary: #059669;
  --accent: #dc2626;
  --light-bg: #f8fafc;
  --card-bg: #ffffff;
  --border: #e2e8f0;
  --text-dark: #1e293b;
  --text-light: #64748b;
}

[data-theme="dark"] {
  --primary: #3b82f6;
  --primary-light: #1e40af;
  --primary-dark: #93c5fd;
  --secondary: #10b981;
  --accent: #ef4444;
  --light-bg: #1e293b;
  --card-bg: #334155;
  --border: #475569;
  --text-dark: #f1f5f9;
  --text-light: #cbd5e1;
}

body {
  background-color: var(--light-bg);
  color: var(--text-dark);
  min-height: 100vh;
  font-family: "Inter", sans-serif;
  transition: background-color 0.3s ease, color 0.3s ease;
}

.header-gradient {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

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

.card:last-child {
  margin-bottom: 0;
}

#latex-input {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  color: var(--text-dark);
  font-family: "Monaco", "Menlo", "Ubuntu Mono", monospace;
  width: 100%;
  transition: all 0.2s ease;
  resize: none;
  min-height: 100px;
  outline: none;
  font-size: 0.95rem;
}

#latex-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  color: white;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
}

.btn-primary:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.btn-primary i {
  margin-right: 0.5rem;
}

.latex-container {
  min-height: 100px;
  border-radius: 8px;
  background: var(--light-bg);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  transition: all 0.2s ease;
  overflow-x: auto;
}

.latex-container.has-content {
  border-color: var(--primary);
  background: var(--light-bg);
}

.tip {
  background: var(--light-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  color: var(--text-dark);
  margin-top: 0.5rem;
}

.formula-examples {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.example-chip {
  background: var(--light-bg);
  padding: 0.4rem 0.9rem;
  border-radius: 20px;
  color: var(--text-dark);
  font-size: 0.8rem;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: all 0.2s ease;
  font-weight: 500;
}

.example-chip:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary-dark);
}

.steps-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

.step-card {
  padding: 1.25rem;
  background: var(--card-bg);
  border-radius: 8px;
  box-shadow: rgba(100, 100, 111, 0.2) 0px 7px 29px 0px;
  border-left: 4px solid var(--primary);
  transition: all 0.2s ease;
  position: relative;
  height: fit-content;
  opacity: 0;
  transform: translateY(20px);
  animation: cardAppear 0.5s ease forwards;
}

.step-card.highlighted {
  border-left: 4px solid var(--accent);
  background: var(--light-bg);
}

.step-card:hover {
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  margin-right: 0.75rem;
  font-weight: 600;
  font-size: 0.875rem;
}

.step-card.highlighted .step-number {
  background: var(--accent);
}

.step-content {
  background: var(--light-bg);
  border-radius: 6px;
  padding: 1rem;
  margin-top: 0.75rem;
  border: 1px solid var(--border);
  position: relative;
  opacity: 0;
  animation: fadeIn 0.4s ease 0.3s forwards;
}

.copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  color: var(--text-light);
  cursor: pointer;
  transition: all 0.2s ease;
  opacity: 0;
  z-index: 9;
}

.step-content:hover .copy-btn {
  opacity: 1;
}

.copy-btn:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.katex {
  font-size: 1.05rem;
}

.katex-display {
  margin: 0;
  overflow-x: auto;
  padding: 0.25rem 0;
}

.section-title {
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
}

.section-title i {
  margin-right: 0.5rem;
  color: var(--primary);
}

/* Loading animation */
.loading-dots {
  display: inline-flex;
  margin-left: 0.5rem;
}

.loading-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: currentColor;
  margin: 0 1px;
  opacity: 0.6;
  animation: pulse 1.5s infinite ease-in-out;
}

.loading-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.loading-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.6;
  }
  50% {
    transform: scale(1.2);
    opacity: 1;
  }
}

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

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text-dark);
  color: var(--light-bg);
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.toast.show {
  opacity: 1;
}

.theme-toggle {
  position: fixed;
  top: 1rem;
  right: 1rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 100;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
}

.theme-toggle:hover {
  transform: scale(1.05);
}

/* Main layout */
.main-content-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 1024px) {
  .main-content-grid {
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
  }
}

.left-column {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.right-column {
  display: flex;
  flex-direction: column;
}

.steps-container {
  height: 100%;
  display: flex;
  flex-direction: column;
  max-height: 90vh;
}

.steps-content {
  flex: 1;
  overflow-y: auto;
  padding-right: 0.5rem;
}

/* Scrollbar styling */
.steps-content::-webkit-scrollbar {
  width: 6px;
}

.steps-content::-webkit-scrollbar-track {
  background: var(--light-bg);
  border-radius: 3px;
}

.steps-content::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.steps-content::-webkit-scrollbar-thumb:hover {
  background: var(--primary-light);
}

.error-container {
  background-color: var(--card-bg);
  border-radius: 8px;
  padding: 1.5rem;
  border-left: 4px solid var(--accent);
  margin: 1rem 0;
  box-shadow: rgba(100, 100, 111, 0.2) 0px 7px 29px 0px;
}

.error-header {
  display: flex;
  align-items: center;
  margin-bottom: 1rem;
  color: var(--accent);
}

.error-header i {
  font-size: 1.5rem;
  margin-right: 0.5rem;
}

.error-header h3 {
  margin: 0;
  font-weight: 600;
}

.error-message {
  margin-bottom: 1rem;
  color: var(--text);
}

.error-location {
  background-color: var(--bg);
  border-radius: 4px;
  padding: 1rem;
  overflow-x: auto;
}

.formula-display {
  margin: 0 0 0.5rem 0;
  font-family: monospace;
  white-space: pre-wrap;
  color: var(--text);
}

.error-indicator {
  margin: 0;
  font-family: monospace;
  color: var(--accent);
  font-weight: bold;
}
