/*
 * Table page (/tables/:id) — Figma reskin
 *
 * 7 frame variants share the same chrome (top bar + right rail + tabletop +
 * joker indicator). State-specific elements (banners, sheets, hand) layer on
 * top via dedicated components. Designed for 360x692 portrait mobile —
 * exactly matches Figma artboard.
 *
 * Figma file: Tq297u9AH340mZFoxWNOGy
 * Sample node: 525:1655 (waiting state — the canonical chrome reference)
 */

/* ── Page shell ─────────────────────────────────────────────────────────── */
.table-page {
  /* Force the 360×692 Figma viewport on every screen. The component itself is
     centered horizontally on desktop. Mobile fills natively. */
  position: relative;
  width: 360px;
  height: 100dvh;
  max-height: 692px;
  margin: 0 auto;
  background:
    radial-gradient(ellipse 120% 80% at 50% 45%, #024522 0%, #001f0c 70%, #000c04 100%),
    #001f0c;
  overflow: hidden;
  isolation: isolate;
  color: #fbfcfc;
  font-family: "Inter", ui-sans-serif, system-ui, sans-serif;
}

@media (min-width: 361px) {
  body:has(.table-page) {
    background: #000;
  }
}

/* Hide the global lobby chrome (top nav, dock) when on the table page —
   table is full-bleed on mobile. */
body:has(.table-page) turbo-frame#nav,
body:has(.table-page) .lobby-dock {
  display: none !important;
}

/* ── Top bar (back + notifications) ─────────────────────────────────────── */
.table-topbar {
  position: absolute;
  inset-inline: 15px;
  top: 18px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 30;
}

.table-topbar__btn {
  width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(166, 217, 15, 0.35);
  border-radius: 12px;
  background: linear-gradient(180deg, #0a4a25 0%, #073418 100%);
  color: #fbfcfc;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}

.table-topbar__btn:active {
  transform: scale(0.95);
}

.table-topbar__btn:focus-visible {
  outline: 2px solid #a6d90f;
  outline-offset: 2px;
}

.table-topbar__btn svg {
  width: 18px;
  height: 18px;
  stroke-width: 2;
}

/* ── Tabletop (glowing oval felt) ───────────────────────────────────────── */
.tabletop-felt {
  position: absolute;
  inset-inline: 4px;
  top: 97px;
  height: 423px;
  border-radius: 50% / 50%;
  /* CSS gradient mirroring the Figma glow. Going with CSS over a baked PNG
     because the Figma reference PNG also contains the seats + CORINGA + card
     stack, which conflict with the live game elements rendered on top. */
  background:
    radial-gradient(ellipse 70% 55% at 50% 50%,
      #d4e85c 0%,
      #a6d90f 10%,
      #5fa70c 28%,
      #2a7a44 50%,
      #0d3b1f 78%,
      #03190b 100%);
  box-shadow:
    inset 0 0 0 2px rgba(8, 50, 24, 0.7),
    inset 0 4px 18px rgba(0, 0, 0, 0.35),
    0 14px 40px rgba(0, 0, 0, 0.55);
  z-index: 1;
}

.tabletop-felt::before {
  /* Inner highlight ring for the "rim" feel */
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: inherit;
  background: radial-gradient(ellipse at 50% 38%, rgba(255, 255, 255, 0.05) 0%, transparent 65%);
  pointer-events: none;
}

/* ── Right action rail (wallet / saldo / bonus / chat) ──────────────────── */
.table-rail {
  position: absolute;
  top: 66px;
  right: 15px;
  width: 42px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  z-index: 25;
}

.table-rail__close {
  position: absolute;
  top: -4px;
  right: 0;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(5, 35, 18, 0.9);
  border: 1px solid rgba(166, 217, 15, 0.4);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #a6d90f;
  z-index: 2;
  -webkit-tap-highlight-color: transparent;
}

.table-rail__close svg {
  width: 10px;
  height: 10px;
  stroke-width: 2.5;
}

.table-rail__items {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 0 6px;
  background: linear-gradient(180deg, rgba(10, 60, 30, 0.7) 0%, rgba(7, 52, 24, 0.7) 100%);
  border: 1px solid rgba(166, 217, 15, 0.25);
  border-radius: 21px;
  width: 42px;
  align-items: center;
}

.table-rail__btn {
  position: relative;
  width: 34px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: #fbfcfc;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.table-rail__btn--icon {
  background: radial-gradient(circle at 30% 30%, #fbe07a 0%, #d59f24 55%, #8a5a0c 100%);
  border-radius: 8px;
  box-shadow: inset 0 -2px 4px rgba(0, 0, 0, 0.25), 0 1px 2px rgba(0, 0, 0, 0.4);
}

.table-rail__btn--plus {
  background: radial-gradient(circle at 30% 30%, #a6d90f 0%, #5fa70c 60%, #2d6b08 100%);
  border-radius: 50%;
  width: 16px;
  height: 16px;
  position: absolute;
  bottom: -4px;
  right: -4px;
  color: #06310f;
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
  border: 1.5px solid #001f0c;
}

.table-rail__group {
  position: relative;
  width: 34px;
  height: 32px;
}

/* ── Seats (empty chair) ────────────────────────────────────────────────── */
.seat {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 47px;
  height: 47px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 35%, #0c4a24 0%, #062815 75%, #021608 100%);
  border: 1.5px solid rgba(255, 255, 255, 0.06);
  color: #fbfcfc;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}

.seat:hover {
  border-color: rgba(166, 217, 15, 0.4);
}

.seat:active {
  transform: scale(0.95);
}

.seat__chair {
  width: 25px;
  height: 25px;
  opacity: 0.85;
}

/* Active player seat — green glow halo */
.seat--active {
  background: radial-gradient(circle at 50% 35%, #a6d90f 0%, #62a40d 50%, #2d6b08 100%);
  box-shadow: 0 0 16px rgba(166, 217, 15, 0.6);
}

/* Hide the legacy waiting copy + card images that BoardComponent renders —
   the new `.waiting-info-banner` + `.spectator-footer` replace them.  */
.table-page .position-waiting,
.table-page .position-table-name {
  display: none !important;
}

/* ── Knock sheet (Você já viu suas cartas. Quer fugir?) ─────────────────── */
.knock-sheet {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 191px;
  background: linear-gradient(180deg, #001b09 0%, #07301a 100%);
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  padding: 27px 31px 16px;
  z-index: 25;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.45);
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
}

.knock-sheet[data-open="true"] {
  transform: translateY(0);
}

.knock-sheet__handle {
  width: 46px;
  height: 3px;
  margin: 0 auto 16px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.4);
}

.knock-sheet__title {
  color: #fbfcfc;
  font-size: 12px;
  font-weight: 500;
  text-align: center;
  margin: 0 0 16px;
}

.knock-sheet__actions {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.knock-sheet__btn {
  width: 297px;
  height: 48px;
  margin: 0 auto;
  border-radius: 24px;
  border: none;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.knock-sheet__btn--primary {
  background: linear-gradient(180deg, #a6d90f 0%, #5fa70c 100%);
  color: #001f0c;
  box-shadow: 0 4px 12px rgba(166, 217, 15, 0.4);
}

.knock-sheet__btn--secondary {
  background: transparent;
  color: #fbfcfc;
  border: 1.5px solid rgba(255, 255, 255, 0.45);
}

/* ── Hand reveal sheet (cards visible in bottom band) ───────────────────── */
.hand-reveal-sheet {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 146px;
  background: linear-gradient(180deg, #001b09 0%, #07301a 100%);
  padding: 16px 16px 8px;
  z-index: 15;
  display: flex;
  flex-direction: column;
}

.hand-reveal-sheet__title {
  color: #fbfcfc;
  font-size: 12px;
  font-weight: 500;
  text-align: center;
  margin: 0 0 12px;
}

.hand-reveal-sheet__cards {
  flex: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1px;
  padding: 0 16px;
}

.hand-reveal-sheet__card {
  width: 43px;
  height: 72px;
  border-radius: 4px;
  background: #fbfcfc;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}

/* ── State banners ──────────────────────────────────────────────────────── */
.waiting-info-banner {
  position: absolute;
  top: 219px;
  left: 50%;
  transform: translateX(-50%);
  width: 170px;
  padding: 8px 16px;
  background: rgba(5, 35, 18, 0.85);
  border: 1px solid rgba(166, 217, 15, 0.3);
  border-radius: 14px;
  color: #fbfcfc;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.35;
  text-align: center;
  z-index: 11;
}

.turn-wait-banner {
  position: absolute;
  top: 23px;
  left: 50%;
  transform: translateX(-50%);
  width: 230px;
  height: 32px;
  background: linear-gradient(180deg, #f8b542 0%, #d97a17 100%);
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: #2c1505;
  font-size: 11px;
  font-weight: 600;
  z-index: 20;
}

.turn-wait-banner__icon {
  width: 14px;
  height: 14px;
}

.spectator-footer {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 146px;
  background: linear-gradient(180deg, #001b09 0%, #07301a 100%);
  padding: 47px 32px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  text-align: center;
  z-index: 15;
}

.spectator-footer__text {
  color: #fbfcfc;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.35;
  max-width: 297px;
}

/* ── Chat sheet (3 modes: emoji / quick / conversation) ────────────────── */
.chat-sheet {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  background: linear-gradient(180deg, #001b09 0%, #07301a 100%);
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  padding: 16px 16px 8px;
  z-index: 30;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-sheet--emoji { height: 388px; }
.chat-sheet--quick { height: 451px; }
.chat-sheet--convo { height: 331px; }

.chat-sheet__handle {
  width: 46px;
  height: 3px;
  margin: 0 auto 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.4);
}

/* Tabs */
.chat-tabs {
  display: flex;
  width: 100%;
  height: 40px;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 20px;
  padding: 4px;
  gap: 4px;
}

.chat-tabs__tab {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: #fbfcfc;
  font-size: 12px;
  font-weight: 600;
  border-radius: 16px;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease;
  -webkit-tap-highlight-color: transparent;
}

.chat-tabs__tab[data-active="true"] {
  background: linear-gradient(180deg, #a6d90f 0%, #5fa70c 100%);
  color: #001f0c;
}

/* Player info card */
.player-info-card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  height: 76px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(166, 217, 15, 0.18);
  border-radius: 16px;
}

.player-info-card__avatar {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, #f1d3b0, #d8b289);
  border: 2px solid rgba(166, 217, 15, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
}

.player-info-card__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.player-info-card__heading {
  font-size: 10px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.55);
  letter-spacing: 0.3px;
}

.player-info-card__name {
  font-size: 14px;
  font-weight: 800;
  color: #fbfcfc;
  margin-bottom: 2px;
}

.player-info-card__stats {
  display: flex;
  gap: 10px;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.75);
}

.player-info-card__id {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.55);
  align-self: flex-start;
}

/* Emoji grid */
.emoji-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-top: 4px;
}

.emoji-grid__heading {
  font-size: 12px;
  font-weight: 700;
  color: #fbfcfc;
  margin: 4px 0 2px;
}

.emoji-grid__cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.emoji-grid__btn {
  width: 48px;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(166, 217, 15, 0.18);
  border-radius: 12px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.emoji-grid__price {
  font-size: 9px;
  font-weight: 700;
  color: #a6d90f;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.emoji-grid__price--paid {
  color: #f8d8a8;
}

/* Quick messages */
.quick-messages {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  flex: 1;
}

.quick-messages__btn {
  height: 38px;
  padding: 0 16px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 19px;
  color: #fbfcfc;
  font-size: 12px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.quick-messages__btn:hover {
  border-color: rgba(166, 217, 15, 0.4);
}

/* Conversation view */
.chat-convo {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
}

.chat-bubble {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-bubble--outgoing {
  flex-direction: row-reverse;
}

.chat-bubble__avatar {
  width: 34px;
  height: 33px;
  flex-shrink: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, #f1d3b0, #d8b289);
  border: 1.5px solid rgba(166, 217, 15, 0.35);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.chat-bubble__text {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 19px;
  padding: 10px 16px;
  color: #fbfcfc;
  font-size: 12px;
  font-weight: 500;
  max-width: 220px;
}

.chat-bubble--outgoing .chat-bubble__text {
  background: linear-gradient(180deg, #0e4928 0%, #073418 100%);
  border-color: rgba(166, 217, 15, 0.25);
}

/* Send message input */
.chat-input {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: auto;
}

.chat-input__heading {
  font-size: 12px;
  font-weight: 700;
  color: #fbfcfc;
  margin: 0 0 6px;
}

.chat-input__row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.chat-input__field {
  flex: 1;
  height: 48px;
  padding: 0 16px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(166, 217, 15, 0.2);
  border-radius: 24px;
  color: #fbfcfc;
  font-size: 13px;
  outline: none;
}

.chat-input__field::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

.chat-input__send {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #a6d90f 0%, #5fa70c 100%);
  color: #001f0c;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.chat-input__send svg {
  width: 22px;
  height: 22px;
  stroke-width: 2.2;
}

/* ── Joker mini preview (top header) ────────────────────────────────────── */
.joker-indicator {
  position: absolute;
  top: 206px;
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  flex-direction: column;
  gap: 4px;
  z-index: 5;
}

.joker-indicator__cards {
  position: relative;
  width: 60px;
  height: 40px;
}

.joker-indicator__card {
  position: absolute;
  width: 24px;
  height: 40px;
  border-radius: 3px;
  background: #fbfcfc;
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.35);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 800;
  color: #1a1a1a;
}

.joker-indicator__card:nth-child(1) {
  left: 6px;
  transform: rotate(-12deg);
}

.joker-indicator__card:nth-child(2) {
  left: 30px;
  transform: rotate(12deg);
}

.joker-indicator__card--red {
  color: #e63946;
}

.joker-indicator__label {
  background: rgba(5, 35, 18, 0.85);
  color: #a6d90f;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(166, 217, 15, 0.3);
}

.joker-indicator__pulse {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 35%, #fbfcfc 0%, #a6d90f 60%, rgba(166, 217, 15, 0) 100%);
  animation: joker-pulse 1.6s ease-in-out infinite;
  pointer-events: none;
}

@keyframes joker-pulse {
  0%, 100% { transform: translateX(-50%) scale(0.85); opacity: 0.55; }
  50%      { transform: translateX(-50%) scale(1.15); opacity: 1; }
}

/* ── Central card stack (joker + deck) ──────────────────────────────────── */
.table-center {
  position: absolute;
  top: 278px;
  left: 84px;
  width: 108px;
  height: 108px;
  z-index: 4;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.4));
  pointer-events: none;
}

.table-center__deck {
  position: absolute;
  inset: 50% auto auto 50%;
  width: 60px;
  height: 84px;
  margin: -42px 0 0 -30px;
  border-radius: 4px;
  background:
    linear-gradient(135deg, #c8362f 0%, #7a1f1c 100%),
    #a02828;
  background-size: 100% 100%;
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.08),
    inset 0 0 0 4px rgba(190, 36, 36, 0.95),
    inset 0 0 0 5.5px rgba(255, 255, 255, 0.2),
    0 4px 10px rgba(0, 0, 0, 0.5);
  transform: rotate(-6deg);
}

.table-center__deck::after {
  content: "CACHETA";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.5px;
  color: #f8d8a8;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.table-center__deck--top {
  transform: rotate(8deg);
  margin: -38px 0 0 -22px;
}

/* ── Discard pile (right of center) ─────────────────────────────────────── */
.table-discard {
  position: absolute;
  top: 290px;
  left: 204px;
  width: 43px;
  height: 72px;
  z-index: 4;
}

/* ── "Solta a carta..." tooltip ─────────────────────────────────────────── */
.drag-hint {
  position: absolute;
  top: 119px;
  left: 48px;
  width: 91px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 35, 18, 0.9);
  color: #fbfcfc;
  border-radius: 13px;
  border: 1px solid rgba(166, 217, 15, 0.3);
  font-size: 11px;
  font-weight: 500;
  z-index: 10;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.drag-hint::after {
  content: "";
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: rgba(5, 35, 18, 0.9);
}

.drag-hint[data-visible="true"] {
  opacity: 1;
}
