/* ==========================================================================
   SPORTCAST.PRO — EVENT CHAT MODULE (V2 REDESIGN OBSIDIAN GLASS)
   Modular chat stylesheet matching EventChat.tsx in V2 dimensions
   ========================================================================== */

/* ── Chat Overlay Container (Frosted Obsidian Glass) ────────────────────── */
.event-chat-overlay-layer {
  position: absolute;
  inset: 0;
  z-index: 30;
  border-radius: 1rem; /* rounded-2xl */
  overflow: hidden;
  background: rgba(12, 13, 16, 0.94) !important;
  backdrop-filter: blur(28px) saturate(140%) !important;
  -webkit-backdrop-filter: blur(28px) saturate(140%) !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  box-shadow: 0 24px 60px -15px rgba(0, 0, 0, 0.85), inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 0 30px var(--theme-accent-glow, rgba(16, 185, 129, 0.15)) !important;
  display: flex;
  flex-direction: column;
  transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1), transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.event-match-info-layer {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center !important;
  gap: clamp(1.4rem, 2.6vh, 2.4rem) !important;
  transition: opacity 0.16s cubic-bezier(0.16, 1, 0.3, 1), transform 0.16s cubic-bezier(0.16, 1, 0.3, 1);
}

.layer-hidden {
  opacity: 0 !important;
  pointer-events: none !important;
  visibility: hidden !important;
  transform: scale(0.98) !important;
}

.event-match-info-layer.layer-hidden {
  transition: opacity 0.12s ease, transform 0.12s ease, visibility 0s 0.12s !important;
}

.event-chat-overlay-layer.layer-hidden {
  transition: opacity 0.16s ease, transform 0.16s ease, visibility 0s 0.16s !important;
}

/* ── Screen Containers ──────────────────────────────────────────────────── */
.chat-ready-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

/* ── Messages Stream ────────────────────────────────────────────────────── */
.chat-orig-messages-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.85rem 0.75rem 0.4rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.chat-orig-messages-list::-webkit-scrollbar {
  width: 4px;
}
.chat-orig-messages-list::-webkit-scrollbar-track {
  background: transparent;
}
.chat-orig-messages-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}
.chat-orig-messages-list::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* ── Message Card / Substrate ───────────────────────────────────────────── */
.chat-msg-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0.5rem; /* 8px */
  padding: 7px 11px 8px 11px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  transition: background 0.18s ease, border-color 0.18s ease;
  word-break: break-word;
  position: relative;
}

.chat-msg-card:hover {
  border-color: rgba(255, 255, 255, 0.16);
}

.chat-msg-card.is-own {
  border-color: rgba(var(--theme-accent-rgb, 16, 185, 129), 0.35);
  background: rgba(var(--theme-accent-rgb, 16, 185, 129), 0.10);
}

.chat-msg-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.chat-msg-author-name {
  font-family: var(--font-druk-wide), 'Druk Wide Cyr', sans-serif;
  font-size: 0.75rem; /* 12px */
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-msg-time {
  font-family: var(--font-druk-wide), 'Druk Wide Cyr', sans-serif;
  font-size: 0.625rem; /* 10px */
  font-weight: 700;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.4);
  line-height: 1;
  white-space: nowrap;
  flex-shrink: 0;
}

.chat-msg-text {
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 0.875rem; /* 14px */
  line-height: 1.38;
  color: #F4F4F5;
  margin: 0;
  padding: 0;
}

/* ── Bottom Input Bar: 2-Row Agent Chat Box ─────────────────────────────── */
.chat-agent-bar {
  flex-shrink: 0;
  padding: 0.35rem 0.75rem 0.65rem 0.75rem;
  background: transparent;
  border-top: none;
  position: relative;
  z-index: 10;
}

.chat-agent-box {
  background: rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 0.5rem; /* 8px matching message cards */
  padding: 8px 12px 7px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 3px 12px rgba(0, 0, 0, 0.25);
}

.chat-agent-box:focus-within {
  border-color: rgba(var(--theme-accent-rgb, 16, 185, 129), 0.5);
  box-shadow: 0 0 16px var(--theme-accent-glow, rgba(16, 185, 129, 0.2)), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.06);
}

/* Row 1: Multiline Textarea auto-expanding from 1 to 3 rows */
.chat-agent-textarea {
  width: 100%;
  box-sizing: border-box;
  resize: none;
  border: none;
  outline: none;
  background: transparent;
  color: #F4F4F5;
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  line-height: 20px;
  height: 20px; /* 1 line default */
  max-height: 62px; /* 3 lines maximum */
  padding: 0;
  margin: 0;
  overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}

.chat-agent-textarea::placeholder {
  color: #71717A;
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
}

/* Row 2: Bottom row with Exit (X) Button, Author Nick, Countdown & Send Button */
.chat-agent-bottom-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 24px;
  gap: 8px;
}

/* Left: Circular Exit (X) Button + Author Nick in Druk Wide Cyr */
.chat-agent-left-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

/* Circular Exit (X) Button - Identical dimensions and round shape to send button */
.chat-agent-close-btn {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.55);
  cursor: pointer;
  padding: 0;
  transition: all 0.2s ease;
}

.chat-agent-close-btn:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.3);
  color: #FFFFFF;
  transform: scale(1.08);
}

.chat-agent-close-btn:active {
  transform: scale(0.95);
}

/* Nickname in Druk Wide Cyr with 16-char overflow safety */
.chat-agent-nick {
  font-family: var(--font-druk-wide), 'Druk Wide Cyr', sans-serif;
  font-size: 0.8125rem; /* ~13px */
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--theme-accent, #10B981);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 230px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  user-select: none;
  transition: color 0.2s ease;
}

/* Right: Actions wrap (Countdown + Circular Send Button) */
.chat-agent-right-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* Countdown Counter (240 -> 0) - EXACT SAME FONT AND SIZE AS NICK */
.chat-agent-countdown {
  font-family: var(--font-druk-wide), 'Druk Wide Cyr', sans-serif;
  font-size: 0.8125rem; /* Exactly matches .chat-agent-nick */
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  color: rgba(255, 255, 255, 0.45);
  transition: color 0.2s ease, text-shadow 0.2s ease;
  user-select: none;
  text-align: right;
}

.chat-agent-countdown.is-near-limit {
  color: #F59E0B;
}

.chat-agent-countdown.is-limit {
  color: #EF4444;
  text-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
}

/* Circular Send Button */
.chat-agent-send-btn {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.3);
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 0;
}

.chat-agent-send-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.chat-agent-send-btn:not(:disabled) {
  background: var(--theme-accent, #10B981);
  color: #050608;
  border-color: transparent;
  box-shadow: 0 0 12px var(--theme-accent-glow, rgba(16, 185, 129, 0.25));
}

.chat-agent-send-btn:not(:disabled):hover {
  transform: scale(1.08);
  box-shadow: 0 0 16px var(--theme-accent-glow, rgba(16, 185, 129, 0.4));
}

.chat-agent-send-btn:not(:disabled):active {
  transform: scale(0.95);
}

/* ── Scroll To Bottom Floating Button with Unread Badge ──────────────────── */
.chat-scroll-down-btn {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 14px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(18, 18, 22, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #FFFFFF;
  cursor: pointer;
  z-index: 25;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5), 0 0 12px var(--theme-accent-glow, rgba(16, 185, 129, 0.25));
  transition: transform 0.2s ease, opacity 0.2s ease, background 0.2s ease, border-color 0.2s ease;
  animation: scrollBtnPop 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  padding: 0;
}

.chat-scroll-down-btn:hover {
  background: rgba(28, 28, 36, 0.98);
  border-color: rgba(255, 255, 255, 0.35);
  transform: translateY(-2px);
}

.chat-scroll-down-btn:active {
  transform: translateY(0) scale(0.95);
}

.chat-scroll-down-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--theme-accent, #10B981);
  color: #050608;
  font-family: var(--font-agency);
  font-size: 0.75rem;
  font-weight: 800;
  line-height: 1;
  padding: 2px 5px;
  min-width: 16px;
  text-align: center;
  border-radius: 9999px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

@keyframes scrollBtnPop {
  from { opacity: 0; transform: translateY(8px) scale(0.85); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Auth Screen (Compact Anon Nickname + Color Selector) ────────────────── */
.chat-auth-container {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 100%;
  padding: 1.25rem 1rem;
  text-align: center;
  background: transparent;
}

.chat-auth-close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #A1A1AA;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  padding: 0;
}

.chat-auth-close-btn:hover {
  color: #FFFFFF;
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.25);
  transform: scale(1.06);
}

.chat-auth-title {
  font-family: var(--font-druk-wide), 'Druk Wide Cyr', sans-serif;
  font-size: 0.875rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #FFFFFF;
  margin-bottom: 2px;
}

.chat-auth-subtitle {
  font-size: 0.8rem;
  color: #71717A;
  margin-bottom: 0.85rem;
}

.chat-auth-form {
  width: 100%;
  max-width: 280px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-auth-input {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  padding: 7px 12px;
  color: #FFFFFF;
  font-family: var(--font-druk-wide), 'Druk Wide Cyr', sans-serif;
  font-size: 0.8rem;
  text-transform: uppercase;
  text-align: center;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.chat-auth-input:focus {
  border-color: var(--theme-accent, #10B981);
  box-shadow: 0 0 10px var(--theme-accent-glow, rgba(16, 185, 129, 0.25));
}

.chat-auth-swatches {
  display: flex;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}

.swatch-btn {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
  padding: 0;
}

.swatch-btn:hover {
  transform: scale(1.15);
}

.swatch-btn.is-active {
  border-color: #FFFFFF;
  transform: scale(1.2);
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.4);
}

.chat-auth-preview-wrap {
  background: rgba(0, 0, 0, 0.35);
  border: 1px dashed rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 8px;
  text-align: left;
}

.chat-auth-preview-label {
  font-size: 0.7rem;
  color: #71717A;
  display: block;
  margin-bottom: 5px;
  font-family: var(--font-agency);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.chat-auth-submit-btn {
  width: 100%;
  background: var(--theme-accent, #10B981);
  color: #050608;
  border: none;
  border-radius: 6px;
  padding: 8px 14px;
  font-family: var(--font-agency);
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 0 14px var(--theme-accent-glow, rgba(16, 185, 129, 0.25));
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.chat-auth-submit-btn:hover {
  transform: scale(1.02);
}

.chat-auth-submit-btn:active {
  transform: scale(0.98);
}

/* ── Mobile Viewports (< 1024px) ────────────────────────────────────────── */
@media (max-width: 1023px) {
  /* Height is strictly stable and inherited from .event-info-col: NO RESIZE JUMPS! */
  .event-info-card {
    transition: none !important;
  }

  .event-info-card.chat-active {
    min-height: 0 !important;
    height: 100% !important;
  }

  .event-match-info-layer {
    justify-content: center !important;
    gap: clamp(1.2rem, 2.4vh, 1.8rem) !important;
  }

  .event-chat-overlay-layer {
    border-radius: 0.75rem;
  }

  .chat-agent-nick,
  .chat-agent-countdown {
    font-size: 0.75rem; /* 12px */
  }

  .chat-agent-nick {
    max-width: 155px;
  }

  .chat-agent-close-btn,
  .chat-agent-send-btn {
    width: 22px;
    height: 22px;
  }
}
