@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Noto+Sans+Thai:wght@300;400;500;600;700&family=Fira+Code:wght@400;500&display=swap');

:root {
  --font-thai: 'Noto Sans Thai', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'Fira Code', monospace;
  --primary: #985017;
  
  /* Font Size Variables (Default Large for Seniors) */
  --chat-font-size: 1.15rem;
  --chat-line-height: 1.75;
  --input-font-size: 1.05rem;
  --prompt-font-size: 1rem;
}

/* Font Size Presets */
body[data-font-size="normal"] {
  --chat-font-size: 1rem;
  --chat-line-height: 1.65;
  --input-font-size: 0.95rem;
  --prompt-font-size: 0.9rem;
}

body[data-font-size="large"] {
  --chat-font-size: 1.15rem;
  --chat-line-height: 1.75;
  --input-font-size: 1.05rem;
  --prompt-font-size: 1rem;
}

body[data-font-size="xlarge"] {
  --chat-font-size: 1.32rem;
  --chat-line-height: 1.85;
  --input-font-size: 1.18rem;
  --prompt-font-size: 1.12rem;
}

body {
  font-family: var(--font-thai);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

/* User Message & Input Text Scaling */
.user-bubble-text {
  font-size: var(--chat-font-size);
  line-height: var(--chat-line-height);
}

.chat-input-text {
  font-size: var(--input-font-size);
}

.prompt-text {
  font-size: var(--prompt-font-size);
}

/* Minimal Scrollbars */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(168, 162, 158, 0.35);
  border-radius: 9999px;
}

.scrollbar-none::-webkit-scrollbar {
  display: none;
}
.scrollbar-none {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* Floating Date Pop-in Transition */
#floatingDatePill {
  transition: opacity 0.24s ease-out, transform 0.24s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#floatingDatePill.date-pill-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

#floatingDatePill.date-pill-hidden {
  opacity: 0;
  transform: translateY(-8px) scale(0.9);
  pointer-events: none;
}

/* In-Chat Date Divider */
.chat-date-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 1.25rem 0 0.75rem 0;
  position: relative;
}

.chat-date-divider span {
  background: #faf8f5;
  color: #78716c;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.25rem 0.9rem;
  border-radius: 9999px;
  border: 1px solid #e7e5e4;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

/* Chat bubble entrance animation */
@keyframes bubblePopIn {
  0% {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.chat-bubble-anim {
  animation: bubblePopIn 0.22s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Collapsible Actions Group (Smoothly collapses when typing) */
.actions-group-visible {
  opacity: 1;
  max-width: 96px;
  transform: scale(1) translateX(0);
  pointer-events: auto;
  margin-right: 0;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.actions-group-hidden {
  opacity: 0;
  max-width: 0;
  transform: scale(0.85) translateX(-10px);
  pointer-events: none;
  margin-right: -0.5rem;
  overflow: hidden;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Markdown styling inside AI bubble (Scales with font size) */
.markdown-body {
  color: #292524;
  font-size: var(--chat-font-size);
  line-height: var(--chat-line-height);
  word-break: break-word;
}

.markdown-body p {
  margin-bottom: 0.75rem;
}

.markdown-body p:last-child {
  margin-bottom: 0;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
  font-weight: 700;
  margin-top: 0.95rem;
  margin-bottom: 0.45rem;
  line-height: 1.35;
  color: #1c1917;
}

.markdown-body h1 { font-size: 1.4em; }
.markdown-body h2 { font-size: 1.25em; }
.markdown-body h3 { font-size: 1.15em; }

.markdown-body ul,
.markdown-body ol {
  margin-top: 0.35rem;
  margin-bottom: 0.75rem;
  padding-left: 1.35rem;
}

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

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

.markdown-body blockquote {
  border-left: 3.5px solid #985017;
  padding-left: 0.85rem;
  margin: 0.75rem 0;
  color: #78716c;
  background: #fbf8f5;
  border-radius: 0 0.4rem 0.4rem 0;
  font-style: italic;
}

.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.75rem 0;
  font-size: 0.9em;
  display: block;
  overflow-x: auto;
}

.markdown-body th,
.markdown-body td {
  border: 1px solid #e7e5e4;
  padding: 0.45rem 0.7rem;
  text-align: left;
}

.markdown-body th {
  background: #f5f5f4;
  font-weight: 600;
}

/* Inline Code */
.markdown-body :not(pre) > code {
  font-family: var(--font-mono);
  background: #faefe6;
  color: #985017;
  padding: 0.12rem 0.4rem;
  border-radius: 0.35rem;
  font-size: 0.85em;
  border: 1px solid #f4decb;
}

/* Code block wrapper for mobile (Light Theme) */
.code-block-wrapper {
  margin: 0.75rem 0;
  border-radius: 0.75rem;
  overflow: hidden;
  background: #fdfbf7;
  border: 1px solid #eedfd5;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0.85rem;
  background: #f5ede6;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: #78716c;
  border-bottom: 1px solid #eedfd5;
}

.code-block-wrapper pre {
  margin: 0;
  padding: 0.85rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  background: transparent;
}

/* Streaming Blinking Cursor */
.streaming-cursor {
  display: inline-block;
  width: 7px;
  height: 16px;
  background: #985017;
  margin-left: 2px;
  vertical-align: middle;
  animation: cursorBlink 0.9s infinite;
}

@keyframes cursorBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* Typing Dots Animation */
.typing-dot {
  width: 6px;
  height: 6px;
  background-color: #985017;
  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.25; }
  40% { transform: scale(1); opacity: 1; }
}
