/* Friends System UI — warm, minimal, Cuban-domino atmosphere. Scoped to .fr-* / .pm-friend / .esf-*
   so it never leaks into other components. Palette is local (not :root) to avoid global token bleed. */
.fr-overlay, .fr-panel, .pm-friend, .esquina-friends {
  --bg-dark: #1A1512; --surface: #241E1A; --border: #332B25;
  --amber: #D49A3E; --amber-hover: #E8B45A;
  --text: #F2EDE4; --muted: #B5A898; --success: #5B8C5A; --danger: #C44B3C;
}

/* ── shared button ── */
.fr-btn {
  cursor: pointer; font: inherit; font-weight: 700; font-size: 13.5px;
  padding: 9px 14px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  transition: background .15s ease, border-color .15s ease, color .15s ease, transform .08s ease, opacity .15s ease;
}
.fr-btn:hover:not(:disabled) { border-color: var(--amber); }
.fr-btn:active:not(:disabled) { transform: translateY(1px); }
.fr-btn:disabled { opacity: .6; cursor: default; }
.fr-btn.fr-add { background: linear-gradient(180deg, var(--amber-hover), var(--amber)); border-color: transparent; color: #231a0e; }
.fr-btn.fr-add:hover:not(:disabled) { filter: brightness(1.05); }
.fr-btn.fr-accept { color: #eafaf0; border-color: rgba(91, 140, 90, .6); }
.fr-btn.fr-accept:hover:not(:disabled) { background: rgba(91, 140, 90, .22); border-color: var(--success); }
.fr-btn.fr-decline, .fr-btn.fr-remove { color: var(--muted); }
.fr-btn.fr-decline:hover:not(:disabled), .fr-btn.fr-remove:hover:not(:disabled) { color: #fff; border-color: var(--danger); background: rgba(196, 75, 60, .18); }
.fr-btn.fr-friends { color: var(--amber-hover); }
.fr-btn.fr-pending { color: var(--muted); }

/* ── profile-card friend action row ── */
.pm-friend { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 2px 0 4px; }
.pm-friend:empty { display: none; }

/* ── status dot ── */
.fr-dot, .esf-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; display: inline-block; }
.fr-dot.is-online, .esf-dot.is-online, .fr-dot.is-playing, .esf-dot.is-playing { background: var(--success); box-shadow: 0 0 0 3px rgba(91, 140, 90, .18); }
.fr-dot.is-playing, .esf-dot.is-playing { background: var(--amber); box-shadow: 0 0 0 3px rgba(212, 154, 62, .18); }
.fr-dot.is-offline, .esf-dot.is-offline { background: #4a4038; box-shadow: none; }

/* ── friends modal ── */
.fr-overlay {
  position: fixed; inset: 0; z-index: 1200; display: flex; align-items: center; justify-content: center; padding: 18px;
  background: rgba(10, 7, 4, .68); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
.fr-panel {
  width: min(420px, 100%); max-height: min(80vh, 620px); display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .6); color: var(--text);
  font-family: 'Nunito', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.fr-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.fr-title { margin: 0; font-size: 18px; font-weight: 800; color: var(--text); }
.fr-close { cursor: pointer; font: inherit; font-size: 18px; line-height: 1; color: var(--muted); background: none; border: 0; padding: 4px 6px; border-radius: 8px; }
.fr-close:hover { color: var(--text); background: rgba(255, 255, 255, .06); }
.fr-body { padding: 12px 14px 16px; overflow-y: auto; }
.fr-section-title { font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--amber); margin: 10px 4px 8px; }
.fr-section-title:first-child { margin-top: 2px; }
.fr-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; border-radius: 12px; background: var(--bg-dark); border: 1px solid var(--border); margin-bottom: 8px;
}
.fr-who { display: flex; align-items: center; gap: 9px; min-width: 0; }
/* Avatar + live dot in the modal rows. Same monogram-or-image treatment as .esf-av, sized to
   the modal's slightly tighter row so the existing layout is unchanged. */
.fr-avwrap { position: relative; flex: none; line-height: 0; }
.fr-av {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 800; font-size: 13px; line-height: 1; color: #2a1a0f;
  background: linear-gradient(160deg, #ffd79a, #c8842e);
  background-size: cover; background-position: center;
}
.fr-av.has-img { color: transparent; }               /* image replaces the monogram */
.fr-avwrap .fr-dot {
  position: absolute; right: -1px; bottom: -1px;
  width: 11px; height: 11px; border: 2px solid var(--bg-dark);
}
.fr-name { font-weight: 700; font-size: 15px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fr-status { font-size: 12px; color: var(--muted); }
.fr-row-actions { display: flex; gap: 6px; flex: none; }
.fr-loading, .fr-empty { color: var(--muted); font-size: 14px; text-align: center; padding: 14px 8px; margin: 0; }

/* ── 🔎 Find a player — the search at the top of the Friends panel ─────────────
   Sits between .fr-head and the scrolling .fr-body, so it stays put while the list under it
   scrolls and survives the body being re-rendered after an accept/decline/remove. Results reuse
   .fr-row/.fr-av/.fr-name — a person reads the same here as in the list below. */
.fr-search { padding: 12px 14px 4px; border-bottom: 1px solid var(--border); }
.frs-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0 0 9px; }
.frs-label { flex: 1 0 100%; font-size: 12px; font-weight: 700; color: var(--muted); }
.frs-input {
  flex: 1 1 140px; min-width: 0; padding: 9px 12px;
  font: inherit; font-size: 14px; color: var(--text);
  background: var(--bg-dark); border: 1px solid var(--border); border-radius: 10px;
}
.frs-input::placeholder { color: var(--muted); }
.frs-input:focus-visible { outline: 2px solid var(--amber); outline-offset: 1px; border-color: var(--amber); }
.frs-submit { flex: none; }
/* Idle: neither the live region nor the result list may reserve blank space under the form. */
.frs-state:empty, .frs-results:empty { display: none; }
.frs-state { padding: 4px 8px 10px; text-align: left; }
.frs-results { padding-bottom: 4px; }

/* ── La Esquina "Te invitaron a jugar" (pending table invites) ──────────────────
   Same card shell as .esquina-friends so the two sections stack as one column, but with an
   amber left edge: an invite is the only thing in the corner that is waiting on you. */
.esquina-invites {
  width: min(440px, 92%); margin: 0 auto 14px; padding: 16px 18px; border-radius: 16px;
  background: rgba(36, 30, 26, .72); border: 1px solid var(--border);
  border-left: 3px solid var(--amber);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  color: var(--text); font-family: 'Nunito', system-ui, sans-serif;
}
.esquina-invites.hidden { display: none; }
.esi-title { margin: 0 0 12px; font-size: 16px; font-weight: 800; color: var(--amber-hover); }
.esi-list { display: flex; flex-direction: column; gap: 10px; }
.esi-row { display: flex; align-items: center; gap: 10px; }
.esi-av {
  width: 32px; height: 32px; border-radius: 50%; flex: none; display: grid; place-items: center;
  font-weight: 800; font-size: 14px; line-height: 1; color: #2a1a0f;
  background: linear-gradient(160deg, #ffd79a, #c8842e);
  background-size: cover; background-position: center;
}
.esi-av.has-img { color: transparent; }
.esi-who { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.esi-name { font-weight: 700; font-size: 15px; color: var(--text); }
.esi-meta { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.esi-table {
  font-weight: 800; letter-spacing: .06em; color: var(--amber-hover);
  padding: 1px 6px; border-radius: 999px; background: rgba(212, 154, 62, .14);
}
.esi-dead { color: #e88b84; font-weight: 700; }
.esi-actions { display: flex; gap: 6px; flex: none; margin-left: auto; }
.esi-btn {
  cursor: pointer; font: inherit; font-size: 13px; font-weight: 800;
  padding: 7px 12px; border-radius: 10px; border: 1px solid transparent;
}
.esi-btn:disabled { opacity: .5; cursor: default; }
.esi-accept { color: #231a0e; background: linear-gradient(180deg, #ffd79a, var(--amber)); }
.esi-accept:hover:not(:disabled) { background: linear-gradient(180deg, #f0c069, #d49a3e); }
.esi-decline { color: var(--muted); background: transparent; border-color: var(--border); }
.esi-decline:hover:not(:disabled) { color: var(--text); border-color: var(--amber); }
/* A table that died before you answered: still listed, but visibly not joinable. */
.esi-row.is-dead .esi-av, .esi-row.is-dead .esi-name { opacity: .55; }

/* ── La Esquina "Amigos conectados" (foreground section) ── */
.esquina-friends {
  width: min(440px, 92%); margin: 0 auto; padding: 16px 18px; border-radius: 16px;
  background: rgba(36, 30, 26, .72); border: 1px solid var(--border);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  color: var(--text); font-family: 'Nunito', system-ui, sans-serif;
}
.esquina-friends.hidden { display: none; }
.esf-title { margin: 0 0 12px; font-size: 16px; font-weight: 800; color: var(--amber-hover); }
.esf-list { display: flex; flex-direction: column; gap: 10px; }
.esf-row { display: flex; align-items: center; gap: 10px; }
.esf-name { font-weight: 700; font-size: 15px; color: var(--text); }

/* Avatar disc + the live dot pinned to its corner. Same monogram-or-image treatment the
   profile card uses (.has-img gets a background-image from avatarUrl). */
.esf-avwrap { position: relative; flex: none; line-height: 0; }
.esf-av {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 800; font-size: 14px; line-height: 1; color: #2a1a0f;
  background: linear-gradient(160deg, #ffd79a, #c8842e);
  background-size: cover; background-position: center;
}
.esf-av.has-img { color: transparent; }              /* image replaces the monogram */
/* Re-anchor the shared .esf-dot onto the avatar instead of sitting inline in the row. */
.esf-avwrap .esf-dot {
  position: absolute; right: -1px; bottom: -1px;
  width: 11px; height: 11px; border: 2px solid var(--surface, #241a12);
}

/* name on top, small meta line under it */
.esf-who { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.esf-meta { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.esf-status { font-size: 12.5px; color: var(--muted); }
.esf-level {
  font-size: 11.5px; font-weight: 800; color: var(--amber-hover);
  padding: 1px 6px; border-radius: 999px; background: rgba(212, 154, 62, .14);
}
/* The friend's SELF-CHOSEN status, shown next to (never replacing) the live indicator. */
.esf-chosen { font-size: 11.5px; font-weight: 700; padding: 1px 6px; border-radius: 999px; }
.esf-chosen.is-away      { color: #f0c069; background: rgba(240, 179, 90, .14); }
.esf-chosen.is-busy      { color: #e88b84; background: rgba(226, 86, 77, .16); }
.esf-chosen.is-invisible { color: var(--muted); background: rgba(255, 255, 255, .06); }
.esf-empty { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
/* "Invitar a mi mesa" on a friend row. The button itself reuses .esi-btn/.esi-accept (defined
   above for the invites panel and valid here — .esquina-friends carries the same palette), so this
   only sizes it for the tighter row and styles the settled result text that replaces it. */
.esf-invite { padding: 5px 10px; font-size: 12px; }
.esf-invited { font-size: 12px; font-weight: 700; color: var(--success); white-space: nowrap; }
.esf-invited.is-error { color: #e88b84; white-space: normal; text-align: right; max-width: 15ch; }
.esf-all {
  margin-top: 14px; cursor: pointer; font: inherit; font-size: 13.5px; font-weight: 700;
  color: var(--amber-hover); background: none; border: 0; padding: 4px 2px;
}
.esf-all:hover { color: #f0c069; text-decoration: underline; }

/* ── toast ── */
.fr-toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); z-index: 1400;
  padding: 10px 18px; border-radius: 12px; background: #241E1A; border: 1px solid #332B25; color: #F2EDE4;
  font-size: 14px; font-weight: 700; box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
  opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease;
}
.fr-toast.show { opacity: 1; transform: translate(-50%, 0); }
