:root {
  --primary: #9b51e0;
  --primary-light: #d8b4fe;
  --secondary: #ff7e67;
  --background: #fdfaf6;
  --surface: #ffffff;
  --text: #2d3748;
  --text-muted: #718096;
  --chat-profe: rgba(155, 81, 224, 0.08);
  --chat-trini: rgba(255, 126, 103, 0.1);
  --radius: 20px;
  --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.01);
}

@media (prefers-color-scheme: dark) {
  :root {
    --background: #1a202c;
    --surface: #2d3748;
    --text: #f7fafc;
    --text-muted: #a0aec0;
    --chat-profe: rgba(155, 81, 224, 0.2);
    --chat-trini: rgba(255, 126, 103, 0.2);
  }
}

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

body {
  background-color: var(--background);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  transition: background-color 0.3s ease, color 0.3s ease;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.2;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes float {
  0% { transform: translateY(0px); }
  50% { transform: translateY(-10px); }
  100% { transform: translateY(0px); }
}

@keyframes pulse-mic {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 126, 103, 0.7); }
  70% { transform: scale(1.1); box-shadow: 0 0 0 15px rgba(255, 126, 103, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 126, 103, 0); }
}

.animate-fade-in {
  animation: fadeIn 0.5s ease forwards;
}

/* Layout */
.container {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.header {
  text-align: center;
  margin-bottom: 2.5rem;
}

.header h1 {
  font-size: 2.5rem;
  color: var(--primary);
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

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

/* Card */
.card {
  background-color: var(--surface);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
}

/* Upload Area */
.upload-area {
  border: 3px dashed var(--primary-light);
  border-radius: var(--radius);
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  background-color: var(--chat-profe);
}

.upload-area input {
  display: none;
}

.upload-icon {
  font-size: 48px;
  color: var(--primary);
  margin-bottom: 1rem;
  display: inline-block;
  animation: float 3s ease-in-out infinite;
}

.upload-area h3 {
  color: var(--primary);
  margin-bottom: 0.5rem;
}

.upload-area p {
  color: var(--text-muted);
}

/* Image Preview */
.image-preview {
  margin-top: 1rem;
  border-radius: calc(var(--radius) - 5px);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.image-preview img {
  width: 100%;
  max-height: 250px;
  object-fit: cover;
  display: block;
}

.chat-image {
  max-width: 100%;
  border-radius: 10px;
  margin-top: 10px;
  display: block;
}

/* Action Buttons */
.action-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #b87cf8);
  color: white;
  padding: 0.8rem 1.8rem;
  border-radius: 9999px;
  font-weight: 600;
  font-size: 1.1rem;
  box-shadow: 0 4px 14px 0 rgba(155, 81, 224, 0.39);
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px) scale(1.02);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-secondary {
  background: rgba(155, 81, 224, 0.1);
  color: var(--primary);
  padding: 0.6rem 1.2rem;
  border-radius: 9999px;
  font-weight: 600;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

/* Chat System */
.chat-container {
  margin-top: 1.5rem;
  border-top: 1px solid rgba(0,0,0,0.05);
  padding-top: 1.5rem;
}

.chat-history {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin-bottom: 2rem;
  max-height: 500px;
  overflow-y: auto;
  padding-right: 0.5rem;
}

/* Scrollbar bonito */
.chat-history::-webkit-scrollbar {
  width: 6px;
}
.chat-history::-webkit-scrollbar-thumb {
  background: var(--primary-light);
  border-radius: 10px;
}

/* Globos de Chat */
.chat-message {
  display: flex;
  flex-direction: column;
  max-width: 90%;
  animation: fadeIn 0.3s ease;
}

.chat-message.profe {
  align-self: flex-start;
}

.chat-message.trini {
  align-self: flex-end;
  align-items: flex-end;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.3rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.chat-header.trini-header {
  flex-direction: row-reverse;
}

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

.avatar.trini-avatar {
  background: var(--secondary);
}

.chat-bubble {
  padding: 1.2rem;
  border-radius: var(--radius);
  font-size: 1.05rem;
  line-height: 1.6;
  white-space: pre-wrap;
  position: relative;
}

.profe .chat-bubble {
  background-color: var(--chat-profe);
  border-bottom-left-radius: 0;
  border: 1px solid rgba(155, 81, 224, 0.1);
}

.trini .chat-bubble {
  background-color: var(--chat-trini);
  border-bottom-right-radius: 0;
  border: 1px solid rgba(255, 126, 103, 0.1);
}

.play-audio-btn {
  margin-top: 0.8rem;
  background: rgba(155, 81, 224, 0.15);
  color: var(--primary);
  border-radius: 20px;
  padding: 0.4rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}
.play-audio-btn:hover { background: rgba(155, 81, 224, 0.25); }

/* Input de Chat */
.chat-input-area {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  background: var(--background);
  padding: 0.5rem;
  border-radius: 9999px;
  border: 1px solid rgba(0,0,0,0.1);
}

@media (prefers-color-scheme: dark) {
  .chat-input-area { border: 1px solid rgba(255,255,255,0.1); }
}

.chat-input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 0.8rem 0.5rem;
  font-size: 1rem;
  color: var(--text);
  outline: none;
}

.btn-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  color: white;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.mic-btn {
  background-color: var(--secondary);
}

.mic-btn.recording {
  background-color: #f56565; /* Rojo */
  animation: pulse-mic 1.5s infinite;
}

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

.camera-btn {
  background-color: var(--primary-light);
  color: var(--primary);
}

.send-btn:hover:not(:disabled), .mic-btn:hover:not(.recording), .camera-btn:hover {
  transform: scale(1.05);
}

.loader {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255,255,255,0.3);
  border-radius: 50%;
  border-top-color: white;
  animation: spin 1s ease-in-out infinite;
}

.loader-dark {
  border: 3px solid rgba(155, 81, 224, 0.2);
  border-top-color: var(--primary);
}

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