/* Custom styling and animations for Agri-AI Tuấn An Phát */
:root {
  --primary-50: #ecfdf5;
  --primary-100: #d1fae5;
  --primary-200: #a7f3d0;
  --primary-500: #10b981;
  --primary-600: #059669;
  --primary-700: #047857;
  --primary-800: #065f46;
  --surface: #ffffff;
  --background: #f8fafc;
  --border: #e2e8f0;
  --text-main: #0f172a;
  --text-muted: #64748b;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: #f8fafc;
  color: #0f172a;
  -webkit-tap-highlight-color: transparent;
}

/* Glassmorphism subtle effects */
.glass-header {
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

/* Chat message bubbles */
.user-bubble {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.bot-bubble {
  background: #ffffff;
  color: #0f172a;
  border: 1px solid #e2e8f0;
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 8px -2px rgba(0, 0, 0, 0.04);
}

/* Markdown styling inside bot bubble */
.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4 {
  font-weight: 700;
  color: #065f46;
  margin-top: 1rem;
  margin-bottom: 0.5rem;
}

.markdown-body h1 { font-size: 1.35rem; }
.markdown-body h2 { font-size: 1.2rem; }
.markdown-body h3 { font-size: 1.05rem; }
.markdown-body h4 { font-size: 0.95rem; }

.markdown-body p {
  margin-bottom: 0.65rem;
  line-height: 1.6;
}

.markdown-body ul, .markdown-body ol {
  margin-left: 1.25rem;
  margin-bottom: 0.75rem;
  line-height: 1.55;
}

.markdown-body ul { list-style-type: disc; }
.markdown-body ol { list-style-type: decimal; }

.markdown-body li {
  margin-bottom: 0.25rem;
}

.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.75rem 0;
  font-size: 0.88rem;
  background-color: #ffffff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.markdown-body th {
  background-color: #ecfdf5;
  color: #065f46;
  padding: 8px 12px;
  text-align: left;
  font-weight: 600;
  border: 1px solid #d1fae5;
}

.markdown-body td {
  padding: 8px 12px;
  border: 1px solid #e2e8f0;
  vertical-align: top;
}

.markdown-body tr:nth-child(even) td {
  background-color: #f8fafc;
}

.markdown-body code {
  background-color: #f1f5f9;
  color: #0f766e;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.markdown-body pre {
  background-color: #1e293b;
  color: #f8fafc;
  padding: 12px 16px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 0.75rem 0;
}

.markdown-body pre code {
  background: transparent;
  color: inherit;
  padding: 0;
}

.markdown-body blockquote {
  border-left: 4px solid #10b981;
  padding-left: 12px;
  margin: 0.75rem 0;
  color: #334155;
  background-color: #f0fdf4;
  padding-top: 6px;
  padding-bottom: 6px;
  border-radius: 0 8px 8px 0;
}

/* File Generated Card */
.file-download-card {
  background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
  border: 1.5px solid #a7f3d0;
  border-radius: 14px;
  padding: 12px 16px;
  margin-top: 12px;
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.08);
}

/* Floating Text Selection Tooltip */
#selection-tooltip {
  position: absolute;
  z-index: 60;
  display: none;
  background: #0f172a;
  color: #ffffff;
  padding: 4px 6px;
  border-radius: 10px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
  font-size: 11px;
  white-space: nowrap;
  animation: tooltipFadeIn 0.15s ease-out;
}

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

/* Custom scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Typing dot indicator */
.typing-dot {
  width: 7px;
  height: 7px;
  background-color: #10b981;
  border-radius: 50%;
  display: inline-block;
  animation: typingBounce 1.4s infinite ease-in-out both;
}
.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Horizontal pill scroll on mobile */
.scrollbar-none::-webkit-scrollbar {
  display: none;
}
.scrollbar-none {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* Mobile viewport fix */
.mobile-chat-height {
  height: calc(100dvh - 170px);
}
@media (min-width: 768px) {
  .mobile-chat-height {
    height: calc(100vh - 190px);
  }
}

/* Print Styling */
@media print {
  header, footer, #chat-form, .file-download-card, button, #selection-tooltip {
    display: none !important;
  }
  body, main {
    background: white !important;
    color: black !important;
  }
  .bot-bubble {
    border: none !important;
    box-shadow: none !important;
  }
}
