/* ==========================================
   PARTY WIDGET STYLESHEET (party.css)
   CuuLongGame Ecosystem — JOB_85 (Phase 1 & 2)
   Layering Law z-index: 55
   ========================================== */

.party-widget {
  position: fixed;
  left: 0;
  top: 0;
  width: 0;
  height: 100vh;
  z-index: 55;
  --party-tab-rail-width: 40px;
  font-family: var(--font-body, system-ui, sans-serif);
  /* 🚨 Khung cha rộng NGUYÊN CẢ panel (~329px) kể cả khi panel đang thu gọn —
     panel lúc đó tuy đã visibility:hidden nhưng khung CHA vẫn nhận click, tạo 1
     "khối vô hình" rộng gấp ~8 lần cái tab 40px nhìn thấy được, che mất nội dung
     bên dưới (menu Admin, ô Sudoku... — bug thật Owner báo 2026-07-29).
     Khung cha chỉ là hộp bố cục, KHÔNG có gì để bấm → tắt nhận click ở đây,
     rồi trả lại quyền nhận click cho đúng 2 phần tử thật sự bấm được bên dưới. */
  pointer-events: none;
}

/* Navigation container holding vertical tabs attached to left screen edge */
.party-widget-nav {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 2;
  pointer-events: auto;   /* tab luôn bấm được (kể cả khi thu gọn) */
}

/* Vertical Tab attached to left screen edge */
.party-widget-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  min-width: 40px;
  padding: 10px 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: none;
  border-radius: 0 var(--radius) var(--radius) 0;
  cursor: pointer;
  user-select: none;
  transition: background var(--dur-quick, 0.15s) var(--ease-out, ease-out),
              transform var(--dur-quick, 0.15s) var(--ease-out, ease-out),
              border-color var(--dur-quick, 0.15s);
  position: relative;
  box-shadow: var(--shadow-sm);
  color: var(--text-muted);
}

.party-widget-tab:hover {
  background: var(--surface-3);
  color: var(--text);
}

.party-widget-tab.active {
  background: var(--surface);
  color: var(--brand, var(--accent, #3b82f6));
  border-color: var(--brand, var(--accent, #3b82f6));
  box-shadow: var(--shadow-md);
}

.party-tab-icon {
  font-size: 16px;
  line-height: 1;
}

.party-tab-text {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  transform: rotate(180deg);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  margin-top: 6px;
  text-transform: uppercase;
  white-space: nowrap;
}

.party-tab-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 16px;
  height: 16px;
  background-color: var(--danger, #fb7185);
  color: #ffffff;
  font-size: 11px;
  font-weight: 900;
  line-height: 16px;
  text-align: center;
  border-radius: 50%;
  display: none;
  box-shadow: 0 0 6px rgba(251, 113, 133, 0.8);
  animation: pulse-badge 1.5s infinite;
}

@keyframes pulse-badge {
  0% { transform: scale(1); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

.party-widget-tab.has-badge .party-tab-badge {
  display: block;
}

.party-widget-tab.has-count .party-tab-badge {
  background-color: var(--brand, var(--accent, #3b82f6));
  box-shadow: 0 0 6px rgba(59, 130, 246, 0.8);
  animation: none;
}

/* Sliding Panel */
.party-widget-panel {
  position: absolute;
  left: var(--party-tab-rail-width);
  top: 50%;
  width: 290px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: none;
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  max-height: 80vh;
  overflow: hidden;
  transform: translate(-100%, -50%);
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: transform var(--dur-normal, 0.25s) var(--ease-out, ease-out),
              opacity var(--dur-normal, 0.25s) var(--ease-out, ease-out),
              visibility var(--dur-normal, 0.25s);
  z-index: 1;
}

.party-widget.is-open .party-widget-panel {
  transform: translate(0, -50%);
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
}

/* Panel Header */
.party-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-2, 10px) var(--sp-3, 16px);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

.party-panel-title-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.party-panel-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.party-status-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: var(--radius-pill, 999px);
  background: var(--surface-3);
  color: var(--text-muted);
}

.party-status-badge.recruiting {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success, #22c55e);
}

.party-status-badge.queued {
  background: rgba(234, 179, 8, 0.15);
  color: #eab308;
}

.party-status-badge.in_game {
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
}

.party-panel-close {
  width: 28px;
  height: 28px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

/* Tab Views Container */
.party-tab-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Roster / Members List */
.party-roster-wrap {
  padding: var(--sp-2, 10px) var(--sp-3, 16px);
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 100px;
}

/* Party Pending Invitation Banner */
.party-invite-banner {
  background: var(--surface-2);
  border: 1px solid var(--brand, var(--accent, #3b82f6));
  border-radius: var(--radius, 8px);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 4px;
}

.party-invite-header {
  font-size: 11px;
  font-weight: 700;
  color: var(--brand, var(--accent, #3b82f6));
  text-transform: uppercase;
}

.party-invite-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 0;
}

.party-invite-card-info {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.party-invite-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.party-member-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius, 8px);
  transition: background var(--dur-quick, 0.15s);
}

.party-member-card:hover {
  background: var(--surface-3);
}

.party-member-avatar {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  cursor: pointer;
  position: relative;
}

.party-member-avatar .avatar,
.party-member-avatar .board-av {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}

.party-member-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.party-member-name-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.party-member-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.party-member-gender {
  font-size: 11px;
}

.party-member-status-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.party-leader-tag {
  color: #f1c40f;
  font-size: 12px;
}

.party-ready-tag {
  font-size: 11px;
  font-weight: 600;
}

.party-ready-tag.is-ready {
  color: var(--success, #22c55e);
}

.party-ready-tag.not-ready {
  color: var(--text-muted);
}

.party-member-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.party-ready-checkbox {
  width: 18px;
  height: 18px;
  min-height: 0;
  padding: 0;
  flex-shrink: 0;
  box-shadow: none;
  cursor: pointer;
  accent-color: var(--accent);
}

.party-kick-btn {
  width: 26px;
  height: 26px;
  padding: 0;
  min-height: 0;
  font-size: 12px;
}

.party-empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: var(--sp-4, 24px) var(--sp-2, 10px);
  font-size: 13px;
}

/* Panel Actions Footer */
.party-panel-actions {
  padding: var(--sp-2, 10px) var(--sp-3, 16px);
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.party-mode-select-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.party-mode-select-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
}

.party-mode-select {
  width: 100%;
  height: 34px;
  font-size: 13px;
  border-radius: var(--radius-sm, 6px);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 0 8px;
}

.party-fee-preview {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  background: var(--surface-3);
  padding: 4px 8px;
  border-radius: var(--radius-sm, 6px);
}

.party-btn-group {
  display: flex;
  gap: 8px;
}

.party-btn-group .btn {
  flex: 1;
}

/* Invite Friends Drawer */
.party-invite-drawer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  max-height: 180px;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.party-friend-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 8px;
  border-radius: var(--radius-sm, 6px);
  background: var(--surface-2);
}

.party-friend-info {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.party-friend-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
}

.party-friend-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Friends Panel Styles */
.friends-panel-wrap {
  padding: var(--sp-2, 10px) var(--sp-3, 16px);
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.friends-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.friends-section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

.friends-section-title.has-pending {
  color: var(--danger, #fb7185);
}

.friend-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius, 8px);
  transition: background var(--dur-quick, 0.15s);
}

.friend-card:hover {
  background: var(--surface-3);
}

.friend-card.pending-card {
  border-color: rgba(251, 113, 133, 0.4);
  background: rgba(251, 113, 133, 0.08);
}

.friend-card-info {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.friend-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9ca3af;
  flex-shrink: 0;
}

.friend-status-dot.online {
  background: #22c55e;
  box-shadow: 0 0 4px rgba(34, 197, 94, 0.6);
}

.friend-card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.friend-action-btn {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  padding: 2px 4px !important;
  min-width: auto !important;
  height: auto !important;
  line-height: 1 !important;
  font-size: 15px;
  cursor: pointer;
  opacity: 0.85;
  transition: opacity 0.15s ease-in-out, transform 0.15s ease-in-out;
}

.friend-action-btn:hover:not(:disabled) {
  opacity: 1;
  transform: scale(1.2);
  background: transparent !important;
}

.friend-action-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* Responsive Breakpoints */
@media (max-width: 1024px) and (min-width: 601px) {
  .party-widget-panel {
    width: 250px;
  }
  .party-member-gender {
    display: none;
  }
}

@media (max-width: 600px) {
  .party-widget-panel {
    width: 280px;
    max-width: 78vw;
  }
  .party-widget-tab {
    min-height: 44px;
  }
}

/* GHI CHÚ (2026-07-29): từng có luật ẩn HẲN widget khi body.clg-game-page /
   body.game-active để chống che nội dung game. ĐÃ GỠ vì xử lý sai chỗ — mất luôn
   tiện ích mở Tổ Đội/Bạn Bè trong lúc chơi (phán quyết Owner). Nguyên nhân thật
   là khung cha .party-widget nhận click trên cả vùng panel đang thu gọn; đã vá
   bằng pointer-events ở đầu file. Widget nay hiện & bấm được ở MỌI trang, và chỉ
   chiếm đúng vùng nhìn thấy được — KHÔNG dựng lại luật ẩn theo trang nữa. */
