/* ============================================================
   VIDYARTHIASTRA — AI ASSISTANT CHATBOT STYLES
   Light Academic Identity (Matches Home Page)
   ============================================================ */

.ai-chat-body {
  margin: 0;
  padding: 0;
  background: #f8fafc;
  color: #17213d;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Header */
.ai-chat-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  padding-top: max(12px, env(safe-area-inset-top));
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
  box-sizing: border-box;
  width: 100%;
  gap: 12px;
}

.ai-chat-header-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.ai-logo {
  display: inline-flex !important;
  align-items: center !important;
  text-decoration: none !important;
  flex-shrink: 0 !important;
  line-height: 0 !important;
  margin: 0 !important;
}

.ai-logo .brand-logo-img {
  height: 34px;
  width: auto;
  max-width: 145px;
  object-fit: contain;
  display: block;
  transition: transform 0.2s ease;
}

.ai-logo:hover .brand-logo-img {
  transform: scale(1.02);
}

.ai-chat-header-right {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.ai-back-btn {
  background: #ffffff;
  color: #1e293b;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
}

.ai-back-btn:hover,
.ai-back-btn:active {
  background: #f1f5f9;
  color: #2457e6;
  border-color: #cbd5e1;
}

.ai-header-title {
  display: flex;
  flex-direction: column;
}

.ai-header-title h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  color: #17213d;
  line-height: 1.2;
}

.ai-header-title p {
  margin: 2px 0 0 0;
  font-size: 12px;
  color: #64748b;
}

.ai-shortcut-btn {
  background: #ffffff;
  color: #2457e6;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  transition: all 0.2s;
}

.ai-shortcut-btn:hover {
  background: #eff6ff;
  border-color: #2457e6;
}

.ai-clear-btn {
  background: #ffffff;
  color: #64748b;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.ai-clear-btn:hover {
  color: #17213d;
  background: #f1f5f9;
}

/* Chat Messages Scroll Container */
.ai-chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  -webkit-overflow-scrolling: touch;
  max-width: 820px;
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
}

/* Suggested Questions Section */
.ai-suggestions-container {
  padding: 10px 16px;
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
}

.ai-suggestions-title {
  font-size: 11px;
  font-weight: 800;
  color: #64748b;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  max-width: 820px;
  margin-left: auto;
  margin-right: auto;
}

.ai-suggestions-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
  max-width: 820px;
  margin: 0 auto;
  -webkit-overflow-scrolling: touch;
}

.ai-suggestions-scroll::-webkit-scrollbar {
  display: none;
}

.ai-suggestion-chip {
  background: #ffffff;
  color: #334155;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.ai-suggestion-chip:active,
.ai-suggestion-chip:hover {
  background: #2457e6;
  color: #ffffff;
  border-color: #2457e6;
}

/* Message Bubbles */
.ai-message-row {
  display: flex;
  gap: 10px;
  max-width: 88%;
}

.ai-message-row.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.ai-message-row.assistant {
  align-self: flex-start;
}

.ai-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #2457e6;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  flex-shrink: 0;
}

.ai-avatar.user-avatar {
  background: #dbeafe;
  color: #1d4ed8;
  font-size: 13px;
  font-weight: 800;
}

.ai-bubble {
  padding: 14px 18px;
  border-radius: 16px;
  font-size: 14.5px;
  line-height: 1.55;
  word-break: break-word;
}

.ai-message-row.user .ai-bubble {
  background: #2457e6;
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.ai-message-row.assistant .ai-bubble {
  background: #ffffff;
  color: #17213d;
  border: 1px solid #e2e8f0;
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}

.ai-bubble p {
  margin: 0 0 10px 0;
}

.ai-bubble p:last-child {
  margin-bottom: 0;
}

.ai-bubble ul,
.ai-bubble ol {
  margin: 6px 0 10px 20px;
  padding: 0;
}

.ai-bubble li {
  margin-bottom: 4px;
}

.ai-bubble strong {
  color: #1e293b;
  font-weight: 700;
}

.ai-message-row.user .ai-bubble strong {
  color: #ffffff;
}

.ai-bubble pre {
  background: #f8fafc;
  color: #1e293b;
  padding: 12px;
  border-radius: 10px;
  overflow-x: auto;
  font-family: monospace;
  font-size: 13px;
  margin: 10px 0;
  border: 1px solid #e2e8f0;
}

/* Welcome Card Specific Formatting */
.ai-welcome-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 18px 20px;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.04);
}

.ai-welcome-card h3 {
  margin: 0 0 8px 0;
  font-size: 16px;
  font-weight: 800;
  color: #17213d;
}

.ai-welcome-card p {
  margin: 0 0 8px 0;
  font-size: 14px;
  color: #475569;
  line-height: 1.5;
}

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

/* Academic Paper Question Components */
.ai-paper-header-badge {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  margin-bottom: 10px;
  font-size: 12.5px;
  font-weight: 700;
  color: #1e293b;
}

.ai-paper-title {
  color: #1e293b;
}

.ai-question-num {
  background: #2457e6;
  color: #ffffff;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
}

.ai-paper-question-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-left: 3px solid #2457e6;
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 12px;
  font-size: 14px;
  color: #0f172a;
}

.ai-question-text {
  font-weight: 600;
  line-height: 1.5;
  margin-bottom: 8px;
}

.ai-question-options {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13.5px;
  color: #334155;
  padding-left: 4px;
}

.ai-option-item {
  padding: 3px 0;
}

.ai-paper-action-bar {
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px solid #f1f5f9;
}

.ai-view-paper-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #ffffff;
  color: #2457e6;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  transition: all 0.2s;
}

.ai-view-paper-btn:hover {
  background: #eff6ff;
  border-color: #2457e6;
}

/* Mode Badges */
.ai-mode-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 3px 8px;
  border-radius: 6px;
  margin-bottom: 8px;
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #dbeafe;
}

/* Verified Sources Container */
.ai-sources-container {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #f1f5f9;
}

.ai-sources-title {
  font-size: 11px;
  font-weight: 800;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.ai-sources-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ai-source-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 12.5px;
  color: #2457e6;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s;
}

.ai-source-pill:hover,
.ai-source-pill:active {
  background: #eff6ff;
  border-color: #2457e6;
}

.ai-source-domain {
  font-size: 10.5px;
  background: #e2e8f0;
  color: #475569;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 700;
}

/* Typing Loading Indicator */
.ai-typing-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 18px;
  background: #ffffff;
  border-radius: 16px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
  width: fit-content;
}

.ai-typing-indicator span {
  width: 7px;
  height: 7px;
  background: #2457e6;
  border-radius: 50%;
  animation: typing-bounce 1.4s infinite ease-in-out both;
}

.ai-typing-indicator span:nth-child(1) {
  animation-delay: -0.32s;
}

.ai-typing-indicator span:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes typing-bounce {
  0%, 80%, 100% {
    transform: scale(0);
  }
  40% {
    transform: scale(1);
  }
}

/* Error Banner in Chat */
.ai-error-banner {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  color: #991b1b;
  padding: 14px 18px;
  border-radius: 12px;
  font-size: 13.5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
}

.ai-retry-btn {
  background: #991b1b;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

/* Input Area */
.ai-input-area {
  padding: 12px 16px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.ai-input-wrapper {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  max-width: 820px;
}

.ai-chat-input {
  width: 100%;
  background: #ffffff;
  color: #17213d;
  border: 1px solid #cbd5e1;
  border-radius: 24px;
  padding: 12px 20px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.ai-chat-input:focus {
  border-color: #2457e6;
  box-shadow: 0 0 0 3px rgba(36, 87, 230, 0.12);
}

.ai-send-btn {
  background: #2457e6;
  color: #ffffff;
  border: none;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.15s, background 0.2s;
}

.ai-send-btn:disabled {
  background: #cbd5e1;
  color: #94a3b8;
  cursor: not-allowed;
}

.ai-send-btn:not(:disabled):hover {
  background: #1d4ed8;
}

.ai-send-btn:not(:disabled):active {
  transform: scale(0.94);
}

/* Locked AI Assistant Container (Coming Soon Screen) */
.ai-locked-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
  box-sizing: border-box;
  width: 100%;
}

.ai-locked-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 18px;
  padding: 44px 32px;
  max-width: 380px;
  width: 100%;
  text-align: center;
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.06);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
}

.ai-locked-title {
  margin: 0;
  font-size: 26px;
  font-weight: 800;
  color: #17213d;
  letter-spacing: -0.3px;
}

.ai-locked-gpt-btn {
  background-color: #2457e6;
  color: #ffffff;
  border: none;
  border-radius: 12px;
  padding: 13px 24px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  max-width: 260px;
  transition: background-color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
  box-shadow: 0 2px 8px rgba(36, 87, 230, 0.25);
  -webkit-tap-highlight-color: transparent;
}

.ai-locked-gpt-btn:hover {
  background-color: #1d4ed8;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(36, 87, 230, 0.35);
}

.ai-locked-gpt-btn:active {
  transform: scale(0.98);
  background-color: #1e40af;
}

.ai-locked-gpt-btn:focus-visible {
  outline: 2px solid #2457e6;
  outline-offset: 2px;
}

/* Desktop Responsiveness */
@media (min-width: 768px) {
  .ai-chat-body {
    max-width: 900px;
    margin: 0 auto;
    border-left: 1px solid #e2e8f0;
    border-right: 1px solid #e2e8f0;
    box-shadow: 0 0 30px rgba(15, 23, 42, 0.05);
  }
}

/* Mobile Responsiveness for Header & Controls */
@media (max-width: 768px) {
  .ai-chat-header {
    padding: 10px 14px;
    padding-top: max(10px, env(safe-area-inset-top));
    gap: 8px;
  }

  .ai-chat-header-left {
    gap: 10px;
  }

  .ai-logo .brand-logo-img {
    height: 28px;
    max-width: 110px;
  }

  .ai-header-title h1 {
    font-size: 16px;
  }

  .ai-header-title p {
    font-size: 11px;
  }

  .ai-shortcut-btn,
  .ai-clear-btn {
    padding: 5px 10px;
    font-size: 11px;
  }
}



@media (max-width: 480px) {
  .ai-chat-header {
    padding: 8px 10px;
    padding-top: max(8px, env(safe-area-inset-top));
    gap: 6px;
  }

  .ai-chat-header-left {
    gap: 8px;
  }

  .ai-back-btn {
    width: 32px;
    height: 32px;
    font-size: 16px;
    border-radius: 8px;
  }

  .ai-logo .brand-logo-img {
    height: 25px;
    max-width: 90px;
  }

  .ai-header-title h1 {
    font-size: 14px;
    white-space: nowrap;
  }

  .ai-header-title p {
    display: none;
  }

  .ai-chat-header-right {
    gap: 4px;
  }

  .ai-shortcut-btn,
  .ai-clear-btn {
    padding: 4px 7px;
    font-size: 11px;
  }
}

@media (max-width: 360px) {
  .ai-logo .brand-logo-img {
    height: 22px;
    max-width: 75px;
  }

  .ai-shortcut-btn {
    display: none; /* Keep Clear Chat visible on extreme narrow 320px */
  }

  .ai-clear-btn {
    padding: 4px 6px;
    font-size: 10px;
  }
}

