
html, body {
  height: 100%;
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: #f0f2f5;
  overflow: hidden;
}

.app-wrapper {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 800px;
  margin: 0 auto;
  background: white;
  border-radius: 10px;
  box-shadow: 0 0 10px rgba(0,0,0,0.1);
  overflow: hidden;
  box-sizing: border-box;
}

.chat-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  box-sizing: border-box;
}

#chat-box {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  background: #fafafa;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
}

.input-area {
  display: flex;
  padding: 16px;
  border-top: 1px solid #e1e5e9;
  background: white;
  flex-shrink: 0;
  box-sizing: border-box;
}

.input-container {
  display: flex;
  align-items: flex-end;
  background: white;
  border: 1px solid #d1d5db;
  border-radius: 24px;
  padding: 8px;
  gap: 8px;
  flex: 1;
  transition: all 0.2s ease;
}

.input-container:focus-within {
  border-color: #4a90e2;
  box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

#user-input {
  flex: 1;
  min-height: 20px;
  max-height: 120px;
  padding: 8px 12px;
  font-size: 16px;
  border: none;
  border-radius: 0;
  resize: none;
  font-family: inherit;
  line-height: 1.4;
  transition: none;
  box-sizing: border-box;
  overflow-y: auto;
  background: transparent;
}

#user-input:focus {
  outline: none;
  border: none;
  box-shadow: none;
}

button {
  padding: 12px 24px;
  font-size: 16px;
  background: #4a90e2;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  flex-shrink: 0;
  box-sizing: border-box;
  font-weight: 500;
}

button:hover:not(:disabled) {
  background: #357ABD;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(74, 144, 226, 0.3);
}

button:disabled {
  background: #9ca3af;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.send-button {
  padding: 8px;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #4a90e2;
  color: white;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
  box-sizing: border-box;
}

.send-button:hover:not(:disabled) {
  background: #357ABD;
  transform: translateY(-1px) scale(1.05);
  box-shadow: 0 4px 12px rgba(74, 144, 226, 0.3);
}

.send-button:disabled {
  background: #9ca3af;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.send-button svg {
  transition: transform 0.2s ease;
}

.send-button:hover:not(:disabled) svg {
  transform: translateY(-1px);
}

.send-button .loading {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.bubble {
  max-width: 85%;
  padding: 16px 20px;
  border-radius: 20px;
  font-size: 16px;
  line-height: 1.6;
  word-wrap: break-word;
  position: relative;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  transition: all 0.2s ease;
}

.bubble:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.user-bubble {
  background: linear-gradient(135deg, #4a90e2 0%, #357ABD 100%);
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 8px;
  margin-left: auto;
  margin-bottom: 8px;
  box-shadow: 0 2px 8px rgba(74, 144, 226, 0.2);
}

.user-bubble:hover {
  box-shadow: 0 4px 12px rgba(74, 144, 226, 0.3);
  transform: translateY(-1px);
}

.ai-bubble {
  background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
  color: #1f2937;
  align-self: flex-start;
  border-bottom-left-radius: 8px;
  margin-right: auto;
  margin-bottom: 8px;
  border: 1px solid #e5e7eb;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.ai-bubble:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transform: translateY(-1px);
}

/* Streaming text styling */
.streaming-text {
  white-space: pre-wrap;
  font-family: inherit;
}

/* Markdown content styling */
.markdown-content {
  font-family: inherit;
}

.markdown-content h1,
.markdown-content h2,
.markdown-content h3,
.markdown-content h4,
.markdown-content h5,
.markdown-content h6 {
  margin: 16px 0 8px 0;
  font-weight: 600;
  line-height: 1.3;
}

.markdown-content h1 { font-size: 1.5em; }
.markdown-content h2 { font-size: 1.3em; }
.markdown-content h3 { font-size: 1.1em; }

.markdown-content p {
  margin: 8px 0;
  line-height: 1.6;
}

.markdown-content ul,
.markdown-content ol {
  margin: 12px 0;
  padding-left: 24px;
}

.markdown-content li {
  margin: 8px 0;
  line-height: 1.6;
}

.markdown-content ol li {
  margin: 12px 0;
  padding-left: 8px;
}

.markdown-content ul li {
  margin: 8px 0;
  padding-left: 8px;
}

/* Handle numbered lists with colons (like "1. MATH 30:") */
.markdown-content ol li:first-line {
  font-weight: 500;
}

/* Better spacing for numbered lists */
.markdown-content ol {
  counter-reset: list-counter;
}

.markdown-content ol li {
  counter-increment: list-counter;
  position: relative;
}

.markdown-content blockquote {
  margin: 12px 0;
  padding: 8px 16px;
  border-left: 4px solid #4a90e2;
  background-color: #f8f9fa;
  border-radius: 0 4px 4px 0;
  font-style: italic;
}

.markdown-content code {
  background-color: #f1f3f4;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
  font-size: 0.9em;
}

.markdown-content pre {
  background-color: #f8f9fa;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 16px;
  overflow-x: auto;
  margin: 12px 0;
}

.markdown-content pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  font-size: 0.9em;
  line-height: 1.5;
}

.markdown-content table {
  border-collapse: collapse;
  width: 100%;
  margin: 12px 0;
  font-size: 0.9em;
}

.markdown-content th,
.markdown-content td {
  border: 1px solid #e5e7eb;
  padding: 8px 12px;
  text-align: left;
}

.markdown-content th {
  background-color: #f8f9fa;
  font-weight: 600;
}

.markdown-content a {
  color: #4a90e2;
  text-decoration: none;
}

.markdown-content a:hover {
  text-decoration: underline;
}

.markdown-content strong {
  font-weight: 600;
}

.markdown-content em {
  font-style: italic;
}

.markdown-content hr {
  border: none;
  border-top: 1px solid #e5e7eb;
  margin: 16px 0;
}

/* Error message styling */
.error-message {
  color: #dc2626;
  background-color: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 6px;
  padding: 12px;
  font-size: 0.9em;
}

/* Site header */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: #003366;
  padding: 16px 24px;
  color: white;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  flex-shrink: 0;
  box-sizing: border-box;
}

.school-name {
  font-size: 1.8rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-logo {
  width: 50px;
  height: 50px;
}

.clear-button {
  background-color: rgba(255, 255, 255, 0.1);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.clear-button:hover {
  background-color: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.5);
}

/* Scrollbar styling */
#chat-box::-webkit-scrollbar {
  width: 8px;
}

#chat-box::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

#chat-box::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 4px;
}

#chat-box::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

/* Responsive design */
@media (max-width: 768px) {
  .chat-container {
    max-width: 100%;
    border-radius: 0;
    height: 100vh;
  }
  
  .bubble {
    max-width: 90%;
    padding: 12px 16px;
  }
  
  #chat-box {
    padding: 16px;
  }
  
  .input-area {
    padding: 12px;
  }
  
  #user-input {
    min-height: 44px;
    max-height: 100px;
  }
  
  button {
    padding: 10px 20px;
  }
}

/* Handle very small screens */
@media (max-height: 600px) {
  .chat-container {
    height: 100vh;
  }
  
  #chat-box {
    padding: 12px;
  }
  
  .input-area {
    padding: 8px 12px;
  }
  
  #user-input {
    min-height: 40px;
    max-height: 80px;
  }
  
  button {
    padding: 8px 16px;
    font-size: 14px;
  }
}
