/* ============================================================
   TWITCH CHAT OVERLAY - OBS STREAMER STYLES
   ============================================================ */

* {
  box-sizing: border-box;
}

html, body {
  background: transparent !important;
  margin: 0;
  padding: 0;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  font-family: 'Open Sans', 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: #ffffff;
  -webkit-font-smoothing: antialiased;
}

#chat_container {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  padding: 12px 16px;
  max-height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  pointer-events: none;
  word-break: break-word;
  overflow-wrap: break-word;
  scrollbar-width: none;
}

#chat_container::-webkit-scrollbar {
  display: none;
}

/* Animations */
@keyframes chatSlideUp {
  0% {
    opacity: 0;
    transform: translateY(22px) scale(0.98);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes chatPopIn {
  0% {
    opacity: 0;
    transform: scale(0.85);
  }
  70% {
    transform: scale(1.03);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes chatFadeIn {
  0% { opacity: 0; }
  100% { opacity: 1; }
}

@keyframes chatSlideFromLeft {
  0% { opacity: 0; transform: translateX(-28px); }
  100% { opacity: 1; transform: translateX(0); }
}

@keyframes chatSlideFromRight {
  0% { opacity: 0; transform: translateX(28px); }
  100% { opacity: 1; transform: translateX(0); }
}

.chat_line {
  margin-bottom: 6px;
  position: relative;
  will-change: transform, opacity;
  animation: chatSlideUp 0.25s cubic-bezier(0.1, 0.9, 0.2, 1) forwards;
}

.chat_line.entry-from-left:not(.anim-none):not(.anim-fade):not(.anim-pop) {
  animation: chatSlideFromLeft 0.25s cubic-bezier(0.1, 0.9, 0.2, 1) forwards;
}

.chat_line.entry-from-right:not(.anim-none):not(.anim-fade):not(.anim-pop) {
  animation: chatSlideFromRight 0.25s cubic-bezier(0.1, 0.9, 0.2, 1) forwards;
}

.chat_line.anim-pop {
  animation: chatPopIn 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.chat_line.anim-fade {
  animation: chatFadeIn 0.3s ease-in forwards;
}

.chat_line.anim-none {
  animation: none;
}

.chat_line.fading {
  opacity: 0 !important;
  transition: opacity 0.8s ease-out !important;
}

/* User Info & Badges */
.user_info {
  display: inline;
  vertical-align: middle;
}

.badge {
  display: inline-block;
  vertical-align: middle;
  border-radius: 4px;
  margin-right: 4px;
  margin-bottom: 3px;
  object-fit: contain;
}

.nick {
  font-weight: 700;
  vertical-align: middle;
  display: inline-block;
  letter-spacing: -0.01em;
}

.platform-tag {
  display: inline-block;
  vertical-align: middle;
  margin-right: 5px;
}

.platform-icon {
  width: 0.8em;
  height: 0.8em;
  border-radius: 3px;
  background: #9146ff;
  color: #fff;
  font-size: 0.72em;
  font-weight: 900;
  line-height: 1;
  text-align: center;
  padding-top: 0.08em;
}

.platform-dot {
  width: 0.42em;
  height: 0.42em;
  border-radius: 50%;
  background: #9146ff;
}

.platform-name {
  color: #bf94ff;
  font-size: 0.7em;
  font-weight: 700;
}

.platform-tag-off .platform-tag {
  display: none;
}

/* 7TV Paint Effect (fallback and gradients) */
.nick.paint {
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent !important;
}

.paint-shadows .nick.paint {
  filter: drop-shadow(0 0 3px rgba(255, 255, 255, 0.65));
}

.colon {
  margin-right: 8px;
  margin-left: 1px;
  color: var(--message-color, #ffffff);
  font-weight: 700;
  vertical-align: middle;
}

/* Message body */
.message {
  vertical-align: middle;
  color: var(--message-color, #ffffff);
  font-weight: var(--message-weight, 400);
}

.bold-messages .message {
  font-weight: 700 !important;
}

.smooth-scroll #chat_container {
  scroll-behavior: smooth;
}

.mention {
  color: #bf94ff;
  font-weight: 800;
}

.reply-context {
  color: #bf94ff;
  opacity: 0.85;
  font-size: 0.88em;
}

/* Twitch GIF Keyboard messages */
.message.gif-message {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 6px;
  max-width: 100%;
  margin-top: 4px;
}

.twitch-gif {
  display: block;
  width: auto;
  height: auto;
  max-width: min(100%, var(--gif-max-size, 320px));
  max-height: var(--gif-max-size, 320px);
  border-radius: 8px;
  object-fit: contain;
}

/* Emotes & Zero-Width Support */
.emote-wrapper {
  position: relative;
  display: inline-block;
  vertical-align: middle;
  margin: 0 2px;
}

.emote {
  display: inline-block;
  vertical-align: middle;
  object-fit: contain;
  margin: 0 1px;
}

.emote.zero-width {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}

/* Cheer Bits */
.cheer_bits {
  font-weight: 800;
  margin-left: 2px;
  margin-right: 6px;
  font-size: 0.8em;
  vertical-align: middle;
}

.cheer_emote {
  vertical-align: middle;
  margin-right: 2px;
}

/* Sizes */
/* Size 1 - Small */
.size-small #chat_container {
  font-size: 20px;
}
.size-small .chat_line {
  line-height: 32px;
  margin-bottom: 4px;
}
.size-small .badge {
  width: 18px;
  height: 18px;
}
.size-small .emote {
  max-height: 28px;
  max-width: 80px;
}
.size-small .cheer_emote {
  max-height: 26px;
}

/* Size 2 - Medium (Default) */
.size-medium #chat_container {
  font-size: 28px;
}
.size-medium .chat_line {
  line-height: 44px;
  margin-bottom: 6px;
}
.size-medium .badge {
  width: 24px;
  height: 24px;
}
.size-medium .emote {
  max-height: 38px;
  max-width: 110px;
}
.size-medium .cheer_emote {
  max-height: 36px;
}

/* Size 3 - Large */
.size-large #chat_container {
  font-size: 38px;
}
.size-large .chat_line {
  line-height: 58px;
  margin-bottom: 8px;
}
.size-large .badge {
  width: 32px;
  height: 32px;
}
.size-large .emote {
  max-height: 48px;
  max-width: 135px;
}
.size-large .cheer_emote {
  max-height: 46px;
}

/* Size 4 - Extra Large */
.size-xlarge #chat_container {
  font-size: 48px;
}
.size-xlarge .chat_line {
  line-height: 72px;
  margin-bottom: 10px;
}
.size-xlarge .badge {
  width: 40px;
  height: 40px;
}
.size-xlarge .emote {
  max-height: 60px;
  max-width: 160px;
}
.size-xlarge .cheer_emote {
  max-height: 58px;
}

/* Strokes (Contorno com paint-order exterior) */
.stroke-thin #chat_container {
  -webkit-text-stroke: 1px rgba(0, 0, 0, 0.95);
  paint-order: stroke fill;
}

.stroke-medium #chat_container {
  -webkit-text-stroke: 2px rgba(0, 0, 0, 0.95);
  paint-order: stroke fill;
}

.stroke-thick #chat_container {
  -webkit-text-stroke: 3px rgba(0, 0, 0, 0.95);
  paint-order: stroke fill;
}

.stroke-thicker #chat_container {
  -webkit-text-stroke: 4.5px rgba(0, 0, 0, 0.95);
  paint-order: stroke fill;
}

/* Shadows */
.shadow-small #chat_container {
  filter: drop-shadow(2px 2px 2px rgba(0, 0, 0, 0.85));
}

.shadow-medium #chat_container {
  filter: drop-shadow(3px 3px 4px rgba(0, 0, 0, 0.95));
}

.shadow-large #chat_container {
  filter: drop-shadow(4px 4px 6px rgba(0, 0, 0, 0.95));
}

.shadow-glow #chat_container {
  filter: drop-shadow(0 0 6px rgba(0, 0, 0, 1)) drop-shadow(0 0 12px rgba(0, 0, 0, 0.9));
}

/* Options */
.nl-after-name .user_info {
  display: block;
}
.nl-after-name .colon {
  display: none;
}
.nl-after-name .message {
  display: block;
  margin-top: 1px;
}

.hide-names .user_info {
  display: none !important;
}

.small-caps .nick,
.small-caps .message {
  font-variant: small-caps;
}

.hide-badges .badge {
  display: none !important;
}

/* Highlighted messages (e.g. bits / channel points) */
.chat_line.highlighted {
  background: rgba(145, 70, 255, 0.25);
  border-left: 4px solid #9146FF;
  padding: 4px 8px;
  border-radius: 4px;
}

.chat_line.first-message::before {
  content: "FIRST";
  display: inline-block;
  margin-right: 6px;
  padding: 0 4px;
  border-radius: 3px;
  background: #9146ff;
  color: #fff;
  font-size: 0.55em;
  font-weight: 800;
  line-height: 1.5;
  vertical-align: middle;
}

.chat_line.channel-points-event {
  background: rgba(145, 70, 255, 0.2);
  border-left: 4px solid #9146ff;
  padding: 4px 8px;
  border-radius: 4px;
}

/* Action messages (/me) */
.chat_line.action .message {
  font-style: italic;
}

/* Subscription / System Notice */
.chat_line.system-notice {
  background: rgba(255, 215, 0, 0.2);
  border-left: 4px solid #FFD700;
  padding: 4px 8px;
  border-radius: 4px;
  color: #FFE57F;
}
