/* Student AI Chat System Styles - CORRECT VERSION */

/* AI Tools Section - Gray Box */
.ai-tools-section {
  margin: 20px 0 0 0 !important;
  padding: 16px !important;
  background: linear-gradient(135deg, var(--bg), #E6EDF6) !important;
  border-radius: var(--radius) !important;
  border: 1px solid var(--border) !important;
}

.simple-notice {
  padding: 0 !important;
  background: none !important;
  border: none !important;
  color: var(--ink) !important; /* Black text by default */
  font-size: 0.95rem !important;
  line-height: 1.6 !important;
  margin-bottom: 0 !important;
}

.simple-notice .highlight {
  color: var(--brand) !important; /* Dark blue for "Two ways to get help:" */
  font-weight: 600 !important;
}

/* Brand Blue Ask AI Button (matches Sign Up) */
.btn.ask-ai {
  background: linear-gradient(135deg, var(--brand), #3B6BC4) !important;
  color: white !important;
  box-shadow: 0 4px 12px rgba(47, 93, 159, 0.3) !important;
}

.btn.ask-ai:hover {
  box-shadow: 0 6px 16px rgba(47, 93, 159, 0.4) !important;
  transform: translateY(-2px);
}

/* Space after buttons before footer */
.actions {
  margin-bottom: 40px !important;
}

/* Mobile */
@media (max-width: 768px) {
  .ai-tools-section {
    margin: 16px 0 0 0 !important;
    padding: 14px !important;
  }
  
  .simple-notice {
    padding: 0 !important;
    font-size: 0.9rem !important;
    margin-bottom: 0 !important;
  }
}

/* Student AI Chat Modal */
.student-ai-chat {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10000;
  display: none;
}

.chat-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

.chat-container {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 95%;
  max-width: 1200px;  /* Much wider for reading */
  max-height: 92vh;   /* Much taller for long responses */
  background: white;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: all 0.2s ease;
}

/* Drag & Drop State */
.chat-container.drag-over {
  border: 3px solid var(--accent);
  background: #F0F4FF;
  box-shadow: 0 20px 60px rgba(59, 130, 246, 0.4);
}

.chat-container.drag-over .chat-messages {
  background: #E0E7FF;
}

.chat-container.drag-over::before {
  content: "📎 Drop files here to upload";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--accent);
  background: white;
  padding: 20px 40px;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  pointer-events: none;
}

/* Minimized State */
.chat-container.minimized {
  top: auto;
  bottom: 20px;
  right: 20px;
  left: auto;
  transform: none;
  width: 320px;
  max-width: calc(100vw - 40px);
  max-height: 56px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}

.chat-container.minimized .chat-messages,
.chat-container.minimized .chat-input-area,
.chat-container.minimized .chat-file-preview,
.chat-container.minimized .initial-actions,
.chat-container.minimized .upload-interface,
.chat-container.minimized .send-only-area,
.chat-container.minimized .chat-footer,
.chat-container.minimized .chat-download-btns {
  display: none !important;
}

.chat-container.minimized .chat-header {
  border-radius: 12px;
  cursor: pointer;
  padding: 12px 16px;
}

.chat-container.minimized .chat-header:hover {
  background: linear-gradient(135deg, var(--brand) 0%, #254a7f 100%);
}

.chat-container.minimized .chat-title {
  font-size: 0.95rem;
}

/* Chat Header */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: linear-gradient(135deg, var(--accent) 0%, #2F5D9F 100%);
  color: white;
  gap: 12px;
}

.chat-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.1rem;
}

.chat-icon {
  font-size: 1.4rem;
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-minimize {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  font-size: 1.8rem;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  line-height: 1;
}

.chat-minimize:hover {
  background: rgba(255, 255, 255, 0.3);
}

.chat-close {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  font-size: 1.8rem;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  line-height: 1;
}

.chat-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Chat Messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: #F6F8FC;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chat-message {
  display: flex;
  flex-direction: column;
  max-width: 90%;  /* Use more width for reading content */
  animation: messageSlideIn 0.3s ease-out;
}

@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chat-message.user-message {
  align-self: flex-end;
  align-items: flex-end;
}

.chat-message.ai-message {
  align-self: flex-start;
  align-items: flex-start;
}

.message-content {
  padding: 12px 16px;
  border-radius: 12px;
  line-height: 1.6;
  word-wrap: break-word;
  font-size: 1rem;  /* Clear, readable font size */
}

.user-message .message-content {
  background: linear-gradient(135deg, var(--accent), #2563EB);
  color: white;
}

.ai-message .message-content {
  background: white;
  color: var(--ink);
  border: 2px solid var(--border);
  padding: 16px 20px;  /* More padding for long reading content */
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  gap: 6px;
  padding: 12px 16px;
  background: white;
  border-radius: 12px;
  width: fit-content;
  border: 2px solid var(--border);
}

.typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  animation: typingBounce 1.4s infinite;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingBounce {
  0%, 60%, 100% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-10px);
  }
}

/* File Preview in Chat */
.chat-file-preview {
  display: none;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 20px;
  background: #EFF6FF;
  border-top: 2px solid var(--border);
}

.file-preview-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: white;
  border-radius: 8px;
  border: 2px solid var(--border);
  font-size: 0.9rem;
}

.file-name {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.remove-file-btn {
  background: #EF4444;
  color: white;
  border: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}

.remove-file-btn:hover {
  background: #DC2626;
}

.pdf-icon, .text-icon {
  font-size: 1.5rem;
}

/* Chat Input Area */
.chat-input-area {
  display: flex;
  gap: 12px;
  padding: 16px 20px;
  background: white;
  border-top: 2px solid var(--border);
  align-items: flex-end;
}

/* Initial Actions Area - Shows First */
.initial-actions {
  padding: 30px 20px;
  background: white;
  border-top: 2px solid var(--border);
  text-align: center;
}

.action-message {
  margin-bottom: 24px;
}

.action-message p {
  margin: 8px 0;
  font-size: 1rem;
  color: var(--ink);
}

.action-message p:first-child {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--brand);
}

.action-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.action-btn {
  padding: 16px 32px;
  border-radius: 12px;
  font-size: 1.1rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  gap: 12px;
}

.action-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

.action-btn.upload-btn {
  background: linear-gradient(135deg, var(--accent), #2563EB);
  color: white;
}

.action-btn.send-btn {
  background: linear-gradient(135deg, var(--brand), #3B6BC4);
  color: white;
}

/* Upload Interface */
.upload-interface {
  padding: 40px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 300px;
}

.upload-zone {
  width: 100%;
  max-width: 500px;
  padding: 60px 40px;
  border: 3px dashed var(--accent);
  border-radius: 16px;
  background: linear-gradient(135deg, #EFF6FF, #DBEAFE);
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
}

.upload-zone:hover {
  border-color: var(--brand);
  background: linear-gradient(135deg, #DBEAFE, #BFDBFE);
  transform: scale(1.02);
}

.upload-icon {
  font-size: 4rem;
  margin-bottom: 20px;
}

.upload-text p {
  margin: 8px 0;
  font-size: 1.1rem;
  color: var(--ink);
}

.upload-text p:first-child {
  font-weight: 600;
  color: var(--brand);
}

.browse-btn {
  margin: 16px 0;
  padding: 12px 32px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.browse-btn:hover {
  background: var(--brand);
  transform: translateY(-2px);
}

.upload-hint {
  margin-top: 12px;
  font-size: 0.9rem;
  color: var(--muted);
}

.send-only-area {
  padding: 16px 20px;
  background: white;
  border-top: 2px solid var(--border);
  text-align: center;
}

.chat-file-btn {
  background: var(--bg);
  border: 2px solid var(--border);
  color: var(--accent);
  font-size: 1.3rem;
  width: 48px;
  height: 48px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.chat-file-btn:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* Chat Microphone Button - More Visible for Kids */
.chat-mic-btn {
  background: linear-gradient(135deg, #F0F4FF, #E0E7FF);
  border: 2px solid var(--accent);
  color: var(--accent);
  font-size: 1.5rem;
  width: 48px;
  height: 48px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
  user-select: none;
  -webkit-user-select: none;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.2);
  position: relative;
}

.chat-mic-btn::after {
  content: 'Voice';
  position: absolute;
  bottom: -18px;
  font-size: 0.65rem;
  color: var(--accent);
  font-weight: 600;
  white-space: nowrap;
}

.chat-mic-btn:hover {
  background: linear-gradient(135deg, var(--accent), #2563EB);
  color: white;
  border-color: var(--accent);
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.chat-mic-btn.listening {
  background: #ef4444;
  color: white;
  border-color: #ef4444;
  animation: pulse-red 1.5s ease-in-out infinite;
  box-shadow: 0 4px 16px rgba(239, 68, 68, 0.4);
}

.chat-mic-btn.listening::after {
  content: 'Listening...';
  color: #ef4444;
}

@keyframes pulse-red {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.8;
    transform: scale(1.05);
  }
}

#chatInput {
  flex: 1;
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 10px 16px;
  font-family: inherit;
  font-size: 1rem;
  resize: none;
  line-height: 1.4;
  min-height: 28px;
  max-height: 120px;
}

#chatInput:focus {
  outline: none;
  border-color: var(--accent);
}

.chat-send-btn {
  background: var(--accent);
  border: none;
  color: white;
  padding: 12px 20px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  flex-shrink: 0;
  height: 48px;
}

.chat-send-btn:hover {
  background: #2563EB;
  transform: translateY(-1px);
}

.send-icon {
  font-size: 1.2rem;
}

/* Download Buttons */
.chat-download-btns {
  display: flex;
  gap: 12px;
}

.download-btn {
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: white;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.8rem;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.download-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.4);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Chat Footer */
.chat-footer {
  padding: 12px 20px;
  background: #F6F8FC;
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .chat-container {
    width: 100%;
    max-width: 100%;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
  }
  
  /* Hide download buttons on mobile - they clutter the header */
  .chat-download-btns {
    display: none !important;
  }
  
  /* More compact header on mobile */
  .chat-header {
    padding: 12px 16px;
  }
  
  .chat-title {
    font-size: 1rem;
  }
  
  .chat-icon {
    font-size: 1.2rem;
  }
  
  /* Smaller header buttons */
  .chat-minimize,
  .chat-close {
    width: 32px;
    height: 32px;
    font-size: 1.5rem;
  }
  
  .message-content {
    max-width: 85%;
  }
  
  .chat-input-area {
    padding: 12px 16px;
  }
  
  .chat-send-btn {
    padding: 12px 16px;
  }
  
  .chat-mic-btn::after {
    display: none;
  }
  
  .initial-actions {
    padding: 20px 16px;
  }
  
  .action-buttons {
    flex-direction: column;
    width: 100%;
  }
  
  .action-btn {
    width: 100%;
    justify-content: center;
    padding: 14px 24px;
    font-size: 1rem;
  }
}

/* Scrollbar Styling */
.chat-messages::-webkit-scrollbar {
  width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
  background: #E6EDF6;
  border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: #2F5D9F;
}

/* Toast Notifications */
.chat-toast {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: white;
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: 600;
  z-index: 10001;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translate(-50%, -20px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

@keyframes slideUp {
  from {
    opacity: 1;
    transform: translate(-50%, 0);
  }
  to {
    opacity: 0;
    transform: translate(-50%, -20px);
  }
}