* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', sans-serif;
  line-height: 1.6;
  color: #333;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}

.content-wrapper {
  display: grid;
  grid-template-columns: 1fr 350px;
  gap: 30px;
  align-items: start;
}

/* Header */
.header {
  text-align: center;
  margin-bottom: 40px;
  color: white;
}

.header h1 {
  font-size: 3rem;
  font-weight: 700;
  margin-bottom: 10px;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.subtitle {
  font-size: 1.2rem;
  opacity: 0.9;
  font-weight: 300;
}

/* Main Layout */
.main-content {
  display: grid;
  gap: 30px;
}

/* Generic Section */
section {
  background: white;
  border-radius: 20px;
  padding: 30px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.1);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  animation: fadeIn 0.6s ease-out;
}

section:hover {
  box-shadow: 0 15px 40px rgba(0,0,0,0.15);
}

section h2 {
  color: #4a5568;
  margin-bottom: 20px;
  font-size: 1.8rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Theory Block */
.theory-content p {
  margin-bottom: 15px;
  font-size: 1.1rem;
  color: #2d3748;
}

.theory-highlight {
  background: linear-gradient(135deg, #f7fafc, #edf2f7);
  border-radius: 15px;
  padding: 25px;
  margin: 20px 0;
  border-left: 4px solid #667eea;
}

.theory-highlight h3 {
  color: #4a5568;
  margin-bottom: 15px;
  font-size: 1.3rem;
}

.theory-highlight ul {
  list-style: none;
  padding-left: 0;
}

.theory-highlight li {
  margin-bottom: 10px;
  padding-left: 20px;
  position: relative;
}

.theory-highlight li:before {
  content: "⚡";
  position: absolute;
  left: 0;
  color: #667eea;
}

.theory-equation {
  background: #f7fafc;
  border-radius: 15px;
  padding: 25px;
  margin: 20px 0;
}

.theory-equation h3 {
  color: #4a5568;
  margin-bottom: 15px;
  font-size: 1.3rem;
}

.equation {
  background: white;
  border-radius: 10px;
  padding: 20px;
  margin: 15px 0;
  text-align: center;
  border: 2px solid #e2e8f0;
}

.equation span {
  font-size: 1.5rem;
  font-weight: 600;
  color: #667eea;
  font-family: 'Courier New', monospace;
  display: block;
  margin-bottom: 10px;
}

.equation p {
  color: #718096;
  font-size: 0.9rem;
}

/* Simulator Block */
.simulator-content {
  display: grid;
  gap: 25px;
}

.simulator-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  background: #f7fafc;
  border-radius: 15px;
  padding: 25px;
  border: 2px solid #e2e8f0;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.control-group label {
  font-weight: 600;
  color: #4a5568;
  font-size: 0.9rem;
}

.control-group input[type="range"] {
  width: 100%;
  height: 8px;
  border-radius: 5px;
  background: #e2e8f0;
  outline: none;
  -webkit-appearance: none;
}

.control-group input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea, #764ba2);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.control-group input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea, #764ba2);
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.control-group span {
  font-weight: 600;
  color: #667eea;
  font-size: 1.1rem;
  text-align: center;
}

.canvas-container {
  display: flex;
  justify-content: center;
  margin: 30px 0;
  width: 100%;
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
}

.canvas-container canvas {
  border: 2px solid #e2e8f0;
  border-radius: 15px;
  background: #f7fafc;
  box-shadow: 0 4px 15px rgba(0,0,0,0.1);
  width: 100%;
  max-width: 800px;
}

.simulator-info {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
  margin-top: 20px;
}

.info-item {
  background: #f7fafc;
  padding: 15px;
  border-radius: 10px;
  border: 2px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.info-label {
  font-weight: 600;
  color: #4a5568;
}

.info-value {
  font-weight: 700;
  color: #667eea;
  font-size: 1.1rem;
}

/* Exercises Block */
.exercise h3 {
  color: #4a5568;
  margin-bottom: 15px;
  font-size: 1.3rem;
}

.exercise-content {
  background: #f7fafc;
  border-radius: 15px;
  padding: 25px;
  border: 2px solid #e2e8f0;
}

.exercise-content p {
  font-size: 1.2rem;
  margin-bottom: 20px;
  color: #2d3748;
}

.exercise-problem {
  background: white;
  border-radius: 10px;
  padding: 20px;
  margin: 15px 0;
  border: 2px solid #e2e8f0;
}

.exercise-problem p {
  margin-bottom: 10px;
  color: #4a5568;
}

.math {
  font-family: 'Courier New', monospace;
  font-weight: 600;
  color: #667eea;
}

.exercise-input {
  display: flex;
  gap: 15px;
  margin-bottom: 20px;
  align-items: center;
  flex-wrap: wrap;
}

#exercise-answer {
  flex: 1;
  min-width: 200px;
  padding: 12px 15px;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  font-size: 1rem;
  font-family: 'Courier New', monospace;
}

#exercise-answer:focus {
  outline: none;
  border-color: #667eea;
}

.unit {
  font-weight: 600;
  color: #667eea;
  font-size: 0.9rem;
}

button {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  border: none;
  padding: 12px 25px;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

button:active {
  transform: translateY(0);
}

.exercise-result {
  padding: 15px 0;
  border-radius: 8px;
  font-weight: 600;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}

.exercise-result.correct {
  background: #c6f6d5;
  color: #22543d;
  border: 2px solid #9ae6b4;
}

.exercise-result.incorrect {
  background: #fed7d7;
  color: #742a2a;
  border: 2px solid #feb2b2;
}

.button-group {
  display: flex;
  gap: 15px;
  margin-top: 15px;
}

.exercise-controls {
  display: flex;
  gap: 15px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.problem-type-selector {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.problem-type-selector label {
  font-weight: 600;
  color: #4a5568;
}

#problem-type {
  padding: 10px;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  font-size: 1rem;
  background: white;
}

#problem-type:focus {
  outline: none;
  border-color: #667eea;
}

.hint {
  background: #fff3cd;
  border: 2px solid #ffeaa7;
  border-radius: 10px;
  padding: 15px;
  margin: 15px 0;
}

.hint p {
  color: #856404;
  margin: 0;
  font-weight: 500;
}

/* Rounding instruction styling */
.rounding-instruction p {
  font-size: 0.8rem;
  color: #666;
  margin-top: 0;
  margin-bottom: 0;
}

/* Ensure MathJax equations are black */
.MathJax, .MathJax_Display, .MathJax_SVG, .MathJax_SVG_Display {
  color: black !important;
}

.math {
  color: black !important;
}

/* Solution Builder Styles */
.solution-builder {
  background: white;
  border-radius: 10px;
  padding: 20px;
  margin: 15px 0;
  border: 2px solid #e2e8f0;
}

.solution-builder h4 {
  color: #2d3748;
  margin-bottom: 15px;
  font-size: 1.1rem;
}

.formula-pieces {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  justify-content: center;
}

.piece {
  background: #667eea;
  color: white;
  padding: 10px 15px;
  border-radius: 8px;
  cursor: grab;
  font-weight: 600;
  user-select: none;
  transition: all 0.3s ease;
}

.piece:hover {
  background: #5a67d8;
  transform: translateY(-2px);
}

.piece:active {
  cursor: grabbing;
}

.formula-template {
  margin-bottom: 20px;
  text-align: center;
}

.formula-display {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 1.2rem;
  font-weight: 600;
  color: #2d3748;
  background: #f7fafc;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  padding: 15px;
}

.formula-slot {
  width: 60px;
  height: 50px;
  border: 2px dashed #cbd5e0;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f7fafc;
  transition: all 0.3s ease;
}

.formula-slot:hover {
  border-color: #667eea;
  background: #edf2f7;
}

.dropped-piece {
  background: #48bb78;
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.9rem;
}

/* Variable Input Styles */
.variable-input {
  background: white;
  border-radius: 10px;
  padding: 20px;
  margin: 15px 0;
  border: 2px solid #e2e8f0;
}

.variable-input h4 {
  color: #2d3748;
  margin-bottom: 15px;
  font-size: 1.1rem;
}

.variable-fields {
  display: flex;
  gap: 20px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  justify-content: center;
}

.variable-field {
  display: flex;
  align-items: center;
  gap: 10px;
}

.variable-field label {
  font-weight: 600;
  color: #4a5568;
  min-width: 40px;
}

.variable-field input {
  width: 100px;
  padding: 8px 12px;
  border: 2px solid #e2e8f0;
  border-radius: 6px;
  font-size: 1rem;
  font-family: 'Courier New', monospace;
}

.variable-field input:focus {
  outline: none;
  border-color: #667eea;
}

.variable-field input:disabled {
  background: #f7fafc;
  color: #4a5568;
}

/* Calculation Step Styles */
.calculation-step {
  background: white;
  border-radius: 10px;
  padding: 20px;
  margin: 15px 0;
  border: 2px solid #e2e8f0;
}

.calculation-step h4 {
  color: #2d3748;
  margin-bottom: 15px;
  font-size: 1.1rem;
}

.calculation-display {
  background: #f7fafc;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  padding: 15px;
  margin-bottom: 20px;
  text-align: center;
}

.calculation-display p {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
  color: #2d3748;
}

.final-answer {
  display: flex;
  align-items: center;
  gap: 15px;
  justify-content: center;
  flex-wrap: wrap;
}

.final-answer label {
  font-weight: 600;
  color: #4a5568;
}

.final-answer input {
  width: 120px;
  padding: 10px 15px;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  font-size: 1rem;
  font-family: 'Courier New', monospace;
}

.final-answer input:focus {
  outline: none;
  border-color: #667eea;
}

/* Fade Animation */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Responsive Design */
@media (max-width: 768px) {
  .container {
    padding: 15px;
  }

  .header h1 {
    font-size: 2rem;
  }

  section {
    padding: 20px;
  }

  .exercise-input {
    flex-direction: column;
    align-items: stretch;
  }

  #exercise-answer {
    min-width: auto;
  }

  .simulator-controls {
    grid-template-columns: 1fr;
  }

  .simulator-info {
    grid-template-columns: 1fr;
  }

  .exercise-controls {
    flex-direction: column;
  }

  #capacitor-canvas {
    max-width: 100%;
    height: auto;
  }
  
  .content-wrapper {
    grid-template-columns: 1fr;
  }
  
  .chat-section {
    order: -1;
    margin-bottom: 20px;
  }
}

/* Chat Section Styles */
.chat-section {
  background: white;
  border-radius: 20px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.1);
  overflow: hidden;
  height: fit-content;
  position: sticky;
  top: 20px;
}

.chat-header {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  padding: 20px;
  text-align: center;
}

.chat-header h3 {
  margin: 0 0 5px 0;
  font-size: 1.3rem;
  font-weight: 600;
}

.chat-header p {
  margin: 0;
  opacity: 0.9;
  font-size: 0.9rem;
}

.chat-container {
  height: 500px;
  overflow: hidden;
}

.botui-app-container {
  height: 100%;
  width: 100% !important;
  max-width: 100% !important;
  overflow: hidden;
}

/* Custom Chat Interface */
#botui {
  width: 100% !important;
  max-width: 100% !important;
  overflow: hidden;
}

.chat-messages {
  height: 400px;
  overflow-y: auto;
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* Internet Explorer 10+ */
}

.chat-messages::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Opera */
}

.chat-message {
  display: flex;
  margin-bottom: 10px;
}

.chat-message.bot-message {
  justify-content: flex-start;
}

.chat-message.user-message {
  justify-content: flex-end;
}

.message-content {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 15px;
  font-size: 0.95rem;
  line-height: 1.4;
  white-space: pre-line;
}

.bot-message .message-content {
  background: #f7fafc;
  color: #2d3748;
  border: 1px solid #e2e8f0;
}

.user-message .message-content {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
}

.typing-indicator .message-content {
  background: #e2e8f0;
  color: #718096;
  font-style: italic;
}

.chat-input-container {
  display: flex;
  gap: 10px;
  padding: 15px;
  border-top: 1px solid #e2e8f0;
  background: white;
}

#chat-input {
  flex: 1;
  border: 2px solid #e2e8f0;
  border-radius: 20px;
  padding: 10px 15px;
  font-size: 0.95rem;
  outline: none;
}

#chat-input:focus {
  border-color: #667eea;
}

#chat-send {
  background: linear-gradient(135deg, #667eea, #764ba2);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  color: white;
  cursor: pointer;
  transition: transform 0.2s ease;
  position: relative;
  font-size: 1.5rem;
  font-weight: bold;
  line-height: 1;
  padding: 0;
  margin: 0;
}

#chat-send::after {
  content: "➤";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.5rem;
  font-weight: bold;
}

#chat-send:hover {
  transform: scale(1.1);
}

/* Markdown styling in chat */
.chat-message .message-content strong {
  font-weight: 600;
  color: #2d3748;
}

.chat-message .message-content em {
  font-style: italic;
  color: #4a5568;
}

.chat-message .message-content code {
  background: #f7fafc;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 2px 6px;
  font-family: 'Courier New', monospace;
  font-size: 0.9em;
  color: #2d3748;
}

.chat-message .message-content ul {
  margin: 10px 0;
  padding-left: 20px;
}

.chat-message .message-content li {
  margin-bottom: 5px;
  line-height: 1.4;
} 