/* ============================================
   Admin Panel - Main Stylesheet
   Express + EJS Frontend
   ============================================ */

/* CSS Variables */
:root {
  --primary-color: #6366f1;
  --primary-hover: #4f46e5;
  --primary-light: #eef2ff;
  --secondary-color: #64748b;
  --success-color: #22c55e;
  --warning-color: #f59e0b;
  --danger-color: #ef4444;
  --danger-hover: #dc2626;

  --bg-dark: #0f172a;
  --bg-sidebar: #1e293b;
  --bg-card: #ffffff;
  --bg-page: #f1f5f9;
  --bg-input: #f8fafc;

  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --text-white: #ffffff;

  --border-color: #e2e8f0;
  --border-radius: 8px;
  --border-radius-lg: 12px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);

  --sidebar-width: 256px;
  --sidebar-collapsed: 80px;
  --topbar-height: 64px;

  --transition: all 0.2s ease;
}

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

html, body {
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background-color: var(--bg-page);
}

a {
  text-decoration: none;
  color: inherit;
}

button {
  cursor: pointer;
  font-family: inherit;
}

input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

/* ============================================
   Custom Form Controls (shadcn-like)
   ============================================ */

/* Custom Select - Modern styled select */
.custom-select {
  position: relative;
  display: inline-block;
}

.custom-select select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 8px 36px 8px 12px;
  font-size: 14px;
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition);
  min-width: 140px;
  width: 100%;
}

.custom-select select:hover {
  border-color: var(--text-muted);
}

.custom-select select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.custom-select::after {
  content: '';
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 5px solid var(--text-muted);
  pointer-events: none;
}

.custom-select select:focus + .custom-select::after,
.custom-select:focus-within::after {
  border-top-color: var(--primary-color);
}

/* Dark variant for sidebar */
.custom-select.dark select {
  background-color: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.1);
  color: var(--text-white);
}

.custom-select.dark select:hover {
  background-color: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.2);
}

.custom-select.dark select:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.custom-select.dark::after {
  border-top-color: var(--text-muted);
}

.custom-select.dark select option {
  background-color: var(--bg-sidebar);
  color: var(--text-white);
}

/* Small variant */
.custom-select.sm select {
  padding: 6px 32px 6px 10px;
  font-size: 13px;
  min-width: 120px;
}

.custom-select.sm::after {
  right: 10px;
  border-left-width: 4px;
  border-right-width: 4px;
  border-top-width: 4px;
}

/* Custom Input */
.custom-input {
  display: block;
  width: 100%;
  padding: 10px 14px;
  font-size: 14px;
  color: var(--text-primary);
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  transition: var(--transition);
}

.custom-input:hover {
  border-color: var(--text-muted);
}

.custom-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.custom-input::placeholder {
  color: var(--text-muted);
}

/* Input with icon */
.input-with-icon {
  position: relative;
}

.input-with-icon .custom-input {
  padding-left: 40px;
}

.input-with-icon .input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}

/* Custom Checkbox */
.custom-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.custom-checkbox input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background-color: var(--bg-card);
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}

.custom-checkbox input[type="checkbox"]:hover {
  border-color: var(--text-muted);
}

.custom-checkbox input[type="checkbox"]:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.custom-checkbox input[type="checkbox"]:checked {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
}

.custom-checkbox input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 2px;
  width: 5px;
  height: 9px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* Custom Dropdown Menu */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: var(--transition);
  font-size: 14px;
  color: var(--text-primary);
}

.dropdown-trigger:hover {
  border-color: var(--text-muted);
  background: var(--bg-input);
}

.dropdown-trigger .chevron {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}

.dropdown.open .dropdown-trigger .chevron {
  transform: rotate(180deg);
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 180px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all 0.15s ease;
  z-index: 1000;
  overflow: hidden;
}

.dropdown.open .dropdown-menu,
.dropdown-menu.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-menu.right {
  left: auto;
  right: 0;
}

.dropdown-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  font-size: 14px;
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition);
}

.dropdown-menu-item:hover {
  background: var(--bg-input);
}

.dropdown-menu-item.active {
  background: var(--primary-light);
  color: var(--primary-color);
}

.dropdown-menu-item .item-icon {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
}

.dropdown-menu-item.active .item-icon {
  color: var(--primary-color);
}

.dropdown-menu-item .check-icon {
  margin-left: auto;
  width: 16px;
  height: 16px;
  color: var(--primary-color);
  opacity: 0;
}

.dropdown-menu-item.active .check-icon {
  opacity: 1;
}

.dropdown-menu-item.danger {
  color: var(--danger-color);
}

.dropdown-menu-item.danger .item-icon {
  color: var(--danger-color);
}

.dropdown-separator {
  height: 1px;
  background: var(--border-color);
  margin: 4px 0;
}

.dropdown-label {
  padding: 8px 14px 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Status indicator in dropdown items */
.dropdown-menu-item .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dropdown-menu-item .status-dot.live {
  background: var(--success-color);
}

.dropdown-menu-item .status-dot.staging {
  background: var(--warning-color);
}

/* ============================================
   Custom Dropdown (Full JS-controlled dropdown)
   ============================================ */
.custom-dropdown {
  position: relative;
  display: inline-block;
}

.custom-dropdown-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: var(--transition);
  font-size: 14px;
  color: var(--text-primary);
  width: 100%;
  text-align: left;
}

.custom-dropdown-trigger:hover {
  border-color: var(--text-muted);
}

.custom-dropdown-trigger:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.custom-dropdown-trigger .dropdown-value {
  flex: 1;
}

.custom-dropdown-trigger .dropdown-chevron {
  color: var(--text-muted);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.custom-dropdown.open .custom-dropdown-trigger .dropdown-chevron {
  transform: rotate(180deg);
}

.custom-dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  min-width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all 0.15s ease;
  z-index: 1000;
  overflow: hidden;
}

.custom-dropdown.open .custom-dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.custom-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  font-size: 14px;
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition);
}

.custom-dropdown-item:hover {
  background: var(--bg-input);
}

.custom-dropdown-item.active {
  background: var(--primary-light);
  color: var(--primary-color);
}

.custom-dropdown-item .check-icon {
  margin-left: auto;
  width: 16px;
  height: 16px;
  color: var(--primary-color);
  opacity: 0;
  flex-shrink: 0;
}

.custom-dropdown-item.active .check-icon {
  opacity: 1;
}

.custom-dropdown-item .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.custom-dropdown-item .status-dot.live,
.status-dot.live {
  background: var(--success-color);
}

.custom-dropdown-item .status-dot.staging,
.status-dot.staging {
  background: var(--warning-color);
}

/* Dark variant (for sidebar) */
.custom-dropdown.dark .custom-dropdown-trigger {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.1);
  color: var(--text-white);
}

.custom-dropdown.dark .custom-dropdown-trigger:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.2);
}

.custom-dropdown.dark .custom-dropdown-trigger:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.custom-dropdown.dark .custom-dropdown-trigger .dropdown-chevron {
  color: var(--text-muted);
}

.custom-dropdown.dark .custom-dropdown-menu {
  background: var(--bg-sidebar);
  border-color: rgba(255, 255, 255, 0.1);
}

.custom-dropdown.dark .custom-dropdown-item {
  color: var(--text-white);
}

.custom-dropdown.dark .custom-dropdown-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

.custom-dropdown.dark .custom-dropdown-item.active {
  background: rgba(59, 130, 246, 0.2);
  color: var(--primary-color);
}

/* Light variant (for topbar) */
.custom-dropdown.light .custom-dropdown-trigger {
  background: var(--bg-card);
  border-color: var(--border-color);
}

/* Small variant */
.custom-dropdown.sm .custom-dropdown-trigger {
  padding: 6px 10px;
  font-size: 13px;
  gap: 6px;
}

.custom-dropdown.sm .custom-dropdown-item {
  padding: 8px 10px;
  font-size: 13px;
}

.custom-dropdown.sm .dropdown-chevron {
  width: 14px;
  height: 14px;
}

/* ============================================
   Login Page
   ============================================ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--bg-dark) 0%, #1e3a5f 100%);
  padding: 20px;
}

.login-container {
  width: 100%;
  max-width: 400px;
}

.login-card {
  background: var(--bg-card);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 40px;
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--primary-color), #8b5cf6);
  border-radius: var(--border-radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}

.login-logo svg {
  width: 32px;
  height: 32px;
  color: white;
}

.login-header h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.login-header p {
  color: var(--text-secondary);
  font-size: 14px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.form-group input {
  padding: 12px 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  background: var(--bg-input);
  transition: var(--transition);
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-group input::placeholder {
  color: var(--text-muted);
}

.form-options {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.remember-me {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
}

.remember-me input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary-color);
}

.forgot-password {
  font-size: 14px;
  color: var(--primary-color);
  transition: var(--transition);
}

.forgot-password:hover {
  color: var(--primary-hover);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--border-radius);
  border: none;
  transition: var(--transition);
}

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

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

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

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

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

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

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

.btn-sm {
  padding: 8px 16px;
  font-size: 13px;
}

.btn-icon {
  padding: 8px;
  background: transparent;
  border: none;
}

.btn-icon:hover {
  background: var(--bg-input);
  border-radius: var(--border-radius);
}

.login-footer {
  margin-top: 24px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}

.error-message {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: var(--danger-color);
  padding: 12px 16px;
  border-radius: var(--border-radius);
  font-size: 14px;
  margin-bottom: 16px;
}

.btn-block {
  width: 100%;
}

.dev-credentials {
  margin-top: 24px;
  padding: 16px;
  background: var(--bg-input);
  border-radius: var(--border-radius);
  font-size: 12px;
  color: var(--text-secondary);
}

.dev-credentials p {
  margin-bottom: 4px;
}

.dev-credentials p:last-child {
  margin-bottom: 0;
}

/* ============================================
   Dashboard Layout
   ============================================ */
.dashboard {
  min-height: 100vh;
  background: var(--bg-page);
}

/* Sidebar */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: var(--transition);
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed);
}

/* Game Selector Header (new design with emoji icon) */
.game-selector-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  cursor: pointer;
  transition: var(--transition);
}

.game-selector-header:hover {
  background: rgba(255, 255, 255, 0.05);
}

.game-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.game-emoji {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  color: white;
  border-radius: 10px;
}

.game-emoji.word-blast {
  background: linear-gradient(135deg, #10b981, #059669);
}

.game-emoji.puzzle-master {
  background: linear-gradient(135deg, #f59e0b, #d97706);
}

.game-emoji.trivia-master {
  background: linear-gradient(135deg, #8b5cf6, #7c3aed);
}

.game-emoji.match-three {
  background: linear-gradient(135deg, #ec4899, #db2777);
}

.game-emoji.default {
  background: linear-gradient(135deg, var(--primary-color), #8b5cf6);
}

.game-icon-small {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
  overflow: hidden;
}

.game-icon-small.word-blast {
  background: linear-gradient(135deg, #10b981, #059669);
}

.game-icon-small.puzzle-master {
  background: linear-gradient(135deg, #f59e0b, #d97706);
}

.game-icon-small.trivia-master {
  background: linear-gradient(135deg, #8b5cf6, #7c3aed);
}

.game-icon-small.match-three {
  background: linear-gradient(135deg, #ec4899, #db2777);
}

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

.game-name {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.game-switch-label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
}

.game-chevron {
  color: var(--text-muted);
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.game-selector-header.open .game-chevron {
  transform: rotate(180deg);
}

/* Game Selector Dropdown */
.game-selector-dropdown {
  position: absolute;
  top: 73px;
  left: 8px;
  right: 8px;
  background: var(--bg-sidebar);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all 0.15s ease;
  z-index: 200;
  overflow: hidden;
}

.game-selector-dropdown.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.game-selector-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-white);
  font-size: 14px;
}

.game-selector-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

.game-selector-item.active {
  background: rgba(99, 102, 241, 0.2);
}

.game-selector-item .check-icon {
  margin-left: auto;
  color: var(--primary-color);
  opacity: 0;
}

.game-selector-item.active .check-icon {
  opacity: 1;
}

.game-selector-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
  margin: 8px 0;
}

.game-selector-item.manage-games {
  color: var(--text-muted);
  font-size: 13px;
}

.game-selector-item.manage-games:hover {
  color: var(--text-white);
}

.game-selector-item.manage-games .game-icon-small {
  background: rgba(255, 255, 255, 0.1);
}

.game-selector-item.manage-games .game-icon-small svg {
  width: 14px;
  height: 14px;
}

/* Legacy sidebar styles (keeping for compatibility) */
.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: none; /* Hidden - using game-selector-header instead */
}

.sidebar-logo {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--primary-color), #8b5cf6);
  border-radius: var(--border-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-logo svg {
  width: 20px;
  height: 20px;
  color: white;
}

.sidebar-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-white);
  white-space: nowrap;
}

/* Legacy Game Selector (keeping for compatibility) */
.game-selector,
.sidebar-game-selector {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: none; /* Hidden - using new game-selector-header */
}

.game-select {
  width: 100%;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--border-radius);
  color: var(--text-white);
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition);
}

.sidebar.collapsed .game-select {
  padding: 10px 8px;
  font-size: 0;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  margin-top: auto;
}

.sidebar-version {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.sidebar-copyright {
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.7;
}

/* Navigation */
.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
}

.nav-section {
  margin-bottom: 24px;
}

.nav-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  padding: 0 8px;
  margin-bottom: 8px;
}

.sidebar.collapsed .nav-section-title {
  display: none;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--border-radius);
  color: var(--text-muted);
  transition: var(--transition);
  margin-bottom: 4px;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-white);
}

.nav-item.active {
  background: var(--primary-color);
  color: var(--text-white);
}

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

.nav-item span {
  white-space: nowrap;
  overflow: hidden;
  transition: var(--transition);
}

.sidebar.collapsed .nav-item span {
  width: 0;
  opacity: 0;
}

.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 10px;
}

/* Sidebar Toggle */
.sidebar-toggle {
  padding: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-toggle button {
  width: 100%;
  padding: 10px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: var(--border-radius);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition);
}

.sidebar-toggle button:hover {
  background: rgba(255, 255, 255, 0.15);
  color: var(--text-white);
}

.sidebar-toggle button svg {
  width: 20px;
  height: 20px;
  transition: transform 0.2s ease;
}

.sidebar.collapsed .sidebar-toggle button svg {
  transform: rotate(180deg);
}

.sidebar-toggle button span {
  white-space: nowrap;
}

.sidebar.collapsed .sidebar-toggle button span {
  display: none;
}

/* ============================================
   Topbar
   ============================================ */
.topbar {
  position: fixed;
  top: 0;
  right: 0;
  left: var(--sidebar-width);
  height: var(--topbar-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 50;
  transition: var(--transition);
}

.sidebar.collapsed ~ .topbar {
  left: var(--sidebar-collapsed);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.env-selector {
  display: flex;
  align-items: center;
  gap: 8px;
}

.env-selector label {
  font-size: 13px;
  color: var(--text-secondary);
}

/* Environment dropdown specific styles */
.env-selector .custom-dropdown {
  min-width: 110px;
}

.env-selector .custom-dropdown-trigger {
  min-width: 110px;
}

.env-selector .custom-dropdown-trigger .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.env-selector .custom-dropdown-trigger .status-dot.live {
  background: var(--success-color);
}

.env-selector .custom-dropdown-trigger .status-dot.staging {
  background: var(--warning-color);
}

.env-select {
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  background: var(--bg-card);
  font-size: 13px;
  cursor: pointer;
  min-width: 120px;
}

.env-select:focus {
  outline: none;
  border-color: var(--primary-color);
}

.env-selector select {
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  background: var(--bg-card);
  font-size: 13px;
  cursor: pointer;
  min-width: 120px;
}

.env-selector select:focus {
  outline: none;
  border-color: var(--primary-color);
}

.env-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.env-indicator.live {
  background: var(--success-color);
}

.env-indicator.staging {
  background: var(--warning-color);
}

.env-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.env-badge.live {
  background: #dcfce7;
  color: #166534;
}

.env-badge.staging {
  background: #fef3c7;
  color: #92400e;
}

.env-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.env-badge.live::before {
  background: var(--success-color);
}

.env-badge.staging::before {
  background: var(--warning-color);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.user-menu {
  position: relative;
}

.user-menu-trigger {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: transparent;
  border: none;
  border-radius: var(--border-radius);
  transition: var(--transition);
}

.user-menu-trigger:hover {
  background: var(--bg-input);
}

.user-menu-trigger .chevron-icon {
  color: var(--text-muted);
  transition: transform 0.2s ease;
}

.user-menu.open .user-menu-trigger .chevron-icon {
  transform: rotate(180deg);
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-color), #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 14px;
  font-weight: 600;
}

.user-info {
  text-align: left;
}

.user-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.user-role {
  font-size: 12px;
  color: var(--text-muted);
}

.user-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  width: 220px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: var(--transition);
  z-index: 100;
}

.user-menu.open .user-dropdown,
.user-dropdown.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
}

.dropdown-header .user-name,
.dropdown-header .dropdown-name {
  font-size: 14px;
  font-weight: 600;
  display: block;
}

.dropdown-header .user-email,
.dropdown-header .dropdown-email {
  font-size: 12px;
  color: var(--text-muted);
  display: block;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  color: var(--text-primary);
  transition: var(--transition);
}

.dropdown-item:hover {
  background: var(--bg-input);
}

.dropdown-item svg {
  width: 18px;
  height: 18px;
  color: var(--text-secondary);
}

.dropdown-divider {
  height: 1px;
  background: var(--border-color);
  margin: 4px 0;
}

.dropdown-item.danger,
.dropdown-item.logout {
  color: var(--danger-color);
}

.dropdown-item.danger svg,
.dropdown-item.logout svg {
  color: var(--danger-color);
}

/* ============================================
   Main Content
   ============================================ */
.main-content {
  margin-left: var(--sidebar-width);
  margin-top: var(--topbar-height);
  padding: 24px;
  min-height: calc(100vh - var(--topbar-height));
  transition: var(--transition);
}

.sidebar.collapsed ~ .main-content {
  margin-left: var(--sidebar-collapsed);
}

.page-header {
  margin-bottom: 24px;
}

.page-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.page-header h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.page-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
}

/* Success button variant */
.btn-success {
  background: var(--color-success);
  color: white;
  border-color: var(--color-success);
}

.btn-success:hover {
  background: #0ca678;
  border-color: #0ca678;
}

/* Spin animation for loading states */
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.spin {
  animation: spin 1s linear infinite;
}

/* Content Cards */
.content-card {
  background: var(--bg-card);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
}

.card-header {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
  border-bottom: 1px solid var(--border-color);
}

.card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.card-body {
  padding: 20px;
}

.placeholder-text {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 20px;
}

/* ============================================
   Users Page
   ============================================ */
.users-toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.search-input {
  position: relative;
}

.search-input input {
  padding: 8px 12px 8px 36px;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  width: 280px;
  background: var(--bg-input);
}

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

.search-input svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
}

.filter-select {
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  background: var(--bg-card);
  min-width: 140px;
}

.filter-select:focus {
  outline: none;
  border-color: var(--primary-color);
}

/* Data Table */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.data-table th {
  background: var(--bg-input);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
}

.data-table tbody tr:hover {
  background: var(--bg-input);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.user-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-cell .avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-color), #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}

.user-cell .user-details {
  min-width: 0;
}

.user-cell .name {
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-cell .user-id {
  font-size: 12px;
  color: var(--text-muted);
  font-family: monospace;
}

/* Status Badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.status-badge.active {
  background: #dcfce7;
  color: #166534;
}

.status-badge.inactive {
  background: #fef3c7;
  color: #92400e;
}

.status-badge.banned {
  background: #fee2e2;
  color: #991b1b;
}

.status-badge.suspended {
  background: #fef3c7;
  color: #92400e;
}

/* Tier Badges */
.tier-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.tier-badge.free {
  background: var(--bg-input);
  color: var(--text-secondary);
}

.tier-badge.premium {
  background: #ddd6fe;
  color: #5b21b6;
}

.tier-badge.vip {
  background: #fef3c7;
  color: #92400e;
}

/* Currency Display */
.currency {
  font-family: monospace;
  font-weight: 500;
}

.currency.coins {
  color: #ca8a04;
}

.currency.gems {
  color: #7c3aed;
}

/* Actions */
.actions-cell {
  display: flex;
  align-items: center;
  gap: 4px;
}

.action-btn {
  padding: 6px;
  background: transparent;
  border: none;
  border-radius: var(--border-radius);
  color: var(--text-secondary);
  transition: var(--transition);
}

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

.action-btn.view:hover {
  color: var(--primary-color);
}

.action-btn.edit:hover {
  color: var(--warning-color);
}

.action-btn.ban:hover {
  color: var(--danger-color);
}

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

/* Pagination */
.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-top: 1px solid var(--border-color);
}

.table-info {
  font-size: 13px;
  color: var(--text-secondary);
}

.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
}

.pagination-btn {
  padding: 8px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: 13px;
  color: var(--text-primary);
  transition: var(--transition);
}

.pagination-btn:hover:not(:disabled) {
  background: var(--bg-input);
  border-color: var(--primary-color);
}

.pagination-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.pagination-btn.active {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: white;
}

/* Page Size Selector */
.page-size-selector {
  display: flex;
  align-items: center;
  gap: 8px;
}

.page-size-selector label {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.page-size-selector select {
  padding: 6px 28px 6px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: 13px;
  color: var(--text-primary);
  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='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  min-width: 70px;
}

.page-size-selector select:hover {
  border-color: var(--primary-color);
}

.page-size-selector select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.table-footer-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
}

.empty-state svg {
  width: 64px;
  height: 64px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.empty-state h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 14px;
  color: var(--text-secondary);
}

/* Loading State */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-color);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.mobile-open {
    transform: translateX(0);
  }

  .topbar {
    left: 0;
  }

  .main-content {
    margin-left: 0;
  }

  .users-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-left {
    width: 100%;
  }

  .search-input input {
    width: 100%;
  }
}

@media (max-width: 768px) {
  .data-table {
    display: block;
    overflow-x: auto;
  }

  .user-info {
    display: none;
  }

  .table-footer {
    flex-direction: column;
    gap: 16px;
  }
}

/* ============================================
   Utility Classes
   ============================================ */
.hidden {
  display: none !important;
}

.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.text-muted {
  color: var(--text-muted);
}

.text-success {
  color: var(--success-color);
}

.text-warning {
  color: var(--warning-color);
}

.text-danger {
  color: var(--danger-color);
}

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.mb-4 { margin-bottom: 24px; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 24px; }

.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 16px; }
.gap-4 { gap: 24px; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }

/* ============================================
   Pill Tabs
   ============================================ */
.tabs-pill {
  display: inline-flex;
  gap: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 9999px;
  padding: 4px;
  margin-bottom: 24px;
}

.tab-pill {
  padding: 8px 20px;
  background: transparent;
  border: none;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 9999px;
  transition: var(--transition);
}

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

.tab-pill.active {
  background: var(--bg-page);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

/* Tab Content Panels */
.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Export Button */
.btn-export {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
}

.btn-export:hover {
  background: var(--bg-input);
  border-color: var(--text-muted);
  color: var(--text-primary);
}

.search-wide {
  flex: 1;
  max-width: 400px;
}

.search-wide .custom-input {
  padding-left: 40px;
  height: 38px;
}

.toolbar-filters {
  display: flex;
  gap: 8px;
}

/* Sortable columns */
.sortable {
  cursor: pointer;
  user-select: none;
}

.sortable:hover {
  color: var(--primary-color);
}

.sort-icon {
  margin-left: 4px;
  opacity: 0.5;
  vertical-align: middle;
}

.sortable:hover .sort-icon {
  opacity: 1;
}

/* Level badge */
.level-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  padding: 4px 8px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

/* Spend colors */
.spend-positive {
  color: var(--success-color);
  font-weight: 500;
}

.spend-zero {
  color: var(--text-muted);
}

/* Action button (eye icon) */
.btn-view {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  border-radius: var(--border-radius);
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}

.btn-view:hover {
  background: var(--bg-input);
  color: var(--primary-color);
}

/* User ID styling */
.user-id {
  font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
  font-size: 13px;
  color: var(--text-secondary);
}

/* Loading & Empty states */
.loading-cell {
  text-align: center;
  padding: 40px !important;
  color: var(--text-muted);
}

.loading-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border-color);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 8px;
}

.empty-cell {
  text-align: center;
  padding: 40px !important;
  color: var(--text-muted);
}

/* ============================================
   Toggle Switch
   ============================================ */
.toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--border-color);
  transition: var(--transition);
  border-radius: 24px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: var(--transition);
  border-radius: 50%;
}

.toggle input:checked + .toggle-slider {
  background-color: var(--primary-color);
}

.toggle input:checked + .toggle-slider:before {
  transform: translateX(20px);
}

/* ============================================
   Icon Button
   ============================================ */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  border-radius: var(--border-radius);
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}

.btn-icon:hover {
  background: var(--bg-input);
  color: var(--primary-color);
}

/* ============================================
   Action Buttons Row
   ============================================ */
.action-buttons {
  display: flex;
  gap: 4px;
}

/* ============================================
   Config Actions Footer
   ============================================ */
.config-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding-top: 24px;
  border-top: 1px solid var(--border-color);
}
