@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg-primary: #080c14;
  --bg-secondary: #0e1626;
  --bg-card: #131d31;
  --bg-card-hover: #19263f;
  --bg-elevated: #1b2840;
  --border: #1c2d45;
  --border-light: #243852;
  --accent: #0088cc;
  --accent-soft: rgba(0, 136, 204, 0.1);
  --accent-glow: rgba(0, 136, 204, 0.2);
  --gold: #f5a623;
  --gold-soft: rgba(245, 166, 35, 0.12);
  --silver: #9ba8b8;
  --bronze: #cd7f4a;
  --text-primary: #e2e8f0;
  --text-secondary: #8899b4;
  --text-muted: #4d5e78;
  --success: #10b981;
  --error: #ef4444;
  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 4px 16px rgba(0, 0, 0, 0.3);
  --font-sans: 'Plus Jakarta Sans', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(0, 136, 204, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 136, 204, 0.025) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
  z-index: 0;
}

body::after {
  content: '';
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(ellipse at 30% 20%, rgba(0, 136, 204, 0.06) 0%, transparent 60%),
              radial-gradient(ellipse at 70% 80%, rgba(245, 166, 35, 0.03) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

.container {
  position: relative;
  z-index: 1;
  max-width: 820px;
  margin: 0 auto;
  padding: 32px 20px;
}

/* Header */
header {
  text-align: center;
  margin-bottom: 40px;
  padding: 32px 0 24px;
  position: relative;
}

header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  border-radius: 2px;
}

header h1 {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 6px;
}

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

/* Card */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0.3;
}

.card:hover {
  border-color: var(--border-light);
  box-shadow: var(--shadow);
}

.card h2 {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card h2 .badge {
  font-size: 11px;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 2px 10px;
  border-radius: 20px;
  border: 1px solid rgba(0, 136, 204, 0.2);
}

/* Form */
.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-secondary);
  letter-spacing: 0.3px;
  text-transform: uppercase;
  font-size: 11px;
}

input[type="text"],
input[type="file"],
textarea {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

input[type="text"]:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

input[type="text"]::placeholder,
textarea::placeholder {
  color: var(--text-muted);
}

textarea {
  resize: vertical;
  min-height: 72px;
}

input[type="file"] {
  padding: 10px;
  cursor: pointer;
}

input[type="file"]::file-selector-button {
  padding: 6px 14px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-xs);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  margin-right: 12px;
  transition: opacity var(--transition);
}

input[type="file"]::file-selector-button:hover {
  opacity: 0.85;
}

/* Buttons */
button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  position: relative;
  overflow: hidden;
}

button::after, .btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, transparent 50%);
  pointer-events: none;
}

button:hover, .btn:hover {
  background: #0099e6;
  transform: translateY(-1px);
  box-shadow: 0 4px 16px var(--accent-glow);
}

button:active, .btn:active {
  transform: translateY(0);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-sm {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}

.btn-sm:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--border-light);
}

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

.btn-outline:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: none;
}

/* API Key Display */
.api-key-display {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}

.api-key-display code {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent);
  word-break: break-all;
  letter-spacing: 0.3px;
}

/* Stats */
.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0.4;
}

.stat-card:hover {
  border-color: var(--border-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.stat-card .stat-icon {
  font-size: 24px;
  margin-bottom: 8px;
  display: block;
}

.stat-number {
  display: block;
  font-size: 32px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -1px;
  line-height: 1.1;
}

.stat-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Tables */
.table-wrapper {
  overflow-x: auto;
  margin: 0 -4px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

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

th {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding-top: 0;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: rgba(0, 136, 204, 0.03);
}

td code {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent);
}

.status-success {
  color: var(--success);
  font-weight: 600;
}

.status-pending {
  color: var(--warning);
  font-weight: 600;
}

.status-error {
  color: var(--error);
  font-weight: 600;
}

/* Leaderboard */
.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.leaderboard-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  animation: slideIn 0.3s ease both;
}

.leaderboard-item:hover {
  border-color: var(--border-light);
  background: var(--bg-card-hover);
}

.leaderboard-item.is-me {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.leaderboard-rank {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
  background: var(--bg-card);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.leaderboard-rank.gold {
  background: linear-gradient(135deg, #f5a623, #e08e00);
  color: #fff;
  border-color: #f5a623;
  box-shadow: 0 0 12px var(--gold-soft);
}

.leaderboard-rank.silver {
  background: linear-gradient(135deg, #9ba8b8, #7a8797);
  color: #fff;
  border-color: #9ba8b8;
}

.leaderboard-rank.bronze {
  background: linear-gradient(135deg, #cd7f4a, #b06a38);
  color: #fff;
  border-color: #cd7f4a;
}

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

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

.leaderboard-name.is-me-name {
  color: var(--accent);
}

.leaderboard-name .you-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 1px 8px;
  border-radius: 10px;
  margin-left: 6px;
  border: 1px solid rgba(0, 136, 204, 0.2);
}

.leaderboard-detail {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.leaderboard-stat {
  text-align: right;
  flex-shrink: 0;
}

.leaderboard-stat .lb-count {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.leaderboard-stat .lb-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* Animations */
@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

.fade-in {
  animation: fadeIn 0.4s ease both;
}

/* Loading state */
.loading-dots::after {
  content: '';
  animation: loadingDots 1.5s infinite;
}

@keyframes loadingDots {
  0% { content: ''; }
  25% { content: '.'; }
  50% { content: '..'; }
  75% { content: '...'; }
}

/* Alert messages */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 16px;
  animation: slideIn 0.3s ease;
}

.alert-error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: var(--error);
}

.alert-success {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.2);
  color: var(--success);
}

/* Actions row */
.actions {
  margin-top: 16px;
  display: flex;
  gap: 10px;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 36px;
  margin-bottom: 12px;
  display: block;
  opacity: 0.5;
}

.empty-state p {
  font-size: 13px;
}

/* Upload form extra */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 32px 16px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  margin-bottom: 16px;
}

.upload-area:hover,
.upload-area.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.upload-area .upload-icon {
  font-size: 32px;
  margin-bottom: 8px;
  display: block;
}

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

.upload-area .upload-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Sections inline toggle */
.section-toggle {
  font-size: 12px;
  color: var(--accent);
  cursor: pointer;
  font-weight: 600;
  background: none;
  border: none;
  font-family: var(--font-sans);
  padding: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.section-toggle:hover {
  text-decoration: underline;
}

/* Upload tabs */
.upload-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  padding: 4px;
  border: 1px solid var(--border);
}

.upload-tab {
  flex: 1;
  padding: 8px 16px;
  background: transparent;
  color: var(--text-muted);
  border: none;
  border-radius: var(--radius-xs);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all var(--transition);
}

.upload-tab.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px var(--accent-glow);
}

.upload-tab:hover:not(.active) {
  color: var(--text-secondary);
  background: var(--bg-card-hover);
}

/* File tree */
.file-tree {
  max-height: 280px;
  overflow-y: auto;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 4px;
  font-size: 12px;
  font-family: var(--font-mono);
}

.file-tree-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border-radius: var(--radius-xs);
  color: var(--text-secondary);
  transition: background var(--transition);
}

.file-tree-item:hover {
  background: var(--bg-card-hover);
}

.file-tree-item .ft-icon {
  flex-shrink: 0;
  width: 16px;
  text-align: center;
}

.file-tree-item .ft-path {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-tree-item .ft-size {
  color: var(--text-muted);
  font-size: 11px;
  flex-shrink: 0;
}

.file-tree-folder {
  font-weight: 600;
  color: var(--text-primary);
  font-family: var(--font-sans);
}

.file-tree-folder .ft-icon {
  font-size: 14px;
}

/* Progress bar */
.progress-bar-track {
  width: 100%;
  height: 6px;
  background: var(--bg-secondary);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 8px;
  border: 1px solid var(--border);
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #00aaff);
  border-radius: 3px;
  transition: width 0.3s ease;
  box-shadow: 0 0 8px var(--accent-glow);
}

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

/* Batch results */
.batch-results {
  max-height: 200px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.batch-result-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--bg-secondary);
  border-radius: var(--radius-xs);
  font-size: 12px;
  animation: slideIn 0.2s ease both;
}

.batch-result-item .br-icon {
  flex-shrink: 0;
}

.batch-result-item .br-file {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-secondary);
}

.batch-result-item .br-msg {
  flex-shrink: 0;
  font-size: 11px;
}

.batch-result-item.success .br-msg {
  color: var(--success);
}

.batch-result-item.error .br-msg {
  color: var(--error);
}

/* Mobile */
@media (max-width: 600px) {
  .container {
    padding: 16px 12px;
  }

  header {
    margin-bottom: 24px;
    padding: 20px 0 16px;
  }

  header h1 {
    font-size: 24px;
  }

  .card {
    padding: 20px;
  }

  .stats {
    gap: 10px;
  }

  .stat-card {
    padding: 16px;
  }

  .stat-number {
    font-size: 26px;
  }

  .leaderboard-item {
    padding: 10px 12px;
  }

  .leaderboard-rank {
    width: 28px;
    height: 28px;
    font-size: 11px;
  }
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

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

::-webkit-scrollbar-thumb:hover {
  background: var(--border-light);
}
