/* ============================================
   Poudlard RP Staff Manager - CSS
   Modern, Clean, Responsive Design
   ============================================ */

/* CSS Variables */
:root {
  /* Colors */
  --bg-primary: #0f0f14;
  --bg-secondary: #16161d;
  --bg-tertiary: #1c1c26;
  --surface: #22222e;
  --surface-hover: #2a2a38;
  --border: #2d2d3a;
  --border-light: #3a3a4a;
  
  --text-primary: #f5f5f7;
  --text-secondary: #a1a1aa;
  --text-tertiary: #71717a;
  
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-soft: rgba(99, 102, 241, 0.15);
  
  --green: #22c55e;
  --green-soft: rgba(34, 197, 94, 0.15);
  --red: #ef4444;
  --red-soft: rgba(239, 68, 68, 0.15);
  --yellow: #eab308;
  --yellow-soft: rgba(234, 179, 8, 0.15);
  
  /* Heatmap */
  --heatmap-0: #1c1c26;
  --heatmap-1: #1e4620;
  --heatmap-2: #2a6f2f;
  --heatmap-3: #3d9140;
  --heatmap-4: #22c55e;
  
  /* Fonts */
  --font-main: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  
  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  
  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 9999px;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);
  
  /* Layout */
  --sidebar-width: 260px;
  --header-height: 60px;
  --nav-height: 70px;
  
  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
}

/* Light Theme */
[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;
  --surface: #ffffff;
  --surface-hover: #f8fafc;
  --border: #e2e8f0;
  --border-light: #cbd5e1;
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-tertiary: #94a3b8;
  
  --heatmap-0: #f1f5f9;
  --heatmap-1: #bbf7d0;
  --heatmap-2: #86efac;
  --heatmap-3: #4ade80;
  --heatmap-4: #22c55e;
  
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
}

/* Reset */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-main);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  overflow-x: hidden;
}

/* App Layout */
.app {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
}

/* ============================================
   Sidebar (Desktop)
   ============================================ */

.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-lg);
  border-bottom: 1px solid var(--border);
}

.sidebar-logo {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
}

.sidebar-title {
  display: flex;
  flex-direction: column;
}

.title-main {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-primary);
}

.title-sub {
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

.sidebar-server {
  padding: var(--space-md) var(--space-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-tertiary);
  margin: var(--space-md);
  border-radius: var(--radius-lg);
}

.server-status {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-tertiary);
  animation: pulse 2s infinite;
}

.server-status.online .status-dot {
  background: var(--green);
}

.sidebar-server .count-number {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
}

.server-status.offline .status-dot {
  background: var(--red);
  animation: none;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.status-text {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.join-server-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  margin: 0 var(--space-md);
  padding: var(--space-md);
  background: linear-gradient(135deg, #1b2838 0%, #2a475e 100%);
  color: #66c0f4;
  text-decoration: none;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.85rem;
  transition: all var(--transition-fast);
  border: 1px solid #66c0f4;
}

.join-server-btn:hover {
  background: linear-gradient(135deg, #2a475e 0%, #3d6a8a 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 192, 244, 0.3);
}

.join-server-btn svg {
  width: 18px;
  height: 18px;
}

/* Light theme pour join-server-btn */
[data-theme="light"] .join-server-btn {
  background: linear-gradient(135deg, #171a21 0%, #1b2838 100%);
  color: #fff;
  border-color: #2a475e;
  box-shadow: 0 2px 8px rgba(27, 40, 56, 0.2);
}

[data-theme="light"] .join-server-btn:hover {
  background: linear-gradient(135deg, #1b2838 0%, #2a475e 100%);
  box-shadow: 0 4px 16px rgba(27, 40, 56, 0.3);
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  font-weight: 500;
  font-size: 0.9rem;
}

.nav-link svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.nav-link:hover {
  background: var(--surface);
  color: var(--text-primary);
}

.nav-link.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.nav-badge {
  margin-left: auto;
  padding: 2px 8px;
  background: var(--surface);
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
}

.nav-link.active .nav-badge {
  background: var(--accent);
  color: white;
}

.sidebar-footer {
  padding: var(--space-lg);
  border-top: 1px solid var(--border);
}

.theme-btn {
  width: 100%;
  padding: var(--space-md);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.theme-btn:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.theme-btn svg {
  width: 20px;
  height: 20px;
}

.icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: block; }

/* ============================================
   Main Content
   ============================================ */

.main {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.mobile-header {
  display: none;
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 0 var(--space-md);
  align-items: center;
  justify-content: space-between;
  z-index: 100;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.header-logo {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
}

.header-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.live-indicator {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 6px 12px;
  background: var(--green-soft);
  border-radius: var(--radius-full);
  transition: all var(--transition-fast);
}

.live-indicator.offline {
  background: var(--red-soft);
}

.live-dot {
  width: 8px;
  height: 8px;
  background: var(--green);
  border-radius: 50%;
  animation: pulse 2s ease-in-out infinite;
}

.live-indicator.offline .live-dot {
  background: var(--red);
  animation: none;
}

.live-count {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--green);
}

.live-indicator.offline .live-count {
  color: var(--red);
}

/* Mobile Navigation - Fixed Bottom Bar */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  z-index: 100;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.mobile-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 4px;
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: 0.65rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: color var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.mobile-nav-item svg {
  width: 24px;
  height: 24px;
  stroke-width: 1.75;
}

.mobile-nav-item.active {
  color: var(--accent);
}

.mobile-nav-item:active {
  transform: scale(0.95);
}

.content {
  flex: 1;
  padding: var(--space-xl);
  overflow-y: auto;
  overflow-x: hidden;
}

/* ============================================
   Pages
   ============================================ */

.page {
  display: none;
  max-width: 100%;
  overflow-x: hidden;
}

.page.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
  gap: var(--space-md);
}

.page-title {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-primary);
  display: flex;
  align-items: center;
}

.page-subtitle {
  color: var(--text-tertiary);
  font-size: 0.9rem;
  margin-bottom: var(--space-lg);
}

/* ============================================
   Cards
   ============================================ */

.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border);
}

.card-header h2 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* ============================================
   Dashboard
   ============================================ */

.dashboard-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-md);
}

.stat-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.stat-icon {
  font-size: 1.5rem;
}

.stat-content {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
  gap: 2px;
}

.stat-value {
  display: block;
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
}

.stat-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-tertiary);
  line-height: 1.2;
}

.stat-sublabel {
  display: block;
  font-size: 0.65rem;
  color: var(--text-tertiary);
  opacity: 0.7;
  line-height: 1.2;
}

.dashboard-main {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.dashboard-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-lg);
}

.dashboard-sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

/* Chart */
.card-chart {
  width: 100%;
}

.chart-info {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  font-weight: 500;
}

.chart-container {
  padding: var(--space-lg);
  padding-bottom: var(--space-sm);
  height: 180px;
  display: flex;
  align-items: flex-end;
  gap: 4px;
}

.chart-bar {
  flex: 1;
  background: var(--accent);
  border-radius: 4px 4px 0 0;
  min-height: 4px;
  transition: all var(--transition-fast);
  cursor: pointer;
  position: relative;
}

.chart-bar:hover {
  background: var(--accent-hover);
  transform: scaleY(1.05);
  transform-origin: bottom;
}

.chart-bar.current {
  background: var(--green);
}

.chart-bar.current:hover {
  background: #34d399;
}

.chart-bar.future {
  background: var(--border);
  opacity: 0.5;
}

.chart-bar .chart-tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-primary);
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-fast);
  z-index: 10;
  pointer-events: none;
}

.chart-bar:hover .chart-tooltip {
  opacity: 1;
  visibility: visible;
}

.chart-tooltip-time {
  color: var(--text-tertiary);
  display: block;
}

.chart-tooltip-value {
  color: var(--accent);
  font-weight: 700;
}

.chart-labels {
  display: flex;
  padding: 0 var(--space-lg) var(--space-md);
  gap: 4px;
}

.chart-label {
  flex: 1;
  text-align: center;
  font-size: 0.6rem;
  color: var(--text-tertiary);
}

/* Server Info */
.card-server .server-info {
  padding: var(--space-lg);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-lg);
}

.server-detail {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.detail-label {
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

.detail-value {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.9rem;
}

.detail-value code {
  background: var(--surface);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

/* Quick Stats */
.quick-stats {
  padding: var(--space-lg);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-md);
  text-align: center;
}

.quick-stat {
  display: flex;
  flex-direction: column;
}

.qs-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-primary);
}

.qs-label {
  font-size: 0.7rem;
  color: var(--text-tertiary);
}

/* Header Time */
.header-time {
  font-size: 0.9rem;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
}

/* Live Players */
.live-badge {
  padding: 4px 12px;
  background: var(--green);
  color: white;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  min-width: 32px;
  text-align: center;
}

.live-players-wrapper {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.live-players {
  padding: var(--space-md);
  padding-bottom: var(--space-lg);
  flex: 1;
  overflow-y: auto;
}

/* Fade indicator when more content below */
.live-players-wrapper::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 40px;
  background: linear-gradient(to top, var(--bg-secondary) 0%, transparent 100%);
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-fast);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.live-players-wrapper.can-scroll-down::after {
  opacity: 1;
}

/* Custom scrollbar for live players */
.live-players::-webkit-scrollbar {
  width: 6px;
}

.live-players::-webkit-scrollbar-track {
  background: transparent;
}

.live-players::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.live-players::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

/* Firefox scrollbar */
.live-players {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.live-player {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.live-player:hover {
  background: var(--surface);
}

.player-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: white;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.player-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.player-avatar.online {
  box-shadow: 0 0 0 3px var(--green);
}

.player-info {
  flex: 1;
  min-width: 0;
}

.player-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-role {
  font-size: 0.75rem;
  font-weight: 500;
}

.player-time {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--green);
  font-family: var(--font-mono);
}

/* Chart */
.card-chart {
  grid-column: span 2;
}

.chart-container {
  padding: var(--space-lg);
  height: 150px;
  display: flex;
  align-items: flex-end;
  gap: 4px;
}

.chart-bar {
  flex: 1;
  background: var(--accent);
  border-radius: 3px 3px 0 0;
  min-height: 4px;
  transition: all var(--transition-fast);
  position: relative;
}

.chart-bar:hover {
  background: var(--accent-hover);
}

/* Player List */
.player-list {
  padding: var(--space-md);
}

.player-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.player-item:hover {
  background: var(--surface);
}

.rank-badge {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  background: var(--surface);
  color: var(--text-secondary);
}

.rank-badge.gold { background: linear-gradient(135deg, #ffd700, #ffb700); color: #000; }
.rank-badge.silver { background: linear-gradient(135deg, #c0c0c0, #a0a0a0); color: #000; }
.rank-badge.bronze { background: linear-gradient(135deg, #cd7f32, #b87333); color: #fff; }

/* ============================================
   Players Page
   ============================================ */

.filters-bar {
  display: flex;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
}

.search-box {
  flex: 1;
  min-width: 200px;
  position: relative;
}

.search-box > svg:first-of-type {
  position: absolute;
  left: var(--space-md);
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-tertiary);
  pointer-events: none;
}

.search-box input {
  width: 100%;
  padding: var(--space-md);
  padding-left: calc(var(--space-md) * 2 + 18px);
  padding-right: calc(var(--space-md) + 28px);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: var(--font-main);
}

.search-box input:focus {
  outline: none;
  border-color: var(--accent);
}

.search-box input::placeholder {
  color: var(--text-tertiary);
}

.search-clear {
  position: absolute;
  right: var(--space-sm);
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  padding: 0;
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}

.search-clear svg {
  width: 16px;
  height: 16px;
  position: static;
  transform: none;
}

.search-clear:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.search-box input:not(:placeholder-shown) + .search-clear {
  display: flex;
}

.filter-tabs {
  display: flex;
  gap: var(--space-xs);
  background: var(--bg-secondary);
  padding: var(--space-xs);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.filter-tab {
  padding: var(--space-sm) var(--space-md);
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  font-family: var(--font-main);
  white-space: nowrap;
}

.filter-tab:hover {
  color: var(--text-primary);
}

.filter-tab.active {
  background: var(--accent);
  color: white;
}

.players-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-md);
}

.player-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.player-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.player-card .player-avatar {
  width: 48px;
  height: 48px;
  font-size: 1rem;
}

.player-roles {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.role-tag {
  padding: 2px 8px;
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: var(--radius-full);
}

.player-status {
  margin-left: auto;
}

.online-badge {
  padding: 4px 10px;
  background: var(--green);
  color: white;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--radius-full);
}

/* Sort Controls */
.sort-controls {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.sort-select {
  padding: var(--space-sm) var(--space-md);
  padding-right: calc(var(--space-md) + 20px);
  background: transparent;
  border: none;
  border-right: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-family: var(--font-main);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  min-width: 130px;
}

.sort-select:focus {
  outline: none;
}

.sort-select option {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.sort-order-btn {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.sort-order-btn:hover {
  background: var(--surface-hover);
  color: var(--accent);
}

.sort-order-btn svg {
  width: 18px;
  height: 18px;
}

.sort-order-btn .sort-asc {
  display: block;
}

.sort-order-btn .sort-desc {
  display: none;
}

.sort-order-btn.desc .sort-asc {
  display: none;
}

.sort-order-btn.desc .sort-desc {
  display: block;
}

/* Pagination Wrapper - Fixed container that spans content area, ALWAYS visible */
.pagination-wrapper {
  position: fixed;
  bottom: var(--space-lg);
  left: var(--sidebar-width);
  right: 0;
  display: flex;
  justify-content: center;
  pointer-events: none;
  z-index: 50;
  /* NO visibility hidden - wrapper is always present to prevent layout shift */
}

/* Pagination - Hidden by default with display none */
.pagination {
  display: none; /* Changed from flex - prevents any space being taken */
  justify-content: center;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
}

/* Only show pagination when parent wrapper has active class AND pagination has visible class */
.pagination-wrapper.active .pagination.visible {
  display: flex;
}

/* Space for fixed pagination on players page */
#page-players {
  padding-bottom: 100px;
}

.pagination-nav {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: var(--font-main);
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.pagination-nav:hover:not(:disabled) {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.pagination-nav:active:not(:disabled) {
  transform: scale(0.95);
}

.pagination-nav:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.pagination-pages {
  display: flex;
  gap: var(--space-xs);
  overflow: hidden;
}

.pagination-btn {
  min-width: 36px;
  height: 36px;
  padding: 0 var(--space-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: var(--font-main);
}

.pagination-btn:hover:not(.pagination-ellipsis) {
  background: var(--surface);
  color: var(--text-primary);
}

.pagination-btn.active {
  background: var(--accent);
  color: white;
  font-weight: 600;
}

.pagination-ellipsis {
  cursor: default;
  opacity: 0.5;
}

.pagination-info {
  color: var(--text-tertiary);
  font-size: 0.8rem;
  white-space: nowrap;
  min-width: 90px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.pagination-range {
  display: inline-block;
  min-width: 50px;
  text-align: right;
}

/* ============================================
   Scan Page - New Design
   ============================================ */

.scan-phase {
  max-width: 900px;
  margin: 0 auto;
}

.scan-main-card {
  margin-bottom: var(--space-lg);
}

.scan-main-card .card-header,
.scan-ingame-card .card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.btn-paste {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-paste:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.btn-paste svg {
  width: 18px;
  height: 18px;
}

.scan-ingame-card {
  margin-bottom: var(--space-lg);
}

.scan-ingame-body {
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.scan-ingame-help {
  font-size: 0.85rem;
  color: var(--text-tertiary);
  margin: 0;
}

.scan-ingame-body input {
  width: 100%;
  padding: var(--space-md);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.scan-ingame-body input:focus {
  outline: none;
  border-color: var(--accent);
}

.scan-ingame-body input::placeholder {
  color: var(--text-tertiary);
  font-size: 0.75rem;
}

.scan-main-body {
  padding: var(--space-xl);
}

.scan-main-body textarea {
  width: 100%;
  min-height: 300px;
  padding: var(--space-lg);
  background: var(--bg-tertiary);
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  resize: vertical;
  transition: border-color var(--transition-fast);
}

.scan-main-body textarea:focus {
  outline: none;
  border-color: var(--accent);
  border-style: solid;
}

.scan-main-body textarea::placeholder {
  color: var(--text-tertiary);
}

.scan-main-actions {
  margin-top: var(--space-lg);
  display: flex;
  justify-content: center;
}

.btn-lg {
  padding: var(--space-md) var(--space-xl);
  font-size: 1rem;
}

.scan-help-section {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  border: 1px solid var(--border);
}

.scan-help-section h3 {
  font-size: 1rem;
  margin-bottom: var(--space-md);
  color: var(--text-primary);
}

.scan-help-steps {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.scan-help-step {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) 0;
}

.scan-help-step .step-num {
  width: 24px;
  height: 24px;
  background: var(--accent);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.scan-help-step code {
  background: var(--bg-tertiary);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  color: var(--accent);
}

/* Scan Results Phase */
.scan-results-card {
  min-height: 500px;
  display: flex;
  flex-direction: column;
}

.scan-results-card .card-header {
  border-bottom: 1px solid var(--border);
}

.badge-lg {
  padding: 6px 14px;
  font-size: 0.9rem;
}

.scan-results-body {
  flex: 1;
  padding: var(--space-lg);
  overflow-y: auto;
  max-height: 60vh;
}

.scan-results-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

/* Scan Player Card */
.scan-player-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
}

.scan-player-card.is-new {
  border-left: 4px solid var(--green);
}

.scan-player-card.is-existing {
  opacity: 0.85;
}

.scan-player-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  background: var(--bg-tertiary);
}

.scan-player-info {
  min-width: 0;
  flex: 1;
}

.scan-player-name {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.scan-player-meta {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 0.75rem;
  color: var(--text-tertiary);
  flex-wrap: wrap;
}

.scan-player-steam {
  font-family: var(--font-mono);
}

.scan-player-tag {
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 600;
}

.scan-player-tag.new {
  background: var(--green-soft);
  color: var(--green);
}

.scan-player-tag.existing {
  background: var(--accent-soft);
  color: var(--accent);
}

.scan-player-tag.merged {
  background: var(--yellow-soft);
  color: var(--yellow);
}

.scan-player-tag.renamed {
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  color: var(--accent);
}

.scan-player-rename-info {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin-top: var(--space-xs);
}

.scan-player-rename-info strong {
  color: var(--text-secondary);
}

.scan-expand-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.scan-expand-btn:hover {
  background: var(--surface);
  color: var(--text-primary);
}

.scan-expand-btn svg {
  width: 20px;
  height: 20px;
}

/* Roles chips */
.scan-player-roles {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--border);
}

.scan-role-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.scan-role-chip:hover {
  border-color: var(--text-tertiary);
}

.scan-role-chip.selected {
  font-weight: 600;
}

.scan-role-chip input[type="checkbox"] {
  display: none;
}

/* Rôles en lecture seule (joueurs existants) */
.scan-player-roles.readonly {
  background: var(--bg-primary);
  align-items: center;
}

.scan-role-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid;
}

.scan-roles-locked {
  font-size: 0.7rem;
  color: var(--text-tertiary);
  margin-left: auto;
}

/* Ingame names section */
.scan-ingame-section {
  padding: var(--space-sm) var(--space-lg);
  border-top: 1px solid var(--border);
  background: var(--bg-primary);
}

.scan-ingame-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-sm);
}

.scan-ingame-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.scan-ingame-add-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-tertiary);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.scan-ingame-add-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.scan-ingame-add-btn svg {
  width: 14px;
  height: 14px;
}

.scan-ingame-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  min-height: 24px;
}

.scan-ingame-empty {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  font-style: italic;
}

.scan-ingame-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 500;
}

.scan-ingame-tag button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  background: transparent;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  opacity: 0.7;
}

.scan-ingame-tag button:hover {
  opacity: 1;
}

.scan-ingame-add-form {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
}

.scan-ingame-add-form input {
  flex: 1;
  padding: var(--space-xs) var(--space-sm);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.85rem;
}

.scan-ingame-add-form input:focus {
  outline: none;
  border-color: var(--accent);
}

.scan-ingame-add-form button {
  padding: var(--space-xs) var(--space-md);
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
}

.scan-ingame-add-form button:hover {
  background: var(--accent-hover);
}

.scan-player-current-role {
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 500;
  text-align: center;
}

.scan-results-footer {
  display: flex;
  justify-content: space-between;
  gap: var(--space-md);
  padding: var(--space-lg);
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
}

/* ============================================
   Roles Page
   ============================================ */

.roles-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.role-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: all var(--transition-fast);
}

.role-item:hover {
  border-color: var(--border-light);
}

.role-item.dragging {
  opacity: 0.5;
}

.role-item.drag-over {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.role-handle {
  cursor: grab;
  color: var(--text-tertiary);
}

.role-handle:active {
  cursor: grabbing;
}

.role-handle svg {
  width: 18px;
  height: 18px;
}

.role-color {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  flex-shrink: 0;
}

.role-info {
  flex: 1;
}

.role-name {
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.role-staff-badge {
  font-size: 0.7rem;
  padding: 2px 8px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: var(--radius-full);
  font-weight: 500;
}

.role-count {
  font-size: 0.8rem;
  color: var(--text-tertiary);
}

/* Checkbox label style for forms */
.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  cursor: pointer;
  padding: var(--space-md);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  transition: all var(--transition-fast);
}

.checkbox-label:hover {
  border-color: var(--accent);
}

.checkbox-label input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin-top: 2px;
  accent-color: var(--accent);
  cursor: pointer;
}

.checkbox-text {
  flex: 1;
}

.checkbox-text strong {
  display: block;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.checkbox-text small {
  color: var(--text-tertiary);
  font-size: 0.85rem;
}

.role-actions {
  display: flex;
  gap: var(--space-sm);
}

.role-action-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.role-action-btn:hover {
  background: var(--surface);
  color: var(--text-primary);
}

.role-action-btn.delete:hover {
  background: var(--red-soft);
  color: var(--red);
}

.role-action-btn svg {
  width: 16px;
  height: 16px;
}

/* ============================================
   Stats Page
   ============================================ */

.stats-page-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}

.stat-big-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.stat-big-content {
  order: 2;
}

.stat-big-value {
  display: block;
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
  order: 1;
  margin-bottom: var(--space-sm);
}

.stat-big-label {
  display: block;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.stat-big-date {
  display: block;
  font-size: 0.8rem;
  color: var(--text-tertiary);
  margin-top: var(--space-xs);
}

/* Heatmap Card */
.heatmap-card .card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.heatmap-period-select {
  padding: var(--space-xs) var(--space-md);
  padding-right: calc(var(--space-md) + 16px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.8rem;
  font-family: var(--font-main);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}

.heatmap-period-select:focus {
  outline: none;
  border-color: var(--accent);
}

.heatmap-period-label {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  font-weight: 400;
}

/* Desktop: show single heatmap, hide mobile stack */
.heatmap-desktop {
  display: block;
}

.heatmaps-mobile {
  display: none;
}

/* Heatmap */
.heatmap-wrapper {
  padding: var(--space-lg);
  overflow-x: auto;
}

.heatmap {
  display: grid;
  grid-template-columns: 40px repeat(24, 1fr);
  gap: 3px;
  min-width: 400px;
}

.heatmap-row {
  display: contents;
}

.heatmap-label {
  font-size: 0.7rem;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: var(--space-sm);
}

.heatmap-hour {
  font-size: 0.6rem;
  color: var(--text-tertiary);
  text-align: center;
}

.heatmap-cell {
  aspect-ratio: 1;
  border-radius: 3px;
  background: var(--heatmap-0);
  min-width: 12px;
  min-height: 12px;
  transition: transform var(--transition-fast);
}

.heatmap-cell:hover {
  transform: scale(1.2);
  z-index: 1;
}

.heatmap-cell.level-1 { background: var(--heatmap-1); }
.heatmap-cell.level-2 { background: var(--heatmap-2); }
.heatmap-cell.level-3 { background: var(--heatmap-3); }
.heatmap-cell.level-4 { background: var(--heatmap-4); }

.heatmap-legend {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

.legend-scale {
  display: flex;
  gap: 3px;
}

.legend-item {
  width: 14px;
  height: 14px;
  border-radius: 3px;
}

/* ============================================
   Settings Page
   ============================================ */

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--space-lg);
}

.settings-info {
  padding: var(--space-lg);
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-sm) 0;
}

.info-row:not(:last-child) {
  border-bottom: 1px solid var(--border);
}

.info-label {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.info-value {
  font-weight: 600;
  color: var(--text-primary);
}

.info-value code, code.info-value {
  background: var(--surface);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.status-online {
  color: var(--green);
}

.status-offline {
  color: var(--red);
}

.settings-actions {
  padding: var(--space-lg);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
}

/* Zone dangereuse */
.card-danger {
  border: 1px solid var(--red);
  border-left: 3px solid var(--red);
}

.card-danger .card-header h2 {
  color: var(--red);
}

.settings-danger {
  padding: var(--space-lg);
}

.danger-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-lg);
}

.danger-info {
  flex: 1;
}

.danger-info strong {
  display: block;
  margin-bottom: var(--space-xs);
  color: var(--text-primary);
}

.danger-info p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin: 0;
}

/* ============================================
   Buttons
   ============================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-lg);
  font-size: 0.9rem;
  font-weight: 600;
  font-family: var(--font-main);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  border: none;
  text-decoration: none;
}

.btn svg {
  width: 18px;
  height: 18px;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--surface-hover);
  border-color: var(--border-light);
}

.btn-danger {
  background: var(--red);
  color: white;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-full {
  width: 100%;
}

/* ============================================
   Modal
   ============================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-normal);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 550px;
  max-height: 95vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: scale(0.95);
  transition: transform var(--transition-normal);
  position: relative;
}

.modal-overlay.active .modal {
  transform: scale(1);
}

/* Drag Handle - Hidden on desktop */
.modal-handle {
  display: none;
}

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

.modal-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.modal-close:hover {
  background: var(--surface);
  color: var(--text-primary);
}

.modal-close svg {
  width: 20px;
  height: 20px;
}

.modal-body {
  padding: var(--space-md) var(--space-lg);
  overflow-y: auto;
}

/* Custom scrollbar for modal */
.modal-body::-webkit-scrollbar {
  width: 8px;
}

.modal-body::-webkit-scrollbar-track {
  background: transparent;
}

.modal-body::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

/* Firefox scrollbar */
.modal-body {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

/* Form Elements */
.form-group {
  margin-bottom: var(--space-md);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
}

.label-hint {
  font-weight: 400;
  color: var(--text-tertiary);
  font-size: 0.7rem;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group select {
  width: 100%;
  padding: var(--space-md);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: var(--font-main);
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--accent);
}

.form-group input[readonly] {
  background: var(--surface);
  color: var(--text-secondary);
  cursor: not-allowed;
  opacity: 0.7;
}

.form-group input[type="color"] {
  width: 100%;
  height: 44px;
  padding: 4px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
}

.form-actions {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-md);
}

.form-actions .btn-danger {
  margin-right: auto;
}

/* Roles Selector */
.roles-selector {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.role-checkbox {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 0.85rem;
}

.role-checkbox:hover {
  border-color: var(--role-color, var(--accent));
}

.role-checkbox.selected {
  background: color-mix(in srgb, var(--role-color, var(--accent)) 20%, transparent);
  border-color: var(--role-color, var(--accent));
}

.role-checkbox input {
  display: none;
}

.role-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

/* Ingame Names */
.ingame-names-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  margin-bottom: var(--space-sm);
}

.ingame-name-item {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs);
  background: var(--surface);
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
}

.ingame-name-item:first-child {
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
}

.ingame-name-order {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.btn-order {
  width: 20px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 0;
  border-radius: 3px;
  transition: all var(--transition-fast);
}

.btn-order:hover:not(:disabled) {
  background: var(--bg-tertiary);
  color: var(--accent);
}

.btn-order:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.btn-order svg {
  width: 12px;
  height: 12px;
}

.ingame-name-rank {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-tertiary);
  min-width: 24px;
  text-align: center;
}

.ingame-name-item:first-child .ingame-name-rank {
  color: var(--accent);
}

.ingame-name-item input {
  flex: 1;
  padding: var(--space-xs) var(--space-sm);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-family: var(--font-main);
}

.ingame-name-item input:focus {
  outline: none;
  border-color: var(--accent);
}

.btn-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-icon.btn-delete:hover {
  background: var(--red-soft);
  color: var(--red);
}

.btn-icon svg {
  width: 14px;
  height: 14px;
}

.btn-sm {
  padding: var(--space-xs) var(--space-md);
  font-size: 0.8rem;
}

/* Copy Link */
.copy-link {
  display: flex;
  gap: var(--space-sm);
}

.copy-link input {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

/* Avatar in Modal */
.modal-avatar {
  width: 72px;
  height: 72px;
  margin: 0 auto var(--space-md);
  border-radius: 50%;
  overflow: hidden;
}

.modal-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Modal Warning */
.modal-warning {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--yellow-soft);
  border: 1px solid var(--yellow);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-md);
}

.modal-warning .warning-icon {
  font-size: 1rem;
  flex-shrink: 0;
}

.modal-warning strong {
  display: block;
  color: var(--yellow);
  font-size: 0.85rem;
  margin-bottom: 2px;
}

.modal-warning p {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin: 0;
}

.modal-warning code {
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

/* Player Stats Grid */
.player-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-tertiary);
  border-radius: var(--radius-lg);
}

.player-stat {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs);
}

.player-stat .stat-icon {
  font-size: 1rem;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border-radius: var(--radius-md);
  flex-shrink: 0;
}

.player-stat .stat-value {
  display: block;
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.85rem;
}

.player-stat .stat-label {
  display: block;
  font-size: 0.65rem;
  color: var(--text-tertiary);
  margin-top: 1px;
}

/* ============================================
   Toast
   ============================================ */

.toast-container {
  position: fixed;
  bottom: calc(var(--nav-height) + var(--space-lg));
  right: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  z-index: 1100;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s ease;
  max-width: 350px;
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.toast-icon svg {
  width: 20px;
  height: 20px;
}

.toast.success .toast-icon { color: var(--green); }
.toast.error .toast-icon { color: var(--red); }
.toast.info .toast-icon { color: var(--accent); }

.toast-message {
  font-size: 0.9rem;
  color: var(--text-primary);
}

/* ============================================
   Empty State
   ============================================ */

.empty-state {
  text-align: center;
  padding: var(--space-2xl);
  color: var(--text-tertiary);
}

.empty-icon {
  font-size: 2.5rem;
  margin-bottom: var(--space-md);
  display: block;
}

.empty-state p {
  font-size: 0.9rem;
}

/* Badge */
.badge {
  padding: 4px 10px;
  background: var(--surface);
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}


/* ============================================
   Responsive Styles - Mobile First
   ============================================ */

/* ===========================================
   MOBILE (max-width: 1024px) - Tablets & Phones
   =========================================== */
@media (max-width: 1024px) {
  /* Hide sidebar, show mobile nav */
  .sidebar {
    display: none;
  }
  
  .main {
    margin-left: 0;
    padding-top: 0;
  }
  
  .mobile-header {
    display: flex;
  }
  
  .mobile-nav {
    display: flex;
  }
  
  .content {
    padding: var(--space-md);
    padding-top: var(--space-md);
    padding-bottom: calc(var(--nav-height) + var(--space-lg) + env(safe-area-inset-bottom, 0px));
    min-height: calc(100vh - var(--header-height));
    min-height: calc(100dvh - var(--header-height));
  }
  
  /* Dashboard */
  .dashboard-grid {
    display: flex;
    flex-direction: column;
  }
  
  .stats-row {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-sm);
  }
  
  .dashboard-cols {
    grid-template-columns: 1fr;
  }
  
  .dashboard-sidebar {
    order: -1;
  }
  
  .dashboard-sidebar .card-live .live-players {
    max-height: 200px;
  }
  
  .card-server .server-info {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .header-time {
    display: none;
  }
  
  /* Scan */
  .scan-container {
    grid-template-columns: 1fr;
  }
  
  .scan-input-card {
    grid-row: auto;
  }
  
  /* Players */
  .players-grid {
    grid-template-columns: 1fr;
  }
  
  .filters-bar {
    flex-wrap: wrap;
  }
  
  .filter-tabs {
    display: flex;
    flex-wrap: nowrap;
    padding: var(--space-xs);
    gap: var(--space-xs);
    flex: 1;
  }
  
  .filter-tab {
    flex: 1;
    text-align: center;
    justify-content: center;
    min-width: 0;
  }
  
  .sort-controls {
    border-radius: var(--radius-md);
  }
  
  .sort-order-btn {
    width: 44px;
    height: 44px;
  }
  
  /* Players page needs extra space for fixed pagination */
  #page-players {
    padding-bottom: 80px;
  }
  
  #page-players .players-grid {
    padding-bottom: 0;
  }
  
  /* Pagination tablet - wrapper repositioned */
  .pagination-wrapper {
    left: 0;
    right: 0;
    bottom: calc(var(--nav-height) + var(--space-lg) + env(safe-area-inset-bottom, 0px));
    padding: 0 var(--space-md);
  }
  
  .pagination {
    width: 100%;
  }
  
  /* Toast */
  .toast-container {
    left: var(--space-md);
    right: var(--space-md);
    bottom: calc(var(--nav-height) + var(--space-md) + env(safe-area-inset-bottom, 0px));
  }
  
  .toast {
    max-width: none;
  }
  
  /* Bottom Sheet Modal - Mobile & Tablet */
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }
  
  .modal {
    max-height: 92vh;
    max-width: 100%;
    width: 100%;
    margin: 0;
    border-radius: 20px 20px 0 0;
    border-bottom: none;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  }
  
  .modal-overlay.active .modal {
    transform: translateY(0);
  }
  
  /* Drag handle visible on mobile */
  .modal-handle {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 12px 0 8px;
    cursor: grab;
    touch-action: none;
  }
  
  .modal-handle:active {
    cursor: grabbing;
  }
  
  .modal-handle-bar {
    width: 40px;
    height: 4px;
    background: var(--border-light);
    border-radius: 2px;
  }
  
  .modal-header {
    padding: var(--space-md) var(--space-lg);
  }
  
  .modal-body {
    padding: var(--space-md) var(--space-lg);
    padding-bottom: calc(var(--space-lg) + env(safe-area-inset-bottom, 20px));
    max-height: calc(92vh - 120px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  /* Form actions stacked */
  .form-actions {
    flex-direction: column-reverse;
    gap: var(--space-sm);
  }
  
  .form-actions .btn {
    width: 100%;
    justify-content: center;
    padding: var(--space-md);
  }
  
  .form-actions .btn-danger {
    margin-right: 0;
    order: 1;
  }
}

/* ===========================================
   SMALL MOBILE (max-width: 640px) - Phones
   =========================================== */
@media (max-width: 640px) {
  .content {
    padding: var(--space-sm);
    padding-bottom: calc(var(--nav-height) + var(--space-md));
  }
  
  /* Prevent horizontal overflow on pages */
  .page {
    overflow-x: hidden;
    max-width: 100%;
  }
  
  .page-title {
    font-size: 1.35rem;
  }
  
  /* Stats Row - More compact */
  .stats-row {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  
  .stat-card {
    padding: var(--space-sm) var(--space-md);
    gap: var(--space-sm);
  }
  
  .stat-icon {
    font-size: 1.2rem;
  }
  
  .stat-value {
    font-size: 1.35rem;
  }
  
  .stat-label {
    font-size: 0.65rem;
  }
  
  .stat-sublabel {
    display: none;
  }
  
  /* Filters */
  .filters-bar {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-sm);
  }
  
  .search-box {
    min-width: 100%;
    width: 100%;
  }
  
  .filter-tabs {
    display: flex;
    flex-wrap: nowrap;
    padding: var(--space-xs);
    gap: var(--space-xs);
    width: 100%;
  }
  
  .filter-tab {
    flex: 1;
    padding: var(--space-sm) var(--space-xs);
    font-size: 0.7rem;
    white-space: nowrap;
    text-align: center;
    justify-content: center;
    min-width: 0;
  }
  
  .sort-controls {
    width: 100%;
    border-radius: var(--radius-md);
  }
  
  .sort-select {
    flex: 1;
    padding: var(--space-md);
    font-size: 0.9rem;
    min-width: 0;
  }
  
  .sort-order-btn {
    width: 52px;
    height: 52px;
  }
  
  .sort-order-btn svg {
    width: 20px;
    height: 20px;
  }
  
  /* Pagination mobile - wrapper repositioned */
  .pagination-wrapper {
    bottom: calc(var(--nav-height) + var(--space-lg) + env(safe-area-inset-bottom, 0px));
    padding: 0 var(--space-sm);
  }
  
  .pagination {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    gap: var(--space-xs);
  }
  
  #page-players {
    padding-bottom: 100px;
  }
  
  .pagination-nav {
    width: 44px;
    height: 44px;
    font-size: 1.2rem;
  }
  
  .pagination-pages {
    flex: 1;
    justify-content: center;
    overflow-x: auto;
    scrollbar-width: none;
  }
  
  .pagination-pages::-webkit-scrollbar {
    display: none;
  }
  
  .pagination-btn {
    min-width: 32px;
    height: 32px;
    font-size: 0.8rem;
  }
  
  .pagination-info {
    display: none;
  }
  
  /* Page header */
  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-sm);
  }
  
  .page-header .btn {
    width: 100%;
    justify-content: center;
  }
  
  .players-grid {
    gap: var(--space-sm);
  }
  
  .player-card {
    padding: var(--space-md);
  }
  
  /* Cards */
  .card {
    margin-bottom: var(--space-sm);
  }
  
  .card-header {
    padding: var(--space-sm) var(--space-md);
  }
  
  .card-header h2 {
    font-size: 0.9rem;
  }
  
  /* Stats Page - Compact horizontal cards */
  #page-stats {
    overflow-x: hidden;
  }
  
  .stats-page-grid {
    grid-template-columns: 1fr;
    gap: 8px;
    margin-bottom: var(--space-md);
  }
  
  .stat-big-card {
    padding: var(--space-sm) var(--space-md);
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
  }
  
  .stat-big-content {
    order: 1;
    flex: 1;
    min-width: 0;
    text-align: left;
  }
  
  .stat-big-value {
    font-size: 1.5rem;
    order: 2;
    margin-bottom: 0;
    flex-shrink: 0;
  }
  
  .stat-big-label {
    font-size: 0.85rem;
  }
  
  .stat-big-date {
    font-size: 0.7rem;
    opacity: 0.7;
  }
  
  /* Heatmap - Compact for mobile */
  .heatmap-desktop {
    display: none;
  }
  
  .heatmaps-mobile {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
  }
  
  .heatmap-period-select {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    font-size: 0.85rem;
  }
  
  .card {
    overflow: hidden;
  }
  
  .heatmap-wrapper {
    padding: var(--space-sm);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .heatmap {
    min-width: 340px;
    gap: 2px;
    grid-template-columns: 22px repeat(24, 1fr);
  }
  
  .heatmap-cell {
    min-width: 4px;
    min-height: 4px;
    border-radius: 1px;
  }
  
  .heatmap-label {
    font-size: 0.45rem;
    padding-right: 4px;
  }
  
  .heatmap-hour {
    font-size: 0.35rem;
  }
  
  .heatmap-legend {
    padding: var(--space-xs) var(--space-sm);
    gap: 4px;
    font-size: 0.6rem;
    justify-content: center;
    flex-wrap: wrap;
  }
  
  /* Settings */
  .settings-grid {
    grid-template-columns: 1fr;
  }
  
  /* Quick stats */
  .quick-stats {
    grid-template-columns: repeat(3, 1fr);
    padding: var(--space-md);
    gap: var(--space-sm);
  }
  
  .qs-value {
    font-size: 1.25rem;
  }
  
  .qs-label {
    font-size: 0.6rem;
  }
  
  .card-server .server-info {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
    padding: var(--space-md);
  }
  
  /* Smaller modal on phones */
  .modal-header {
    padding: var(--space-sm) var(--space-lg);
  }
  
  /* Player stats in modal - compact */
  .player-stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-sm);
    padding: var(--space-sm);
  }
  
  .player-stat {
    padding: var(--space-xs);
  }
  
  .player-stat .stat-icon {
    width: 28px;
    height: 28px;
    font-size: 1rem;
  }
  
  .player-stat .stat-value {
    font-size: 0.85rem;
  }
  
  .player-stat .stat-label {
    font-size: 0.6rem;
  }
  
  /* Form row stacked on mobile */
  .form-row {
    grid-template-columns: 1fr;
    gap: var(--space-sm);
  }
  
  /* Roles selector compact */
  .roles-selector {
    max-height: 120px;
    overflow-y: auto;
  }
  
  .role-checkbox {
    font-size: 0.8rem;
    padding: 6px 10px;
  }
  
  /* Modal avatar */
  .modal-avatar {
    width: 64px;
    height: 64px;
  }
}

/* ===========================================
   TABLET (641px - 1024px)
   =========================================== */
@media (min-width: 641px) and (max-width: 1024px) {
  .stats-row {
    grid-template-columns: repeat(4, 1fr);
  }
  
  .dashboard-cols {
    grid-template-columns: 1fr 1fr;
  }
  
  .players-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .scan-container {
    grid-template-columns: 1fr 280px;
  }
}

/* ===========================================
   DESKTOP (min-width: 1025px)
   =========================================== */
@media (min-width: 1025px) {
  .mobile-nav,
  .mobile-header {
    display: none;
  }
  
  .toast-container {
    bottom: var(--space-lg);
  }
  
  /* Desktop Dashboard Layout */
  .dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 320px;
    grid-template-rows: auto minmax(0, 1fr);
    gap: var(--space-lg);
  }
  
  .stats-row {
    grid-column: 1 / -1;
    grid-template-columns: repeat(4, 1fr);
  }
  
  .dashboard-main {
    grid-column: 1;
    grid-row: 2;
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
  }
  
  .dashboard-sidebar {
    grid-column: 2;
    grid-row: 2;
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
    min-height: 0;
    overflow: hidden;
    align-self: stretch;
  }
  
  .dashboard-sidebar .card-live {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  
  .dashboard-sidebar .card-live .live-players-wrapper {
    flex: 1 1 0;
    min-height: 0;
    overflow: hidden;
  }
  
  .dashboard-sidebar .card-live .live-players {
    height: 100%;
    max-height: none;
    overflow-y: auto;
  }
  
  /* Stats rapides - taille fixe en bas */
  .dashboard-sidebar > .card:last-child {
    flex: 0 0 auto;
  }
  
  .dashboard-cols {
    grid-template-columns: 1fr 1fr;
  }
  
  .scan-container {
    grid-template-columns: 1fr 350px;
  }
}

/* End of stylesheet */
