/* ==========================================================================
   Giao diện xã hội của thế giới chung (social-ui.mjs): menu lại gần người chơi, khung chat, bảng nhóm, thẻ lời mời.
   Cùng phong cách kính tối với bảng lớp học ngoại ngữ (class.css).
   ========================================================================== */

.sws-glass { background: rgba(13, 20, 33, .92); color: #e8eef7; border: 1px solid rgba(255, 255, 255, .1); border-radius: 18px;
  box-shadow: 0 24px 60px -20px rgba(0, 0, 0, .65); backdrop-filter: blur(10px); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; }
.sws-glass * { box-sizing: border-box; }
.sws-in { animation: sws-in .2s ease-out; }
@keyframes sws-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Ảnh đại diện chữ cái: màu theo tên (biến --h) */
.sws-ava { display: inline-flex; align-items: center; justify-content: center; flex: none; border-radius: 50%; font-weight: 800; color: #fff; text-transform: uppercase;
  background: linear-gradient(135deg, hsl(var(--h, 160) 65% 50%), hsl(calc(var(--h, 160) + 35) 65% 36%)); }
.sws-x { border: 0; background: none; color: #93a4bd; font-size: 15px; cursor: pointer; width: 30px; height: 30px; border-radius: 8px; flex: none; }
.sws-x:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.sws-x:disabled { opacity: .3; cursor: default; background: none; }

/* --- Menu lại gần --- */
#sw-social-menu { width: 300px; overflow: hidden; }
.sws-menu-hd { display: flex; align-items: center; gap: 12px; padding: 14px 14px 12px; border-bottom: 1px solid rgba(255, 255, 255, .08);
  background: linear-gradient(180deg, rgba(255, 255, 255, .06), transparent); }
.sws-menu-hd .sws-ava { width: 42px; height: 42px; font-size: 17px; box-shadow: 0 0 0 3px rgba(255, 255, 255, .08); }
.sws-name { font-size: 15px; font-weight: 700; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sws-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.sws-chip { font-size: 11px; font-weight: 600; border-radius: 999px; padding: 2px 8px; }
.sws-chip.is-friend { background: rgba(16, 185, 129, .16); color: #6ee7b7; }
.sws-chip.is-in { background: rgba(245, 158, 11, .16); color: #fcd34d; }
.sws-chip.is-out { background: rgba(148, 163, 184, .16); color: #cbd5e1; }
.sws-chip.is-group { background: rgba(139, 92, 246, .18); color: #c4b5fd; }
.sws-chip.is-other { background: rgba(56, 189, 248, .16); color: #7dd3fc; }
.sws-actions { display: flex; flex-direction: column; padding: 6px; gap: 2px; }
.sws-act { display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px 10px; border: 0; border-radius: 12px; background: none; color: inherit; text-align: left; cursor: pointer; font: inherit; transition: background .12s; }
.sws-act:hover, .sws-act:focus-visible { background: rgba(255, 255, 255, .07); outline: none; }
.sws-act:disabled { cursor: default; opacity: .55; background: none; }
.sws-tile { display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 10px; flex: none; }
.sws-tile.t-emerald { background: rgba(16, 185, 129, .16); color: #34d399; }
.sws-tile.t-sky { background: rgba(56, 189, 248, .16); color: #38bdf8; }
.sws-tile.t-violet { background: rgba(139, 92, 246, .18); color: #a78bfa; }
.sws-tile.t-amber { background: rgba(245, 158, 11, .16); color: #fbbf24; }
.sws-tile.t-gray { background: rgba(148, 163, 184, .12); color: #94a3b8; }
.sws-act-text { flex: 1; min-width: 0; }
.sws-act-label { display: block; font-size: 14px; font-weight: 600; color: #f1f5f9; }
.sws-act-hint { display: block; font-size: 12px; color: #93a4bd; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sws-kbd { flex: none; min-width: 22px; text-align: center; border-radius: 6px; padding: 1px 6px; font-size: 11px; font-weight: 700; color: #cbd5e1;
  background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .12); }
.sws-foot { padding: 7px 14px; font-size: 11.5px; color: #64748b; border-top: 1px solid rgba(255, 255, 255, .06); }
.sws-foot b { color: #94a3b8; }

/* --- Khung chat --- */
#sw-chat { width: min(360px, calc(100vw - 32px)); height: min(440px, calc(100vh - 140px)); display: flex; flex-direction: column; overflow: hidden; }
.sws-chat-hd { display: flex; align-items: center; gap: 8px; padding: 10px 10px 10px 14px; border-bottom: 1px solid rgba(255, 255, 255, .08);
  background: linear-gradient(180deg, rgba(255, 255, 255, .05), transparent); }
.sws-chat-title { font-size: 14px; font-weight: 700; color: #fff; display: flex; align-items: center; gap: 8px; }
.sws-chat-title small { font-size: 11.5px; font-weight: 500; color: #93a4bd; }
.sws-tabs { display: flex; gap: 6px; padding: 8px 10px; overflow-x: auto; border-bottom: 1px solid rgba(255, 255, 255, .06); scrollbar-width: none; }
.sws-tabs::-webkit-scrollbar { display: none; }
.sws-tab { flex: none; display: inline-flex; align-items: center; gap: 6px; border: 0; border-radius: 999px; padding: 4px 10px 4px 4px; background: rgba(255, 255, 255, .06);
  color: #cbd5e1; font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.sws-tab .sws-ava { width: 22px; height: 22px; font-size: 11px; }
.sws-tab:hover { background: rgba(255, 255, 255, .1); }
.sws-tab.is-on { background: rgba(37, 99, 235, .9); color: #fff; }
.sws-badge { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: #ef4444; color: #fff; font-size: 11px; line-height: 18px; text-align: center; }
.sws-log { flex: 1; min-height: 0; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; user-select: text; }
.sws-empty { margin: auto; text-align: center; color: #64748b; font-size: 13px; line-height: 1.5; }
.sws-row { display: flex; align-items: flex-end; gap: 8px; max-width: 100%; }
.sws-row .sws-ava { width: 26px; height: 26px; font-size: 12px; }
.sws-row.is-me { flex-direction: row-reverse; }
.sws-msg { max-width: 78%; display: flex; flex-direction: column; }
.sws-row.is-me .sws-msg { align-items: flex-end; }
.sws-from { font-size: 11px; color: #93a4bd; margin: 0 4px 2px; }
.sws-bubble { padding: 8px 12px; border-radius: 14px; font-size: 14px; line-height: 1.45; word-wrap: break-word; overflow-wrap: anywhere; background: rgba(255, 255, 255, .08); color: #e8eef7; border-bottom-left-radius: 4px; }
.sws-row.is-me .sws-bubble { background: #2563eb; color: #fff; border-bottom-left-radius: 14px; border-bottom-right-radius: 4px; }
.sws-row.is-cont .sws-ava { visibility: hidden; }
.sws-time { font-size: 10.5px; color: #64748b; margin: 2px 4px 0; }
.sws-ft { padding: 10px; border-top: 1px solid rgba(255, 255, 255, .08); }
.sws-form { display: flex; gap: 8px; }
.sws-form input { flex: 1; min-width: 0; height: 40px; border-radius: 12px; border: 1px solid rgba(255, 255, 255, .14); background: rgba(255, 255, 255, .06); color: #fff;
  padding: 0 12px; font: inherit; font-size: 14px; outline: none; }
.sws-form input::placeholder { color: #7c8aa0; }
.sws-form input:focus { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59, 130, 246, .25); }
.sws-send { width: 40px; height: 40px; border-radius: 12px; border: 0; background: #2563eb; color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; flex: none; }
.sws-send:hover { background: #1d4ed8; }
.sws-hint { margin-top: 6px; font-size: 11px; color: #64748b; text-align: center; }

/* --- Bảng nhóm --- */
#sw-group { width: 240px; padding: 12px; }
.sws-group-hd { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sws-group-hd b { font-size: 13.5px; color: #fff; }
.sws-group-hd small { font-size: 11.5px; color: #93a4bd; font-weight: 500; margin-left: 4px; }
.sws-leave { border: 0; background: rgba(239, 68, 68, .14); color: #fca5a5; font: inherit; font-size: 11.5px; font-weight: 600; border-radius: 8px; padding: 3px 8px; cursor: pointer; }
.sws-leave:hover { background: rgba(239, 68, 68, .25); }
.sws-member { display: flex; align-items: center; gap: 8px; padding: 5px 4px; border-radius: 10px; font-size: 13px; color: #e2e8f0; }
.sws-member .sws-ava { width: 26px; height: 26px; font-size: 12px; }
.sws-member span.n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sws-member em { font-style: normal; font-size: 11px; color: #93a4bd; }
.sws-kick { border: 0; background: none; color: #fca5a5; font: inherit; font-size: 11.5px; cursor: pointer; padding: 2px 4px; border-radius: 6px; }
.sws-kick:hover { background: rgba(239, 68, 68, .15); }

/* --- Thẻ lời mời / xin vào nhóm --- */
.sws-invite { pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; font-size: 13.5px; max-width: min(460px, calc(100vw - 32px)); }
.sws-invite .t { flex: 1; color: #e2e8f0; }
.sws-yes, .sws-no { border: 0; border-radius: 9px; padding: 6px 12px; font: inherit; font-size: 12.5px; font-weight: 700; cursor: pointer; flex: none; }
.sws-yes { background: #10b981; color: #fff; }
.sws-yes:hover { background: #059669; }
.sws-no { background: rgba(255, 255, 255, .1); color: #cbd5e1; }
.sws-no:hover { background: rgba(255, 255, 255, .16); }

/* Ẩn bằng class "hidden" của Tailwind: selector #id ở trên (display: flex) mạnh hơn nên phải ghi rõ */
#sw-chat.hidden, #sw-social-menu.hidden, #sw-group.hidden { display: none; }
