/* ==========================================================================
   STUDY BUDDY - CSS STYLESHEET
   Design Theme: Cute, Minimalist, Pastel Light Blue, High Readability
   ========================================================================== */

/* --- Design Tokens & Variables --- */
:root {
  /* Blue Palette */
  --primary-50: #F0F7FF;
  --primary-100: #E0EFFF;
  --primary-200: #BFDBFE;
  --primary-300: #93C5FD;
  --primary-400: #60A5FA;
  --primary-500: #3B82F6;
  --primary-600: #2563EB;
  --primary-700: #1D4ED8;
  --primary-800: #1E40AF;
  --primary-900: #1E3A8A;

  /* Neutral & Pastel Accents */
  --bg-page: #F4F8FE;
  --bg-surface: #FFFFFF;
  --bg-glass: rgba(255, 255, 255, 0.88);
  --border-light: #DBEAFE;
  --border-subtle: #E2E8F0;

  /* Text Colors */
  --text-main: #1E293B;
  --text-secondary: #475569;
  --text-muted: #64748B;
  --text-light: #94A3B8;
  --text-white: #FFFFFF;

  /* Accents */
  --accent-yellow: #FDE047;
  --accent-amber: #F59E0B;
  --accent-green: #10B981;
  --accent-pink: #F472B6;
  --accent-purple: #A855F7;
  --accent-red: #EF4444;

  /* Typography */
  --font-family-base: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-family-heading: 'Poppins', 'Nunito', sans-serif;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(37, 99, 235, 0.05);
  --shadow-sm: 0 2px 8px rgba(37, 99, 235, 0.08);
  --shadow-md: 0 6px 16px rgba(37, 99, 235, 0.10);
  --shadow-lg: 0 12px 28px rgba(37, 99, 235, 0.12);
  --shadow-bubble: 0 4px 14px rgba(37, 99, 235, 0.06);

  /* Radius */
  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-xl: 30px;
  --radius-pill: 9999px;

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
  --transition-bounce: 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Layout dimensions */
  --header-height: 72px;
  --max-content-width: 920px;
}

/* --- Base & Reset --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  font-family: var(--font-family-base);
  background-color: var(--bg-page);
  color: var(--text-main);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Background aesthetic soft gradient with floating soft bubbles */
body {
  background: radial-gradient(circle at 10% 20%, rgba(191, 219, 254, 0.45) 0%, transparent 40%),
              radial-gradient(circle at 90% 80%, rgba(147, 197, 253, 0.35) 0%, transparent 45%),
              linear-gradient(180deg, #F0F7FF 0%, #E2EEFE 100%);
  background-attachment: fixed;
}

/* Links & Buttons defaults */
a {
  color: var(--primary-600);
  text-decoration: none;
  font-weight: 600;
  transition: color var(--transition-fast);
}
a:hover {
  color: var(--primary-700);
  text-decoration: underline;
}

button {
  font-family: inherit;
  border: none;
  background: none;
  cursor: pointer;
  outline: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* --- Main Layout Grid --- */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: var(--max-content-width);
  margin: 0 auto;
  background: var(--bg-surface);
  box-shadow: 0 0 40px rgba(37, 99, 235, 0.08);
  position: relative;
  overflow: hidden;
}

@media (min-width: 960px) {
  .app-container {
    border-left: 1px solid var(--border-light);
    border-right: 1px solid var(--border-light);
  }
}

/* --- App Header --- */
.app-header {
  height: var(--header-height);
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1.5px solid var(--border-light);
  z-index: 20;
  position: relative;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Mascot Avatar Mini in Header */
.mascot-avatar {
  position: relative;
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #DBEAFE 0%, #93C5FD 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  border: 2px solid #FFFFFF;
}

.mascot-face {
  position: relative;
  width: 26px;
  height: 22px;
  background: #FFFFFF;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(37, 99, 235, 0.15);
}

.mascot-eyes {
  position: relative;
  display: flex;
  gap: 8px;
}
.mascot-eyes::before,
.mascot-eyes::after {
  content: '';
  width: 4px;
  height: 4px;
  background: var(--primary-700);
  border-radius: 50%;
  display: inline-block;
  animation: cuteBlink 4s infinite;
}

.mascot-smile {
  width: 8px;
  height: 4px;
  border-bottom: 2px solid var(--primary-600);
  border-radius: 0 0 6px 6px;
  margin-top: 2px;
}

.status-indicator {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 12px;
  height: 12px;
  background-color: var(--accent-green);
  border: 2px solid #FFFFFF;
  border-radius: 50%;
  animation: pulseGreen 2.5s infinite;
}

@keyframes pulseGreen {
  0%, 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6); }
  50% { box-shadow: 0 0 0 5px rgba(16, 185, 129, 0); }
}

@keyframes cuteBlink {
  0%, 96%, 100% { transform: scaleY(1); }
  98% { transform: scaleY(0.1); }
}

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

.brand-name {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-name h1 {
  font-family: var(--font-family-heading);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary-800);
  letter-spacing: -0.3px;
  line-height: 1.2;
}

.ai-badge {
  font-size: 0.68rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary-500), var(--primary-700));
  color: #FFFFFF;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  gap: 3px;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}

.brand-tagline {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* Header Action Buttons */
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: var(--radius-pill);
  background-color: var(--primary-50);
  color: var(--primary-700);
  font-size: 0.85rem;
  font-weight: 700;
  border: 1px solid var(--primary-200);
  transition: all var(--transition-bounce);
}

.btn-icon:hover {
  background-color: var(--primary-200);
  color: var(--primary-900);
  transform: translateY(-1px);
}

.btn-icon:active {
  transform: scale(0.95);
}

.btn-reset {
  background: linear-gradient(135deg, #FEF2F2, #FEE2E2);
  color: #DC2626;
  border-color: #FECACA;
}

.btn-reset:hover {
  background: #FCA5A5;
  color: #991B1B;
}

@media (max-width: 600px) {
  .btn-label-desktop {
    display: none;
  }
  .btn-icon {
    padding: 9px;
    border-radius: 50%;
    width: 38px;
    height: 38px;
    justify-content: center;
  }
  .brand-tagline {
    display: none;
  }
  .app-header {
    padding: 0 14px;
    height: 64px;
  }
}

/* --- Main Chat Area --- */
.chat-main {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  position: relative;
  scroll-behavior: smooth;
}

/* Custom Scrollbar */
.chat-main::-webkit-scrollbar {
  width: 6px;
}
.chat-main::-webkit-scrollbar-track {
  background: transparent;
}
.chat-main::-webkit-scrollbar-thumb {
  background: var(--primary-200);
  border-radius: var(--radius-pill);
}
.chat-main::-webkit-scrollbar-thumb:hover {
  background: var(--primary-400);
}

.chat-messages-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  justify-content: flex-start;
  gap: 16px;
}

/* --- Welcome Hero Card --- */
.welcome-card {
  background: linear-gradient(180deg, #FFFFFF 0%, #F5F9FF 100%);
  border: 2px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 26px 22px;
  text-align: center;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
  animation: fadeInDown 0.5s ease;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.welcome-card.dismissed {
  display: none;
}

/* Cute Robot Mascot */
.welcome-mascot-large {
  display: flex;
  justify-content: center;
  margin-bottom: 14px;
}

.cute-robot {
  position: relative;
  width: 80px;
  height: 80px;
  animation: floatMascot 4s ease-in-out infinite;
}

@keyframes floatMascot {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.robot-antenna {
  width: 4px;
  height: 12px;
  background: var(--primary-400);
  margin: 0 auto;
  position: relative;
}
.robot-antenna::before {
  content: '';
  position: absolute;
  top: -6px;
  left: -4px;
  width: 12px;
  height: 12px;
  background: var(--accent-amber);
  border-radius: 50%;
  border: 2px solid #FFFFFF;
}

.robot-head {
  position: relative;
  width: 76px;
  height: 58px;
  background: linear-gradient(135deg, #DBEAFE 0%, #BFDBFE 100%);
  border: 3px solid #FFFFFF;
  border-radius: 18px;
  box-shadow: var(--shadow-md);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.robot-eyes {
  display: flex;
  gap: 16px;
}
.robot-eyes .eye {
  width: 10px;
  height: 12px;
  background: var(--primary-900);
  border-radius: 50%;
  position: relative;
  animation: cuteBlink 4s infinite;
}
.robot-eyes .eye::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 4px;
  height: 4px;
  background: #FFFFFF;
  border-radius: 50%;
}

.robot-blush {
  position: absolute;
  bottom: 12px;
  width: 10px;
  height: 6px;
  background: var(--accent-pink);
  border-radius: 50%;
  opacity: 0.6;
}
.left-blush { left: 8px; }
.right-blush { right: 8px; }

.robot-mouth {
  width: 14px;
  height: 7px;
  border-bottom: 3px solid var(--primary-700);
  border-radius: 0 0 10px 10px;
  margin-top: 4px;
}

.robot-hat {
  position: absolute;
  top: -8px;
  right: 0px;
  font-size: 1.5rem;
  transform: rotate(15deg);
}

.welcome-title {
  font-family: var(--font-family-heading);
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--primary-900);
  margin-bottom: 8px;
}

.welcome-text {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.55;
  max-width: 600px;
  margin: 0 auto 16px auto;
}

.feature-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-bottom: 20px;
}

.f-badge {
  background: var(--primary-100);
  color: var(--primary-800);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--primary-200);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Suggestion Chips Section */
.suggestions-section {
  border-top: 1px dashed var(--border-light);
  padding-top: 18px;
}

.suggestions-heading {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary-700);
  margin-bottom: 12px;
}

.suggestion-chips-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.chip-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #FFFFFF;
  border: 1.5px solid var(--primary-200);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  text-align: left;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-main);
  box-shadow: var(--shadow-xs);
  transition: all var(--transition-bounce);
}

.chip-btn:hover {
  background: var(--primary-50);
  border-color: var(--primary-400);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
  color: var(--primary-700);
}

.chip-btn:active {
  transform: scale(0.97);
}

.chip-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
}

.chip-text {
  line-height: 1.35;
}

/* --- Chat Flow & Message Bubbles --- */
.chat-flow {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.message-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  animation: messageSlideIn 0.35s ease;
  width: 100%;
}

@keyframes messageSlideIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Bot Message on the Left */
.message-row.bot-message {
  justify-content: flex-start;
}

.bot-avatar-mini {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, #DBEAFE, #93C5FD);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
  border: 2px solid #FFFFFF;
  box-shadow: var(--shadow-xs);
}

/* User Message on the Right */
.message-row.user-message {
  justify-content: flex-end;
}

.user-avatar-mini {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, #BFDBFE, #60A5FA);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  flex-shrink: 0;
  border: 2px solid #FFFFFF;
  box-shadow: var(--shadow-xs);
  order: 2;
}

.message-body-wrap {
  display: flex;
  flex-direction: column;
  max-width: 82%;
}

@media (max-width: 600px) {
  .message-body-wrap {
    max-width: 90%;
  }
}

.user-message .message-body-wrap {
  align-items: flex-end;
  order: 1;
}

.bot-message .message-body-wrap {
  align-items: flex-start;
}

/* User Bubble Styling */
.user-bubble {
  background: linear-gradient(135deg, #3B82F6 0%, #2563EB 100%);
  color: #FFFFFF;
  padding: 12px 18px;
  border-radius: 20px 20px 4px 20px;
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.5;
  box-shadow: var(--shadow-sm);
  word-break: break-word;
  white-space: pre-wrap;
}

/* Bot Bubble Styling */
.bot-bubble {
  background: #FFFFFF;
  color: var(--text-main);
  padding: 16px 20px;
  border-radius: 20px 20px 20px 4px;
  font-size: 0.95rem;
  line-height: 1.65;
  box-shadow: var(--shadow-bubble);
  border: 1.5px solid var(--border-light);
  word-break: break-word;
}

/* Message Meta (Timestamp & Copy Button) */
.message-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 5px;
  font-size: 0.72rem;
  color: var(--text-light);
  font-weight: 600;
}

.btn-bubble-action {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: transparent;
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-bubble-action:hover {
  color: var(--primary-700);
  background: var(--primary-100);
}

/* --- Markdown Elements Inside Bot Bubble --- */
.bot-bubble p {
  margin-bottom: 10px;
}
.bot-bubble p:last-child {
  margin-bottom: 0;
}

.bot-bubble h1, 
.bot-bubble h2, 
.bot-bubble h3, 
.bot-bubble h4 {
  font-family: var(--font-family-heading);
  color: var(--primary-900);
  margin-top: 14px;
  margin-bottom: 8px;
  line-height: 1.3;
}
.bot-bubble h1 { font-size: 1.25rem; }
.bot-bubble h2 { font-size: 1.15rem; }
.bot-bubble h3 { font-size: 1.05rem; }
.bot-bubble h4 { font-size: 0.95rem; }

.bot-bubble ul, 
.bot-bubble ol {
  margin: 8px 0 12px 22px;
  padding: 0;
}

.bot-bubble li {
  margin-bottom: 6px;
  line-height: 1.55;
}

.bot-bubble strong {
  font-weight: 700;
  color: var(--primary-900);
}

.bot-bubble em {
  font-style: italic;
  color: var(--text-secondary);
}

.bot-bubble blockquote {
  background: var(--primary-50);
  border-left: 4px solid var(--primary-400);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 10px 14px;
  margin: 10px 0;
  color: var(--primary-900);
  font-size: 0.92rem;
  font-style: normal;
}

.bot-bubble table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 0.88rem;
  background: #FFFFFF;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-light);
}

.bot-bubble th, 
.bot-bubble td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-light);
}

.bot-bubble th {
  background: var(--primary-100);
  color: var(--primary-900);
  font-weight: 700;
}

.bot-bubble tr:last-child td {
  border-bottom: none;
}

.bot-bubble tr:nth-child(even) td {
  background: #FAFCFF;
}

/* Inline Code & Code Block */
.bot-bubble code:not(pre code) {
  background: #EFF6FF;
  color: #1D4ED8;
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  font-size: 0.88em;
  font-family: 'Consolas', 'Monaco', monospace;
  border: 1px solid var(--primary-200);
}

.bot-bubble .code-block-container {
  margin: 12px 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #1E293B;
  box-shadow: var(--shadow-sm);
}

.bot-bubble .code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px;
  background: #0F172A;
  color: #94A3B8;
  font-size: 0.75rem;
  font-family: 'Consolas', monospace;
}

.bot-bubble .btn-copy-code {
  color: #E2E8F0;
  background: rgba(255, 255, 255, 0.1);
  padding: 3px 8px;
  border-radius: var(--radius-xs);
  font-size: 0.72rem;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all var(--transition-fast);
}

.bot-bubble .btn-copy-code:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #FFFFFF;
}

.bot-bubble pre {
  margin: 0;
  padding: 12px 16px;
  overflow-x: auto;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 0.85rem;
  line-height: 1.5;
  color: #F8FAFC;
}

.bot-bubble pre code {
  background: transparent;
  padding: 0;
  border: none;
  color: inherit;
  font-size: inherit;
}

/* Error Bubble */
.bot-bubble.error-bubble {
  background: #FEF2F2;
  border-color: #FECACA;
  color: #991B1B;
}

.bot-bubble.error-bubble strong {
  color: #B91C1C;
}

/* --- Typing Indicator --- */
.typing-indicator-container {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  animation: fadeIn 0.3s ease;
}

.typing-bubble {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #FFFFFF;
  border: 1.5px solid var(--primary-200);
  padding: 12px 18px;
  border-radius: 20px 20px 20px 4px;
  box-shadow: var(--shadow-xs);
}

.typing-text {
  font-size: 0.84rem;
  color: var(--text-muted);
  font-weight: 600;
}

.typing-dots {
  display: flex;
  gap: 4px;
  align-items: center;
}

.typing-dots .dot {
  width: 7px;
  height: 7px;
  background: var(--primary-500);
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dots .dot:nth-child(1) { animation-delay: 0s; }
.typing-dots .dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dots .dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 80%, 100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  40% {
    transform: translateY(-6px);
    opacity: 1;
    background: var(--primary-600);
  }
}

/* --- Bottom Input Dock --- */
.chat-input-area {
  padding: 10px 18px 14px 18px;
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1.5px solid var(--border-light);
  z-index: 20;
}

.input-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Quick Subjects Pills Bar */
.quick-subjects-bar {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}
.quick-subjects-bar::-webkit-scrollbar {
  display: none;
}

.subject-pill {
  white-space: nowrap;
  background: #FFFFFF;
  border: 1px solid var(--primary-200);
  color: var(--primary-800);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-xs);
  transition: all var(--transition-bounce);
  flex-shrink: 0;
}

.subject-pill:hover {
  background: var(--primary-100);
  border-color: var(--primary-400);
  transform: translateY(-1px);
}

.subject-pill:active {
  transform: scale(0.95);
}

/* Form & Textarea */
.chat-form {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: #FFFFFF;
  border: 2px solid var(--primary-200);
  border-radius: var(--radius-lg);
  padding: 6px 8px 6px 16px;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition-normal), box-shadow var(--transition-normal);
}

.chat-form:focus-within {
  border-color: var(--primary-500);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
}

.input-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  position: relative;
}

.chat-input {
  width: 100%;
  border: none;
  outline: none;
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.45;
  color: var(--text-main);
  background: transparent;
  resize: none;
  max-height: 120px;
  min-height: 24px;
  padding: 6px 26px 6px 0;
}

.chat-input::placeholder {
  color: var(--text-light);
  font-size: 0.9rem;
}

.btn-clear-input {
  position: absolute;
  right: 2px;
  color: var(--text-light);
  font-size: 0.95rem;
  padding: 4px;
  transition: color var(--transition-fast);
}

.btn-clear-input:hover {
  color: var(--text-secondary);
}

/* Send Button */
.btn-send {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
  color: #FFFFFF;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 0.92rem;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
  transition: all var(--transition-bounce);
  flex-shrink: 0;
}

.btn-send:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--primary-600), var(--primary-700));
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.4);
}

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

.btn-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.send-icon {
  font-size: 0.95rem;
}

@media (max-width: 500px) {
  .btn-send {
    padding: 10px;
    border-radius: var(--radius-md);
    width: 42px;
    height: 42px;
  }
  .send-text {
    display: none;
  }
  .chat-input-area {
    padding: 8px 12px 10px 12px;
  }
}

/* Input Footer Hint */
.input-footer-hint {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.72rem;
  color: var(--text-muted);
  padding: 0 4px;
}

.hint-text strong {
  color: var(--primary-800);
}

.model-tag {
  background: var(--primary-100);
  color: var(--primary-800);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-weight: 700;
  font-size: 0.68rem;
}

@media (max-width: 600px) {
  .hint-text {
    display: none;
  }
}

/* --- Modals --- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
  animation: fadeIn 0.2s ease;
}

.modal-backdrop.hidden {
  display: none;
}

.modal-card {
  background: #FFFFFF;
  border-radius: var(--radius-lg);
  max-width: 520px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-light);
  overflow: hidden;
  animation: modalPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  flex-direction: column;
}

@keyframes modalPop {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  background: var(--primary-50);
  border-bottom: 1.5px solid var(--border-light);
}

.modal-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-icon {
  font-size: 1.25rem;
  color: var(--primary-600);
}

.modal-title-wrap h3 {
  font-family: var(--font-family-heading);
  font-size: 1.15rem;
  color: var(--primary-900);
  font-weight: 700;
}

.btn-close-modal {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 1.1rem;
  transition: all var(--transition-fast);
}

.btn-close-modal:hover {
  background: var(--primary-200);
  color: var(--primary-900);
}

.modal-body {
  padding: 22px;
  max-height: 70vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-main);
}

.input-password-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.form-control {
  width: 100%;
  padding: 10px 42px 10px 14px;
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.92rem;
  outline: none;
  transition: border-color var(--transition-normal);
}

.form-control:focus {
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.btn-toggle-pwd {
  position: absolute;
  right: 12px;
  color: var(--text-muted);
  font-size: 1rem;
  padding: 4px;
}
.btn-toggle-pwd:hover {
  color: var(--primary-600);
}

.input-help {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.api-guide-box {
  background: var(--primary-50);
  border: 1px solid var(--primary-200);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 0.86rem;
}

.api-guide-box h4 {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--primary-800);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.api-guide-box ol {
  margin-left: 18px;
  color: var(--text-secondary);
  line-height: 1.55;
}

.api-guide-box li {
  margin-bottom: 4px;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 22px;
  background: #F8FAFC;
  border-top: 1px solid var(--border-subtle);
}

.btn-primary {
  background: var(--primary-600);
  color: #FFFFFF;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.9rem;
  box-shadow: var(--shadow-xs);
  transition: all var(--transition-fast);
}

.btn-primary:hover {
  background: var(--primary-700);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--primary-100);
  color: var(--primary-800);
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.9rem;
  transition: all var(--transition-fast);
}

.btn-secondary:hover {
  background: var(--primary-200);
}

/* Help Modal Specifics */
.help-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.help-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: #F8FAFC;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

.help-icon-bubble {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.help-item h4 {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--primary-900);
  margin-bottom: 3px;
}

.help-item p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

/* --- Toast Notifications --- */
.toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
}

.toast {
  background: #1E293B;
  color: #FFFFFF;
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toastIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), toastOut 0.3s ease 2.7s forwards;
  pointer-events: auto;
}

.toast.toast-success {
  background: #065F46;
  border: 1px solid #10B981;
}

.toast.toast-info {
  background: #1E3A8A;
  border: 1px solid #3B82F6;
}

.toast.toast-error {
  background: #991B1B;
  border: 1px solid #EF4444;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-16px) scale(0.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(-16px) scale(0.9); }
}

/* --- Utility Classes & Animations --- */
.hidden {
  display: none !important;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}
