/* ========= Tokens ========= */
:root {
  --border: #DDDDDD;
  --bg: #F0F3F4;
  --bg-blue: #EBF7FF;
  --text: #0F172A;
  --muted: #707070;
  --line: #EDEFF3;
  --link: #2F6DE0;
  --color-blue: #3863FF;
  --color-purple: #D92EFF;
  --color-pink: #FF3485;
  --color-rose: #FF6477;
  --color-yellow: #FFD014;
}

/* ========= Page ========= */
* {
  box-sizing: border-box;
  font-family: 'Inter', Arial, Helvetica, sans-serif;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  padding: 0;
  /* background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); */
  font-family: Inter, system-ui, Segoe UI, Roboto, Arial, sans-serif;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  color: var(--text);
}

/* ========= Card ========= */
.chat {
  width: 100%;
  max-width: 380px;
  height: 90vh;
  max-height: 680px;
  background: transparent;
  background-image: url("/images/bg.png");
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 8px 24px rgba(16, 24, 40, .08);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}

.chat::before {
  content: '';
  position: absolute;
  inset: 0;
  padding: 3px;
  border-radius: 18px;
  background: linear-gradient(90deg, var(--color-yellow), var(--color-rose), var(--color-pink), var(--color-purple), var(--color-blue));
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

@media (max-width: 768px) {
  .chat {
    max-width: 100%;
    height: 100vh;
  }
}

/* ========= Tabs (segmented) ========= */
.header {
  padding: 8px;
  display: flex;
  flex-direction: column;
  align-self: flex-start;
  max-width: 50rem !important;
  width: 100%;
  overflow-x: auto;
  background-color: oklch(70.4% 0.04 256.788);
  border: 0.47px solid transparent;
  border-bottom: 1px solid var(--border);
  border-radius: 6px;
  box-sizing: border-box;
}

.header-tagline {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: 0.02em;
  text-align: center;
  background: linear-gradient(
    90deg,
    #057602 0%,
    #0755e6 22%,
    #e10849 40%,
    #0755e6 58%,
    #e10849 78%,
    #f4bc05 100%
  );
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  background-size: 200% 100%;
  text-shadow: none;
  animation: header-tagline-gradient 12s ease-in-out infinite;
}
.copy-paste-hint {
  font-size: 14px;
  font-weight: 500;
  color: #666666;
  text-align: center;
  margin-top: 8px;
}

@keyframes header-tagline-gradient {
  0%, 100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}

.header-row {
  display: flex;
  width: 100%;
}

.header-left {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
}

.header-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  row-gap: 8px;
  overflow-x: auto;
}

.logo-circle {
  width: 82px;
  height: 82px;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  margin-bottom: 8px;
  position: relative;
}

/* Vệt sáng chạy qua ảnh tròn (giống hiệu ứng #text-line), giữ màu ảnh gốc */
.logo-circle::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  pointer-events: none;
  background: linear-gradient(
    105deg,
    transparent 0%,
    transparent 35%,
    rgba(255, 255, 255, 0.4) 45%,
    rgba(255, 255, 255, 0.7) 50%,
    rgba(255, 255, 255, 0.4) 55%,
    transparent 65%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: logo-circle-shine 2.5s ease-in-out 0.5s infinite;
}

@keyframes logo-circle-shine {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.logo-circle .logo-icon {
  object-fit: contain;
  position: relative;
  z-index: 0;
}

.brand-container {
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.brand-logo {
  object-fit: contain;
}

.logo-text {
  margin: 0px 0;
  font-family: 'Arial Black', Gadget, sans-serif;
  font-size: 1.6rem;
  font-weight: 900;
  background: linear-gradient(to right,
      #f26522,
      #f7941d,
      #fff200,
      #8dc63f,
      #00aeef,
      #2e3192);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.navs {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.header>nav.navs {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.connection-status {
  font-size: 12px;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 12px;
  transition: all 0.2s;
  color: var(--line);
  background: transparent;
}

.connect-status {
  display: flex;
  align-items: center;
}

.header>.navs:first-child {
  flex: 0 0 auto;
}

.connection-status.mini {
  font-size: 11px;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: 10px;
  color: var(--line);
  background: transparent;
}

.tabs {
  display: flex;
  flex-direction: row-reverse;
  /* justify-content: flex-start; */
  gap: 5px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding-bottom: 2px;
  flex: 1;
}

.header nav .tabs {
  justify-content: center;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tabs {
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  /* Smooth scrolling on iOS */
}

.connection-status {
  font-size: 11px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 12px;
  transition: all 0.2s;
  flex-shrink: 0;
  color: var(--line);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  /* Prevent shrinking */
  white-space: nowrap;
  /* Prevent text wrapping */
}

.connection-status::before {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
  color: #057602;
}

.connection-status.is-online {
  color: #ffffff;
  background: rgba(22, 163, 74, 0.1);
}

.connection-status.is-online::before {
  animation: pulse 2s ease-in-out infinite;
}

.connection-status.is-offline {
  color: #dc2626;
  background: rgba(220, 38, 38, 0.1);
}

.tab {
  background: #fff;
  border: 1px solid var(--color-blue);
  margin-top: 2px;
  border-radius: 12px;
  padding: 0px 14px;
  min-height: 32px;
  box-shadow: 0 1px 0 rgba(16, 24, 40, .02);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
  /* Prevent tabs from shrinking */
  white-space: nowrap;
  /* Prevent text wrapping */
}

.tab:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(16, 24, 40, 0.08);
}

/* .tabs .tab:first-child {
  border-top-left-radius: 18px;
} */

.tab svg {
  width: 16px;
  height: 16px
}

.tab .tab-count {
  font-weight: 600;
  font-size: 13px;
  color: #475569;
}

.tab.active {
  background: var(--bg-blue);
}

/* chữ gradient đa sắc bên trong pill */
.gtext {
  font-weight: 500;
  font-size: medium;
  font-style: normal;
  letter-spacing: 0;
  line-height: 39.21px;
  background-image: linear-gradient(90deg, var(--color-blue), var(--color-purple), var(--color-pink), var(--color-rose), var(--color-yellow));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  /* fallback cho trình duyệt không hỗ trợ */
  color: transparent;
  background-clip: text;
  display: inline-flex;
  align-items: center;
}

.gtext::after {
  content: none;
}

/* ========= Messages ========= */
.list {
  flex: 1;
  overflow: auto;
}

.list::-webkit-scrollbar {
  width: 6px
}

.list::-webkit-scrollbar-thumb {
  background: #E5E7EC;
  border-radius: 8px
}

@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.item {
  display: flex;
  gap: 10px;
  margin-bottom: 3px;
  padding: 10px 12px 8px;
  transform: translateZ(0);
  animation: messageSlideIn 0.3s ease-out;
}

.item:hover {
  background-color: rgba(0, 0, 0, 0.01);
}

.item.is-me {
  margin-left: 3px;
  margin-right: 3px;
  background-color: var(--bg-blue);
}

.ava {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex: 0 0 36px;
  overflow: hidden;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
}

.ava.img {
  background: #FFEFF6
}

.ava.sun {
  background: conic-gradient(from 35deg, #ffe3fd, #b5f0ff, #ffe3fd)
}

.ava.orange {
  background: linear-gradient(135deg, #ff7a59, #ffb86c)
}

.ava.purple {
  background: linear-gradient(135deg, #7c3aed, #f472b6)
}

.avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}

.msg {
  flex: 1;
  min-width: 0;
  position: relative;
}

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

.name {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  color: #1A1A1A
}

.name.admin {
  background: linear-gradient(90deg, var(--color-blue), var(--color-purple), var(--color-pink), var(--color-rose), var(--color-yellow));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.name small {
  font-weight: 600;
  font-size: 11px;
  margin-left: 4px;
  -webkit-text-fill-color: var(--text);
  animation: textColorPulse 3s infinite;
}

@keyframes textColorPulse {

  0%,
  100% {
    -webkit-text-fill-color: var(--color-purple);
  }

  50% {
    -webkit-text-fill-color: var(--color-blue);
  }
}

.time {
  margin-left: auto;
  font-size: 10px;
  font-weight: 500;
  line-height: 18.67px;
  color: var(--muted);
}

.ext {
  width: 20px;
  height: 20px;
  border-radius: 5px;
  margin-left: 4px;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  color: #778099;
  background: #fff;
}

.ext svg {
  width: 12px;
  height: 12px
}

.text {
  margin: 6px 0 0;
  font-size: 13.5px;
  line-height: 1.45;
  color: #374151;
  white-space: normal;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

a.link {
  color: var(--link);
  text-decoration: none
}

a.link:hover {
  text-decoration: underline
}

.box-img {
  display: flex;
  flex-wrap: wrap;
  /* allow rows */
  flex-direction: row;
  align-items: flex-start;
  gap: 2px;
  /* space between images */
  margin-top: 6px;
}

/* each image takes up to 50% width so there are max 2 per row */
.box-img>.img-wrap {
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #edeef2;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  box-sizing: border-box;
  flex: 0 0 calc(50% - 4px);
  max-width: calc(50% - 4px);
}

/* if there's only one image, make it full width and center it */
.box-img>.img-wrap:only-child {
  flex: 0 0 100%;
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
}

.img-wrap img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  aspect-ratio: 16/9;
  /* keep consistent heights */
}

.item.ai-bot .ava {
  color: #fff;
}

.ai-bot .msg .text {
  color: #000000;
}
#online-count {
  color: #8200ff;
}
.ai-results {
  margin-top: 10px;
  display: grid;
  gap: 10px;
}

.ai-result-card {
  display: flex;
  gap: 10px;
  align-items: stretch;
  background: #f8f9ff;
  border: 1px solid #e5e7ff;
  border-radius: 12px;
  padding: 10px;
}

.ai-result-thumb {
  width: 72px;
  height: 72px;
  border-radius: 10px;
  object-fit: cover;
  cursor: pointer;
  box-shadow: 0 6px 12px rgba(63, 81, 181, 0.18);
}

.ai-result-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
}

.ai-result-title {
  font-weight: 600;
  font-size: 13px;
  color: #1f2937;
  line-height: 1.3;
}

.ai-result-score {
  font-size: 12px;
  color: #4b5563;
}

.ai-result-link {
  font-size: 12px;
  font-weight: 500;
  color: var(--color-blue);
  text-decoration: none;
  width: fit-content;
}

.ai-result-link:hover {
  text-decoration: underline;
}

/* ========= Input ========= */
/* vùng footer */
.footer {
  padding: 10px;
  background: #fff
}

/* viền gradient theo ảnh */
.input-wrap {
  border-radius: 16px;
  padding: 1px;
  background: linear-gradient(90deg, var(--color-blue) 0%, var(--color-purple) 25%, var(--color-pink) 50%, var(--color-rose) 75%, var(--color-yellow) 100%);
}

/* khung trắng bên trong */
.input {
  background: #fff;
  border-radius: 15px;
  border: 1px solid #EEF0F4;
}

.input--stack {
  display: flex;
  flex-direction: column;
  padding: 8px 10px 8px 10px;
}

/* textarea ở trên */
.msgarea {
  width: 100%;
  min-height: 40px;
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  font: 500 13.5px/1.45 "Inter", system-ui, Arial, sans-serif;
  color: #000000;
  padding: 4px 2px 0 2px;
}

@keyframes placeholderInOut {
  0%, 100% {
    opacity: 0.5;
    transform: translateX(-8px);
  }
  50% {
    opacity: 1;
    transform: translateX(8px);
  }
}

.msgarea::placeholder {
  color: #000000;
}

.msgarea::-webkit-scrollbar {
  display: none
}

/* hàng action dưới */
.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 8px;
  margin-top: 6px;
  /* border-top: 1px solid #F1F3F6; */
}

/* icon nút trái */
.left-actions {
  display: flex;
  gap: 8px
}

.btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: #F7F8FB;
  border: 1px solid #ECEFF3;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn:hover {
  background: #E8EBEF;
  transform: translateY(-1px);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.btn:focus-visible {
  outline: 2px solid var(--color-blue);
  outline-offset: 2px;
}

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

.btn svg {
  width: 16px;
  height: 16px;
  color: #6B7280
}

/* nút gửi viền gradient riêng bên phải */
.send {
  width: 30px;
  height: 30px;
  box-sizing: border-box;
  padding: 0.1px;
  border-radius: 50%;
  cursor: pointer;
  border: 1px solid transparent;
  background-image: linear-gradient(#fff, #fff), linear-gradient(85deg, var(--color-blue), var(--color-purple), var(--color-pink), var(--color-rose), var(--color-yellow));
  background-origin: border-box;
  background-clip: content-box, border-box;
  display: grid;
  place-items: center;
  transition: all 0.15s ease;
}

.send:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 6px 18px rgba(16, 24, 40, 0.15);
}

.send:active {
  transform: translateY(0) scale(0.98);
}

.send:focus-visible {
  outline: 3px solid rgba(99, 102, 241, 0.2);
  outline-offset: 2px;
}

.send svg {
  width: 16px;
  height: 16px;
  stroke: var(--color-pink);
}


/* little corner up-arrow circle like screenshot */
.corner {
  position: absolute;
  right: 12px;
  bottom: 10px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #FFDDF0;
  border: 1px solid #FFD0E6;
  display: none;
}

/* ========= System Messages ========= */
.item.system .msg {
  background: var(--bg-blue);
  border: 1px dashed var(--color-blue);
}

.item.system .name {
  color: var(--color-blue);
}

/* ========= Typing Indicator ========= */
.typing-indicator {
  max-height: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 500;
  color: #475569;
  opacity: 0;
  transition: opacity 0.2s, max-height 0.2s;
}

.typing-indicator.is-active {
  opacity: 1;
  max-height: 40px;
  padding: 0 18px 0 18px;
}

.typing-indicator .label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.typing-indicator .dots {
  display: inline-flex;
  gap: 4px;
}

.typing-indicator .dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-blue);
  opacity: 0.3;
  animation: typing-bounce 1s infinite;
}

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

.typing-indicator .dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing-bounce {

  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.3;
  }

  40% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

.scroll-bottom {
  position: absolute;
  right: 16px;
  bottom: 96px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--color-blue);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 16px rgba(15, 23, 42, 0.18);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px) scale(0.9);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.scroll-bottom svg {
  width: 18px;
  height: 18px;
}

.scroll-bottom.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.scroll-bottom:hover {
  transform: scale(1.1);
  box-shadow: 0 12px 24px rgba(56, 99, 255, 0.3);
}

.scroll-bottom:active {
  transform: scale(0.95);
}

.scroll-bottom:focus-visible {
  outline: 3px solid rgba(56, 99, 255, 0.4);
  outline-offset: 2px;
}

.suggestions-container {
  position: absolute;
  top: auto;
  right: auto;
  bottom: 120px;
  left: 1rem;
  transform: translateX(-50%);
  width: 90%;
  max-width: 340px;
  max-height: 186px;
  background: #fff;
  border: 1px solid #E0E3E8;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(16, 24, 40, 0.12);
  z-index: 10;
  pointer-events: none;
  opacity: 0;
  transform: translateY(12px) scale(0.95);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.suggestions-container.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.loading-indicator {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.9);
  padding: 12px 16px;
  /* border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1); */
  font-size: 14px;
  color: #374151;
}

.loading-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #E5E7EB;
  border-top: 2px solid #3B82F6;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

/* Paste notification animation */
@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOut {
  from {
    transform: translateX(0);
    opacity: 1;
  }

  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

.paste-notification {
  position: fixed;
  top: 20px;
  right: 20px;
  background: #4caf50;
  color: white;
  padding: 12px 20px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 10000;
  font-size: 14px;
  font-weight: 500;
  animation: slideIn 0.3s ease-out;
}

.suggestions-list {
  max-height: 185px;
  border-radius: 12px;
  overflow-x: hidden;
  overflow-y: auto;
}

.suggestions-list::-webkit-scrollbar {
  width: 6px;
}

.suggestions-list::-webkit-scrollbar-thumb {
  background: #E5E7EC;
  border-radius: 8px;
}

.suggestion-item {
  padding: 10px 14px;
  border-bottom: 1px solid var(--muted);
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background-color 0.15s;
}

.suggestion-item:last-child {
  border-bottom: none;
}

.suggestion-item:hover {
  background: #F7F8FB;
}

.suggestion-item:active {
  background: #E8EBEF;
}

.suggestion-thumb {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  object-fit: cover;
  margin-right: 8px;
}

.suggestion-text {
  flex: 1;
  margin-right: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
  font-weight: 400;
  font-size: 14px;
}

.suggestion-highlight {
  font-weight: 700;
  padding: 2px 4px;
  border-radius: 6px;
  background-image: linear-gradient(#fff, #fff), linear-gradient(85deg, var(--color-blue), var(--color-purple), var(--color-pink), var(--color-rose), var(--color-yellow));
  background-origin: border-box;
  background-clip: text, border-box;
  color: transparent;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.suggestion-badge {
  background: var(--bg-blue);
  color: var(--color-blue);
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 8px;
  white-space: nowrap;
}

.suggestion-badge.badge-prefix {
  color: var(--color-purple);
}

.suggestion-badge.badge-fuzzy {
  color: var(--color-pink);
}

@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media print {

  .footer,
  .scroll-bottom,
  .suggestions-container {
    display: none;
  }
}

/* ========= Upload Modal ========= */
dialog.upload-modal {
  background: #fff;
  padding: 10px 20px;
  border: none;
  border-radius: 12px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
  width: 90%;
  max-width: 360px;
  transform: scale(0.95);
  transition: transform 0.3s ease;
}

dialog.upload-modal[open] {
  transform: scale(1);
}

dialog.upload-modal::backdrop {
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.3s ease;
}

dialog.upload-modal[open]::backdrop {
  opacity: 1;
}

.upload-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
  margin-bottom: 15px;
}

.upload-modal-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.upload-modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--muted);
}

.upload-modal-body .form-group {
  margin-bottom: 15px;
}

.upload-modal-body label {
  display: block;
  margin-bottom: 5px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.upload-modal-body input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
}

.upload-modal-body input.is-loading {
  /* A self-animating SVG spinner that doesn't affect the input element itself */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='%233863FF' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='M12 3a9 9 0 1 0 9 9'%3E%3CanimateTransform attributeName='transform' type='rotate' from='0 12 12' to='360 12 12' dur='1s' repeatCount='indefinite' /%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.upload-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 15px;
  border-top: 1px solid var(--border);
  margin-top: 15px;
}

.upload-modal-footer .btn-secondary {
  background: var(--bg);
  border-color: var(--border);
  color: var(--text);
}

.upload-modal-footer .btn {
  width: auto;
  height: auto;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.upload-modal-footer .btn-primary {
  background: var(--color-blue);
  border-color: var(--color-blue);
  color: #fff;
}

.upload-modal-footer .btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.upload-modal-footer .btn-primary:hover {
  background: var(--link);
  border-color: var(--link);
}

.upload-modal-footer .btn-secondary:hover {
  background: var(--border);
}

/* ========= Image Preview ========= */
#image-preview-container {
  display: none;
  /* Hidden by default */
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 2px 8px 2px;
  /* Align with textarea padding */
}

.upload-hint {
  display: block;
  margin: 0 2px 8px 2px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
  transition: all 0.2s ease;
}

.upload-hint--default {
  color: #94a3b8;
  font-style: italic;
}

.upload-hint--active {
  color: #6366f1;
  font-weight: 600;
}

.ai-chat .upload-hint--active {
  color: #6366f1;
  font-weight: 600;
}

.preview-item {
  position: relative;
  width: 56px;
  height: 56px;
}

.preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.preview-item .remove-btn {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 20px;
  height: 20px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  border: 1px solid white;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
  padding: 0;
  transition: background-color 0.15s;
}

.preview-item .remove-btn:hover {
  background: rgba(0, 0, 0, 0.9);
}

.item.is-deleted .box-img,
.item.is-deleted .ai-results {
  display: none;
}


.message-actions {
  position: absolute;
  top: 4px;
  right: 4px;
  display: none;
  gap: 4px;
  align-items: center;
  z-index: 5;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.has-admin-privileges .message-actions {
  display: flex;
}

.has-admin-privileges .item:hover .message-actions,
.has-admin-privileges .item:focus-within .message-actions,
.has-admin-privileges .message-actions:focus-within {
  opacity: 1;
  pointer-events: auto;
}

.message-action {
  appearance: none;
  border: none;
  background: rgba(255, 255, 255, 0.9);
  color: #ef4444;
  border-radius: 6px;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.message-action svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

.message-action:hover {
  background: rgba(239, 68, 68, 0.12);
  transform: translateY(-1px);
}

.message-action:disabled {
  opacity: 0.6;
  cursor: wait;
}

.message-action--delete {
  color: #ef4444;
}

.item.is-deleted .message-actions {
  display: none !important;
}

/* ========= Input Hints ========= */
.input-hint.error-hint {
  display: none;
  /* Hidden by default */
  color: #dc2626;
  /* Red color for error */
  font-size: 12px;
  margin-top: 4px;
}

.input-hint.error-hint.is-visible {
  display: block;
  /* Show when needed */
}

/* ========= Guest Profile Modal ========= */
.guest-profile-modal {
  border: none;
  border-radius: 12px;
  padding: 0;
  width: min(420px, 90vw);
  height: min(230px, 90vh);
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.25);
  overflow: auto;
}

.guest-profile-modal::-webkit-scrollbar {
  width: 3px;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.08);
}

.guest-profile-modal::backdrop {
  background: rgba(15, 23, 42, 0.65);
}

.guest-profile-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px;
}

.guest-profile-header h3 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
}

.guest-profile-subtitle {
  margin: 4px 0 0;
  color: #64748b;
  font-size: 0.95rem;
}

.guest-profile-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.guest-profile-label {
  font-weight: 600;
  font-size: 0.9rem;
}

.guest-profile-body input {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #cbd5f5;
  font-size: 1rem;
}

.guest-profile-body input:focus {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.guest-profile-hint {
  min-height: 16px;
  color: #dc2626;
  font-size: 0.85rem;
  display: none;
}

.guest-profile-hint.is-visible {
  display: block;
}

.guest-profile-footer {
  display: flex;
  justify-content: flex-end;
}

.guest-profile-footer .btn-primary {
  display: inline-block;
  min-width: 120px;
  background: #1d4ed8;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-weight: 400;
  font-size: 1rem;
  overflow: visible;
  text-overflow: unset;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: none;
  letter-spacing: normal;
  transition: background 0.2s;
}

.guest-profile-footer .btn-primary:hover {
  background: #2563eb;
}

.guest-profile-footer .btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.ai-pending-indicator {
  display: none;
  align-items: center;
  gap: 8px;
  margin: 8px 18px;
  color: #475569;
  font-size: 0.9rem;
}

.ai-pending-indicator.is-visible {
  display: inline-flex;
}

.ai-pending-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(99, 102, 241, 0.25);
  border-top-color: #4f46e5;
  border-radius: 50%;
  animation: aiPendingSpin 0.9s linear infinite;
}

@keyframes aiPendingSpin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}
