/* Admin Analytics & Dashboard Styles */

.admin-body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  margin: 0;
  display: flex;
  flex-direction: column;
}

/* Auth Overlay */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 26, 0.96);
  backdrop-filter: blur(12px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  max-width: 440px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.auth-badge-icon {
  font-size: 3rem;
  margin-bottom: 0.75rem;
}

.auth-header h2 {
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
}

.auth-sub {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 1.75rem;
  line-height: 1.5;
}

.auth-form .input-group {
  text-align: right;
  margin-bottom: 1.25rem;
}

.auth-error-msg {
  color: var(--color-red);
  font-size: 0.85rem;
  font-weight: 700;
  margin-top: 0.5rem;
}

.btn-block {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-main);
}
.btn-outline:hover {
  background: rgba(255, 255, 255, 0.08);
}

.btn-danger {
  background: var(--color-red);
  color: #fff;
  border: none;
}
.btn-danger:hover {
  background: var(--color-red-dark);
}

.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1.5rem; }
.mb-4 { margin-bottom: 1.5rem; }
.py-4 { padding-top: 1rem; padding-bottom: 1rem; }
.text-center { text-align: center; }
.text-red { color: #f87171 !important; }
.text-green { color: #4ade80 !important; }

/* Dashboard Layout */
.admin-layout {
  max-width: 1280px;
  margin: 0 auto;
  width: 100%;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  box-sizing: border-box;
}

/* Header */
.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem 1.5rem;
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
  gap: 1rem;
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.admin-logo-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--text-main);
  font-weight: 800;
  font-size: 1.3rem;
}

.logo-emoji {
  font-size: 1.6rem;
}

.admin-tag {
  background: rgba(139, 92, 246, 0.2);
  color: #c4b5fd;
  border: 1px solid rgba(139, 92, 246, 0.4);
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
}

.admin-header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.live-status-pill {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(38, 137, 12, 0.18);
  border: 1px solid rgba(38, 137, 12, 0.4);
  color: #4ade80;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-full);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 8px #22c55e;
  animation: pulse-glow 1.8s infinite;
}

@keyframes pulse-glow {
  0% { transform: scale(0.9); opacity: 0.8; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.8; }
}

.btn-action-icon {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-size: 1.1rem;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}
.btn-action-icon:hover {
  background: rgba(255, 255, 255, 0.15);
}

.btn-logout:hover {
  background: rgba(226, 27, 60, 0.3);
  border-color: var(--color-red);
}

/* Tabs */
.admin-tabs {
  display: flex;
  gap: 0.5rem;
  background: rgba(26, 34, 56, 0.6);
  border: 1px solid var(--border-color);
  padding: 0.4rem;
  border-radius: var(--radius-md);
  overflow-x: auto;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 700;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
  transition: var(--transition);
}
.tab-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}
.tab-btn.active {
  background: var(--color-blue);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.tab-badge {
  background: var(--color-red);
  color: #fff;
  font-size: 0.75rem;
  padding: 0.1rem 0.5rem;
  border-radius: var(--radius-full);
  font-weight: 800;
}

/* Tab Panels */
.tab-panel {
  display: none;
  flex-direction: column;
  gap: 1.5rem;
}
.tab-panel.active {
  display: flex;
}

/* KPI Cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 4px;
  height: 100%;
}
.kpi-purple::before { background: var(--accent-purple); }
.kpi-blue::before { background: var(--color-blue); }
.kpi-gold::before { background: var(--accent-gold); }
.kpi-green::before { background: var(--color-green); }

.kpi-icon {
  font-size: 2.2rem;
  background: rgba(255, 255, 255, 0.05);
  width: 54px;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
}

.kpi-data {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.kpi-title {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
}

.kpi-value {
  color: var(--text-main);
  font-size: 1.7rem;
  font-weight: 900;
}

/* Cards & Layouts */
.admin-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.admin-card.no-padding {
  padding: 0;
  overflow: hidden;
}

.card-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.card-heading {
  font-size: 1.15rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.overview-split-grid,
.questions-split-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 1.25rem;
}

/* Section Title Bar */
.section-title-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.section-title {
  font-size: 1.35rem;
  font-weight: 800;
  margin-bottom: 0.25rem;
}

.section-desc {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Live Rooms Grid */
.live-rooms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.25rem;
}

.live-room-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
  position: relative;
  transition: var(--transition);
}
.live-room-card:hover {
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-2px);
}

.live-room-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.75rem;
}

.live-pin-badge {
  font-family: monospace;
  font-size: 1.25rem;
  font-weight: 900;
  letter-spacing: 2px;
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.4);
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-sm);
}

.room-state-tag {
  font-size: 0.8rem;
  font-weight: 800;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-full);
}
.state-lobby { background: rgba(59, 130, 246, 0.2); color: #60a5fa; }
.state-question { background: rgba(234, 179, 8, 0.2); color: #facc15; }
.state-result { background: rgba(168, 85, 247, 0.2); color: #c084fc; }
.state-podium { background: rgba(34, 197, 94, 0.2); color: #4ade80; }

.live-room-body h4 {
  font-size: 1.1rem;
  font-weight: 800;
  margin-bottom: 0.35rem;
}

.live-room-meta {
  color: var(--text-muted);
  font-size: 0.85rem;
  display: flex;
  gap: 1rem;
}

.live-players-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.live-players-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
}

.live-players-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.player-chip {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

/* History Table */
.table-responsive {
  overflow-x: auto;
  width: 100%;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  text-align: right;
  font-size: 0.9rem;
}

.history-table th {
  background: rgba(15, 23, 42, 0.6);
  color: var(--text-muted);
  font-weight: 700;
  padding: 0.9rem 1.1rem;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.history-table td {
  padding: 0.9rem 1.1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  white-space: nowrap;
}

.history-table tr:hover td {
  background: rgba(255, 255, 255, 0.03);
}

.history-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.search-box .search-input {
  min-width: 280px;
  padding: 0.55rem 1rem;
  font-size: 0.9rem;
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.25rem;
  border-top: 1px solid var(--border-color);
  background: rgba(15, 23, 42, 0.4);
}

.pagination-info {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.pagination-buttons {
  display: flex;
  gap: 0.5rem;
}

.btn-sm {
  padding: 0.4rem 0.85rem;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
}

/* Question Analytics List */
.question-analytics-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.question-stat-item {
  background: rgba(15, 23, 42, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.question-stat-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.question-stat-text {
  font-weight: 700;
  font-size: 0.92rem;
  line-height: 1.4;
}

.accuracy-pill {
  font-weight: 800;
  font-size: 0.85rem;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-full);
  white-space: nowrap;
}
.acc-high { background: rgba(34, 197, 94, 0.2); color: #4ade80; }
.acc-mid { background: rgba(234, 179, 8, 0.2); color: #facc15; }
.acc-low { background: rgba(239, 68, 68, 0.2); color: #f87171; }

.accuracy-bar-track {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.accuracy-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
}

.question-stat-meta {
  display: flex;
  justify-content: space-between;
  color: var(--text-muted);
  font-size: 0.78rem;
}

/* Frequency Bar Charts */
.bars-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.bar-item {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.bar-item-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.88rem;
  font-weight: 700;
}

.bar-track {
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-blue), var(--accent-purple));
  border-radius: var(--radius-full);
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 26, 0.85);
  backdrop-filter: blur(8px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-card {
  background: #141b2d;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 720px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-size: 1.3rem;
  font-weight: 800;
}

.modal-subtitle {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 0.2rem;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
}
.modal-close-btn:hover { color: #fff; }

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
}

.sub-heading {
  font-size: 1.05rem;
  font-weight: 800;
  margin-bottom: 0.75rem;
}

.modal-table {
  width: 100%;
  border-collapse: collapse;
  text-align: right;
  font-size: 0.88rem;
}
.modal-table th {
  background: rgba(255, 255, 255, 0.05);
  padding: 0.65rem 0.85rem;
  color: var(--text-muted);
}
.modal-table td {
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.modal-questions-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  background: var(--bg-card);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  grid-column: 1 / -1;
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 0.75rem;
}

.loading-state {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-muted);
}

/* --- Reports & Flag Management --- */
.reports-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.filter-pill-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--transition);
}

.filter-pill-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.filter-pill-btn.active {
  background: var(--color-blue);
  color: #fff;
  border-color: var(--color-blue);
}

.reports-list-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.report-item-card {
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  transition: var(--transition);
}

.report-item-card.pending {
  border-right: 4px solid #EF4444;
}

.report-item-card.resolved {
  border-right: 4px solid #22C55E;
}

.report-item-card.dismissed {
  border-right: 4px solid #94A3B8;
  opacity: 0.85;
}

.report-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.report-meta-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.report-quiz-badge {
  background: rgba(139, 92, 246, 0.2);
  color: #C4B5FD;
  border: 1px solid rgba(139, 92, 246, 0.4);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-weight: 700;
}

.report-reason-badge {
  background: rgba(239, 68, 68, 0.2);
  color: #FCA5A5;
  border: 1px solid rgba(239, 68, 68, 0.4);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.78rem;
}

.report-status-badge {
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 700;
}

.report-status-badge.pending {
  background: rgba(234, 179, 8, 0.2);
  color: #FDE047;
  border: 1px solid rgba(234, 179, 8, 0.4);
}

.report-status-badge.resolved {
  background: rgba(34, 197, 94, 0.2);
  color: #86EFAC;
  border: 1px solid rgba(34, 197, 94, 0.4);
}

.report-status-badge.dismissed {
  background: rgba(148, 163, 184, 0.2);
  color: #CBD5E1;
  border: 1px solid rgba(148, 163, 184, 0.4);
}

.report-question-text {
  font-size: 1.05rem;
  font-weight: 800;
  color: #FFF;
  line-height: 1.4;
}

.report-options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.5rem;
}

.report-option-chip {
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
}

.report-option-chip.is-correct {
  border-color: #22C55E;
  background: rgba(34, 197, 94, 0.15);
  color: #86EFAC;
  font-weight: 700;
}

.opt-icon {
  font-size: 0.85rem;
  font-weight: 900;
}
.opt-icon-red { color: var(--color-red); }
.opt-icon-blue { color: var(--color-blue); }
.opt-icon-yellow { color: var(--color-yellow); }
.opt-icon-green { color: var(--color-green); }

.report-notes-box {
  background: rgba(239, 68, 68, 0.08);
  border: 1px dashed rgba(239, 68, 68, 0.35);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 0.85rem;
  color: #FECACA;
  line-height: 1.4;
}

.report-notes-box strong {
  color: #FFF;
}

.report-actions-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.6rem;
  flex-wrap: wrap;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 0.75rem;
}

.edit-question-card {
  max-width: 600px;
}

.edit-options-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.edit-option-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.edit-option-row input[type="radio"] {
  width: 20px;
  height: 20px;
  accent-color: #22C55E;
  cursor: pointer;
  flex-shrink: 0;
}

.opt-badge {
  font-size: 0.95rem;
  font-weight: 900;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}
.opt-red { color: var(--color-red); }
.opt-blue { color: var(--color-blue); }
.opt-yellow { color: var(--color-yellow); }
.opt-green { color: var(--color-green); }

.modal-footer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.65rem;
  margin-top: 1rem;
}

@media (max-width: 768px) {
  .admin-header {
    flex-direction: column;
    align-items: stretch;
  }
  .admin-brand {
    justify-content: space-between;
  }
  .overview-split-grid,
  .questions-split-grid {
    grid-template-columns: 1fr;
  }
  .search-box .search-input {
    min-width: 100%;
  }
  .history-controls {
    width: 100%;
  }
}
