@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  /* Ultra Premium SaaS Palette */
  --bg-color: #09090B;
  --card-bg: #111113;
  --surface-bg: #18181B;
  --border-color: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.12);
  
  --primary: #7C3AED;
  --primary-hover: #6D28D9;
  --primary-subtle: rgba(124, 58, 237, 0.15);
  
  --success: #22C55E;
  --success-subtle: rgba(34, 197, 94, 0.15);
  
  --danger: #EF4444;
  --danger-hover: #DC2626;
  --danger-subtle: rgba(239, 68, 68, 0.15);
  
  --warning: #F59E0B;
  --warning-subtle: rgba(245, 158, 11, 0.15);
  
  --text-main: #FFFFFF;
  --text-secondary: #A1A1AA;
  --text-muted: #71717A;
  
  /* Radii */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-pill: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5), 0 2px 4px -2px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.6), 0 4px 6px -4px rgba(0, 0, 0, 0.6);
  --shadow-glow: 0 0 20px rgba(124, 58, 237, 0.15);

  /* Spacing */
  --space-1: 8px;
  --space-2: 16px;
  --space-3: 24px;
  --space-4: 32px;
  --space-5: 48px;
  --space-6: 64px;

  --font-sans: 'Inter', -apple-system, sans-serif;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

:root[data-theme="light"] {
  --bg-color: #FAFAFA;
  --card-bg: #FFFFFF;
  --surface-bg: #F4F4F5;
  --border-color: rgba(0, 0, 0, 0.08);
  --border-hover: rgba(0, 0, 0, 0.15);
  --text-main: #09090B;
  --text-secondary: #71717A;
  --text-muted: #A1A1AA;
  
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
  --shadow-glow: 0 0 20px rgba(124, 58, 237, 0.08);
}

/* Reset & Base */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  background-color: var(--bg-color);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
button, input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; border: none; background: none; outline: none; }
button { cursor: pointer; }

/* Utilities */
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }

.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

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

.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }

.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }

.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }

.p-3 { padding: var(--space-3); }
.p-4 { padding: var(--space-4); }

.w-full { width: 100%; }
.h-full { height: 100%; }

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

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: var(--radius-pill); }

/* Animations */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.animate-fade-in { animation: fadeInUp 0.4s var(--transition-smooth) forwards; }
.delay-1 { animation-delay: 0.05s; }
.delay-2 { animation-delay: 0.1s; }
.delay-3 { animation-delay: 0.15s; }

/* App Layout */
.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--card-bg);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  transition: width var(--transition-smooth), transform var(--transition-smooth);
  z-index: 40;
}
.sidebar-header {
  height: 64px;
  padding: 0 var(--space-3);
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid transparent;
}
.brand-logo {
  width: 32px;
  height: 32px;
  background: var(--primary);
  color: white;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  box-shadow: var(--shadow-glow);
}
.brand-title {
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.sidebar-nav {
  padding: var(--space-3) var(--space-2);
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.95rem;
  transition: all var(--transition);
  position: relative;
}
.nav-item svg { width: 18px; height: 18px; stroke-width: 2px; }
.nav-item:hover {
  background: var(--surface-bg);
  color: var(--text-main);
}
.nav-item.active {
  background: var(--primary-subtle);
  color: var(--primary);
  font-weight: 600;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  height: 60%;
  width: 3px;
  background: var(--primary);
  border-radius: 0 4px 4px 0;
}

.sidebar-footer {
  padding: var(--space-3) var(--space-2);
  border-top: 1px solid var(--border-color);
}
.admin-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}
.admin-profile:hover { background: var(--surface-bg); }
.admin-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-pill);
  background: var(--border-hover);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-main);
}
.admin-info { display: flex; flex-direction: column; overflow: hidden; }
.admin-name { font-weight: 500; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.admin-role { font-size: 0.75rem; color: var(--text-secondary); }

/* Main Wrapper */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Topbar */
.topbar {
  height: 64px;
  flex-shrink: 0;
  background: var(--bg-color);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-4);
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-pill);
  padding: 6px 16px;
  width: 240px;
  transition: all var(--transition);
}
.search-bar:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-subtle);
  width: 280px;
}
.search-bar svg { color: var(--text-muted); width: 16px; height: 16px; }
.search-bar input { flex: 1; font-size: 0.9rem; color: var(--text-main); }
.search-bar input::placeholder { color: var(--text-muted); }

.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-pill);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all var(--transition);
  background: transparent;
  border: 1px solid transparent;
}
.icon-btn:hover {
  background: var(--surface-bg);
  color: var(--text-main);
  border-color: var(--border-color);
}
.icon-btn svg { width: 18px; height: 18px; }

/* Content Area */
.content-area {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4) var(--space-5);
}
.content-inner {
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

/* Page Header */
.page-header {
  margin-bottom: var(--space-4);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
}
.page-title {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 4px;
}
.page-desc {
  color: var(--text-secondary);
  font-size: 1rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--transition);
  border: 1px solid transparent;
  user-select: none;
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.1);
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(124,58,237,0.3), inset 0 1px 0 rgba(255,255,255,0.1);
}

.btn-secondary {
  background: var(--surface-bg);
  border-color: var(--border-color);
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--card-bg);
  border-color: var(--border-hover);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.btn-danger:hover:not(:disabled) {
  background: var(--danger-hover);
  box-shadow: 0 4px 12px rgba(239,68,68,0.3);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--surface-bg);
  color: var(--text-main);
}

.btn-sm { height: 32px; padding: 0 12px; font-size: 0.85rem; }
.btn-lg { height: 48px; padding: 0 24px; font-size: 1rem; border-radius: var(--radius-md); }

/* KPI Cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.kpi-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  transition: all var(--transition-smooth);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}
.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 2px;
  background: var(--border-hover);
  transition: background var(--transition-smooth);
}
.kpi-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.kpi-card:hover::before { background: var(--primary); }

.kpi-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-2);
}
.kpi-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.kpi-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--surface-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}
.kpi-icon svg { width: 16px; height: 16px; }
.kpi-value {
  font-size: 2.25rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 4px;
  line-height: 1.1;
}
.kpi-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Panels */
.panel {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--space-4);
  display: flex;
  flex-direction: column;
}
.panel-head {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.panel-title {
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.panel-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-top: 2px;
}
.panel-body { padding: var(--space-4); }
.panel-body.no-pad { padding: 0; }

/* Leaderboard */
.leaderboard-row {
  display: flex;
  align-items: center;
  padding: 12px var(--space-4);
  border-bottom: 1px solid var(--border-color);
  transition: background var(--transition);
}
.leaderboard-row:hover { background: var(--surface-bg); }
.leaderboard-row:last-child { border-bottom: none; }
.rank-badge {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-pill);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  background: var(--surface-bg);
  color: var(--text-secondary);
  margin-right: 16px;
}
.rank-1 { background: rgba(234, 179, 8, 0.15); color: #EAB308; box-shadow: 0 0 10px rgba(234, 179, 8, 0.2); }
.rank-2 { background: rgba(148, 163, 184, 0.15); color: #94A3B8; }
.rank-3 { background: rgba(180, 83, 9, 0.15); color: #B45309; }

.wallet-address {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.95rem;
  color: var(--text-main);
  flex: 1;
}
.rank-1 + .wallet-address { color: var(--primary); font-weight: 600; }

.ticket-bar-container {
  width: 120px;
  height: 6px;
  background: var(--border-color);
  border-radius: var(--radius-pill);
  overflow: hidden;
  margin-right: 16px;
}
.ticket-bar {
  height: 100%;
  background: var(--primary);
  border-radius: var(--radius-pill);
}
.ticket-count {
  font-weight: 600;
  font-size: 1.05rem;
  min-width: 60px;
  text-align: right;
}

/* Forms & Inputs (Floating Labels) */
.form-group {
  position: relative;
  margin-bottom: var(--space-3);
}
.form-control {
  width: 100%;
  background: var(--surface-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 24px 12px 8px; /* Space for floating label */
  color: var(--text-main);
  font-size: 0.95rem;
  transition: all var(--transition);
}
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-subtle);
  background: var(--bg-color);
}
textarea.form-control {
  min-height: 120px;
  resize: vertical;
}
.form-label {
  position: absolute;
  left: 13px;
  top: 16px;
  font-size: 0.95rem;
  color: var(--text-secondary);
  pointer-events: none;
  transition: all var(--transition);
  transform-origin: left top;
}
/* Floating state */
.form-control:focus ~ .form-label,
.form-control:not(:placeholder-shown) ~ .form-label {
  top: 6px;
  font-size: 0.75rem;
  color: var(--primary);
  font-weight: 500;
}
.form-control:not(:focus):not(:placeholder-shown) ~ .form-label {
  color: var(--text-secondary);
}

.file-drop-area {
  border: 2px dashed var(--border-hover);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  text-align: center;
  transition: all var(--transition);
  cursor: pointer;
  background: var(--surface-bg);
  position: relative;
  overflow: hidden;
}
.file-drop-area:hover, .file-drop-area.dragover {
  border-color: var(--primary);
  background: var(--primary-subtle);
}
.file-drop-area input[type="file"] {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  opacity: 0; cursor: pointer;
}
.file-drop-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.file-drop-content svg {
  width: 32px; height: 32px; color: var(--text-secondary);
}
.img-preview {
  width: 100%;
  height: 200px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  border: 1px solid var(--border-color);
  margin-top: 12px;
}

/* Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}
.table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}
.table th {
  padding: 14px var(--space-4);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  background: var(--surface-bg);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 10;
}
.table td {
  padding: 16px var(--space-4);
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}
.table tbody tr { transition: background var(--transition); }
.table tbody tr:hover { background: var(--surface-bg); }
.table tr:last-child td { border-bottom: none; }
.img-thumb {
  width: 48px;
  height: 36px;
  border-radius: 4px;
  object-fit: cover;
  border: 1px solid var(--border-color);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.badge-success { background: var(--success-subtle); color: var(--success); }
.badge-danger { background: var(--danger-subtle); color: var(--danger); }
.badge-warning { background: var(--warning-subtle); color: var(--warning); }
.badge-neutral { background: var(--surface-bg); color: var(--text-secondary); border: 1px solid var(--border-color); }

/* Flashes */
.flash {
  padding: 16px;
  border-radius: var(--radius-md);
  margin-bottom: var(--space-3);
  font-size: 0.9rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 12px;
  animation: fadeInUp 0.3s ease-out forwards;
}
.flash.success { background: var(--success-subtle); color: var(--success); border: 1px solid rgba(34,197,94,0.2); }
.flash.error { background: var(--danger-subtle); color: var(--danger); border: 1px solid rgba(239,68,68,0.2); }

/* Auth Layout */
.auth-layout {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  background: var(--bg-color);
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  box-shadow: var(--shadow-lg);
  animation: fadeInUp 0.5s var(--transition-smooth) forwards;
}
.auth-header {
  text-align: center;
  margin-bottom: var(--space-4);
}
.auth-logo {
  width: 56px;
  height: 56px;
  margin: 0 auto 24px;
  background: var(--primary);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 800;
  box-shadow: var(--shadow-glow);
}
.auth-title {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 8px;
}
.auth-subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

/* Grids */
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

.layout-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--space-4);
}

/* Responsive */
@media (max-width: 1024px) {
  .sidebar {
    position: fixed;
    top: 0; left: 0; height: 100%;
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }
  .layout-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .topbar { padding: 0 var(--space-3); }
  .content-area { padding: var(--space-3); }
  .page-header { flex-direction: column; gap: var(--space-2); align-items: flex-start; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .search-bar { width: 180px; }
  .search-bar:focus-within { width: 200px; }
}
