@font-face {
  font-family: "Shabnam";
  src: url("/public/fonts/Shabnam-FD.woff2") format("woff2");
  font-weight: normal;
  font-style: normal;
}

* {
  font-family: "Shabnam", sans-serif;
}

body {
  background-image: linear-gradient(180deg, #eef2ff 0%, #f8fafc 100%);
}

.msg-item {
  cursor: pointer;
  width: fit-content;
}

.reply-box {
  border-right: 3px solid rgba(255, 255, 255, 0.65);
}

.voice-player {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 220px;
  width: clamp(220px, 42vw, 460px);
  max-width: 100%;
  direction: ltr;
}

.voice-play-btn {
  width: 2rem;
  height: 2rem;
  border-radius: 9999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: inherit;
  flex-shrink: 0;
}

.voice-play-icon {
  width: 1rem;
  height: 1rem;
}

.voice-wave-track {
  position: relative;
  height: 1.6rem;
  flex: 1;
  min-width: 120px;
  cursor: pointer;
  border-radius: 9999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.12);
  direction: ltr;
}

.voice-wave-bars {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1px;
  padding: 0.28rem 0.25rem;
}

.voice-bar {
  display: block;
  flex: 1 1 0;
  min-width: 1px;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.42);
}

.msg-item.bg-slate-100 .voice-wave-track {
  background: rgba(99, 102, 241, 0.08);
}

.msg-item.bg-slate-100 .voice-play-btn {
  background: rgba(99, 102, 241, 0.1);
  border-color: rgba(99, 102, 241, 0.22);
}

.msg-item.bg-slate-100 .voice-bar {
  background: rgba(71, 85, 105, 0.35);
}

.voice-wave-progress {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  background: linear-gradient(90deg, rgba(34, 211, 238, 0.45), rgba(56, 189, 248, 0.58));
  pointer-events: none;
}

.voice-duration {
  font-size: 0.72rem;
  opacity: 0.92;
  min-width: 2.6rem;
  text-align: left;
}

.voice-player audio {
  display: none;
}

#messageInput::placeholder {
  direction: rtl;
  text-align: right;
}

.voice-speed-btn {
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1;
  padding: 0.15rem 0.3rem;
  border-radius: 0.3rem;
  border: 1px solid currentColor;
  opacity: 0.55;
  cursor: pointer;
  transition: opacity 0.15s;
  white-space: nowrap;
  background: transparent;
  flex-shrink: 0;
}

.voice-speed-btn:hover,
.voice-speed-btn.active {
  opacity: 1;
}

@media (max-width: 768px) {
  html {
    font-size: 14px;
  }

  body {
    font-size: 0.92rem;
  }

  #chatForm button,
  #chatForm textarea,
  #messages .msg-item,
  header h1,
  header p,
  #chatStatus {
    font-size: 0.85rem;
  }

  #messages time {
    font-size: 0.68rem;
  }

  .voice-player {
    min-width: 240px;
    width: min(100%, 360px);
    gap: 0.42rem;
  }

  .voice-wave-track {
    min-width: 150px;
  }
}

/* Mobile fallback for Android Chrome:
   avoid nested scroll containers in supporter queue panel. */
@media (max-width: 1023px) {
  #supporterInboxPanels {
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
  }

  #supporterPanelQueue,
  #supporterPanelHistory {
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
  }
}

/* Voice player overrides for owner chat detail (light bg) */
.owner-chat-voice .voice-play-btn {
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.4);
  color: #4338ca !important;
}

.owner-chat-voice .voice-wave-track {
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid rgba(99, 102, 241, 0.15);
}

.owner-chat-voice .voice-wave-bars .voice-bar {
  background: #6366f1 !important;
  opacity: 0.4;
}

.owner-chat-voice .voice-wave-progress {
  background: rgba(99, 102, 241, 0.35);
}

.owner-chat-voice .voice-duration {
  color: #475569;
}

/* Small previews for message templates (Tailwind max-h-* may be absent from built app.css). */
.msg-template-thumb {
  display: block;
  max-height: 5rem;
  max-width: 7rem;
  width: auto;
  height: auto;
  object-fit: contain;
}

/* Chat bubbles: tiny square image preview; full size in lightbox (chat.js). */
.chat-img-thumb {
  display: inline-flex;
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  margin-top: 0.35rem;
  padding: 0;
  align-items: stretch;
  justify-content: stretch;
  border: 2px solid #84cc16;
  border-radius: 6px;
  overflow: hidden;
  cursor: zoom-in;
  background: #f1f5f9;
  vertical-align: top;
}
.chat-img-thumb:hover {
  box-shadow: 0 0 0 2px rgb(163 230 53 / 0.45);
}
.chat-img-thumb:focus-visible {
  outline: 2px solid #a3e635;
  outline-offset: 2px;
}
.chat-img-thumb img {
  width: 32px;
  height: 32px;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

#chatImageLightbox {
  z-index: 100;
}

#chatImageLightboxImg {
  max-width: 100%;
  max-height: min(85dvh, calc(100dvh - 6rem));
  height: auto;
  width: auto;
  object-fit: contain;
}

/* Live top-3 leaderboard on supporter panel */
.supporter-live-rank {
  background: linear-gradient(135deg, rgba(238, 242, 255, 0.95) 0%, rgba(255, 255, 255, 0.98) 55%, rgba(255, 251, 235, 0.4) 100%);
}

.supporter-live-rank--flash {
  animation: supporterRankFlash 0.55s ease;
}

@keyframes supporterRankFlash {
  0% { box-shadow: inset 0 0 0 0 rgba(99, 102, 241, 0); }
  40% { box-shadow: inset 0 0 0 2px rgba(99, 102, 241, 0.25); }
  100% { box-shadow: inset 0 0 0 0 rgba(99, 102, 241, 0); }
}

.supporter-live-rank__dot {
  animation: supporterLivePulse 1.4s ease-in-out infinite;
}

.supporter-live-rank__badge--ping {
  animation: supporterBadgePing 0.5s ease;
}

@keyframes supporterLivePulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.85); }
}

@keyframes supporterBadgePing {
  0% { transform: scale(1); }
  50% { transform: scale(1.06); }
  100% { transform: scale(1); }
}

.supporter-live-rank__podium {
  min-height: 0;
  gap: 0.5rem;
}

.supporter-live-rank__slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  border-radius: 0.5rem;
  border: 1px solid transparent;
  padding: 0.2rem 0.15rem 0.25rem;
  min-height: 2.75rem;
  transition: box-shadow 0.25s ease, border-color 0.25s ease;
}

.supporter-live-rank__slot--first {
  min-height: 3rem;
  transform: none;
  z-index: 0;
}

.supporter-live-rank__slot--gold {
  background: linear-gradient(180deg, #fffbeb 0%, #fef3c7 100%);
  border-color: rgba(251, 191, 36, 0.45);
  box-shadow: 0 1px 4px rgba(245, 158, 11, 0.1);
}

.supporter-live-rank__slot--silver {
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  border-color: rgba(148, 163, 184, 0.4);
}

.supporter-live-rank__slot--bronze {
  background: linear-gradient(180deg, #fff7ed 0%, #ffedd5 100%);
  border-color: rgba(251, 146, 60, 0.35);
}

.supporter-live-rank__slot--me {
  box-shadow: 0 0 0 1.5px rgba(99, 102, 241, 0.5);
}

.supporter-live-rank__slot--empty {
  min-height: 2.5rem;
  opacity: 0.45;
  background: #f8fafc;
  border-color: #e2e8f0;
}

.supporter-live-rank__medal {
  font-size: 7px;
  font-weight: 800;
  line-height: 1;
  color: #64748b;
  margin-bottom: 1px;
}

.supporter-live-rank__slot--gold .supporter-live-rank__medal { color: #b45309; }
.supporter-live-rank__slot--silver .supporter-live-rank__medal { color: #475569; }
.supporter-live-rank__slot--bronze .supporter-live-rank__medal { color: #c2410c; }

.supporter-live-rank__avatar-wrap {
  margin-bottom: 2px;
}

.supporter-live-rank__avatar {
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 9999px;
  object-fit: cover;
  border: 1.5px solid #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.1);
  display: block;
}

.supporter-live-rank__avatar--ph {
  background: linear-gradient(135deg, #e2e8f0, #cbd5e1);
}

.supporter-live-rank__name {
  font-size: 7px;
  font-weight: 600;
  color: #1e293b;
  line-height: 1.15;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 1px;
}

.supporter-live-rank__score {
  font-size: 7px;
  font-weight: 600;
  color: #4338ca;
  margin-top: 0;
  line-height: 1.15;
}

.supporter-live-rank__empty {
  font-size: 9px;
  color: #94a3b8;
  margin: auto 0;
}
