/* ═══════════════════════════════════════════════
   Electrico Studios — Core Styles
   Dark analytics dashboard with glowing accents
   ═══════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;0,9..40,800&family=JetBrains+Mono:wght@400;600&display=swap');

:root {
  /* Backgrounds */
  --bg-deep: #06060b;
  --bg-base: #0b0b12;
  --bg-surface: rgba(140, 160, 255, 0.05);
  --bg-surface-hover: rgba(140, 160, 255, 0.09);
  --bg-surface-active: rgba(140, 160, 255, 0.13);

  /* Text */
  --text-primary: #eaebf0;
  --text-secondary: #9a9db0;
  --text-muted: #5c5f73;

  /* Accent */
  --accent: #4d7cff;
  --accent-glow: rgba(77, 124, 255, 0.25);
  --accent-hover: #6690ff;

  /* Semantic */
  --green: #22c97a;
  --green-dim: rgba(34, 201, 122, 0.12);
  --red: #e04858;
  --red-dim: rgba(224, 72, 88, 0.12);
  --amber: #e8a830;
  --amber-dim: rgba(232, 168, 48, 0.12);

  /* Borders */
  --border: rgba(140, 160, 255, 0.07);
  --border-hover: rgba(140, 160, 255, 0.14);

  /* Misc */
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
  --font: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: 'JetBrains Mono', monospace;
}

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

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

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

/* Subtle background texture */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 20% 10%, rgba(77, 124, 255, 0.03), transparent),
    radial-gradient(ellipse 60% 50% at 80% 90%, rgba(34, 201, 122, 0.02), transparent);
  pointer-events: none;
  z-index: 0;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
img { display: block; max-width: 100%; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(140, 160, 255, 0.12); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(140, 160, 255, 0.2); }

/* ═══════════════════════════════════════════════
   LAYOUT
   ═══════════════════════════════════════════════ */

.app { position: relative; z-index: 1; }

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ── Navbar ── */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(6, 6, 11, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
}

.navbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  height: 56px;
  gap: 32px;
}

.logo {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text-primary);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
}
.logo-mark {
  width: 24px;
  height: 24px;
  background: var(--accent);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  color: #fff;
}
.logo span { color: var(--accent); }

.nav-links {
  display: flex;
  gap: 4px;
  list-style: none;
}
.nav-links a {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.87rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: all 0.15s;
}
.nav-links a:hover, .nav-links a.active {
  color: var(--text-primary);
  background: var(--bg-surface);
}
.nav-links a.active { color: var(--accent); }

/* ── Search Bar (Navbar) ── */
.nav-search {
  flex: 1;
  max-width: 400px;
  position: relative;
}
.nav-search input {
  width: 100%;
  padding: 8px 14px 8px 36px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.87rem;
  outline: none;
  transition: all 0.2s;
}
.nav-search input::placeholder { color: var(--text-muted); }
.nav-search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.nav-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 14px;
  pointer-events: none;
}

/* Search dropdown */
.search-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: 400px;
  overflow-y: auto;
  display: none;
  z-index: 200;
}
.search-dropdown.open { display: block; }
.search-result {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background 0.12s;
}
.search-result:hover { background: var(--bg-surface-hover); }
.search-result-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  object-fit: cover;
  flex-shrink: 0;
}
.search-result-info { flex: 1; min-width: 0; }
.search-result-name {
  font-size: 0.87rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-result-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.search-result-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 99px;
  flex-shrink: 0;
}
.search-result-badge.tracked { background: var(--green-dim); color: var(--green); }
.search-result-badge.untracked { background: var(--bg-surface); color: var(--text-muted); }

.search-section-label {
  padding: 8px 14px 4px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  font-size: 0.8rem;
  color: var(--text-secondary);
  white-space: nowrap;
}
.nav-user-dot {
  width: 7px;
  height: 7px;
  background: var(--green);
  border-radius: 50%;
  animation: pulse-dot 2s infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ═══════════════════════════════════════════════
   COMPONENTS
   ═══════════════════════════════════════════════ */

/* ── Auth Screen ── */
.auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  flex-direction: column;
  gap: 20px;
}
.auth-box {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 380px;
  text-align: center;
}
.auth-box h1 {
  font-size: 1.3rem;
  font-weight: 800;
  margin-bottom: 6px;
}
.auth-box p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 24px;
}
.auth-box input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--mono);
  font-size: 0.87rem;
  outline: none;
  margin-bottom: 14px;
}
.auth-box input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.87rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-ghost {
  background: var(--bg-surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-surface-hover); color: var(--text-primary); }
.btn-sm { padding: 6px 12px; font-size: 0.78rem; }
.btn-danger { background: var(--red-dim); color: var(--red); }
.btn-danger:hover { background: rgba(224, 72, 88, 0.2); }

/* ── Stat Cards ── */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  text-align: center;
  transition: all 0.2s;
}
.stat-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-1px);
}
.stat-card-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.stat-card-value {
  font-size: 1.6rem;
  font-weight: 800;
  font-feature-settings: 'tnum';
  letter-spacing: -0.5px;
}

/* ── Tables ── */
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 3px;
}
.data-table th {
  padding: 8px 16px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  text-align: left;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.data-table th:hover { color: var(--text-secondary); }
.data-table th.sorted { color: var(--accent); }
.data-table th .sort-arrow { font-size: 10px; margin-left: 3px; }

.data-table td {
  padding: 14px 16px;
  font-size: 0.87rem;
  background: var(--bg-surface);
  vertical-align: middle;
}
.data-table tr td:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.data-table tr td:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.data-table tbody tr {
  cursor: pointer;
  transition: all 0.12s;
}
.data-table tbody tr:hover td { background: var(--bg-surface-hover); }

/* ── Developer Row Elements ── */
.dev-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}
.dev-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface-active);
  object-fit: cover;
  flex-shrink: 0;
}
.dev-name {
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dev-username {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.dev-tags {
  display: flex;
  gap: 4px;
  margin-top: 2px;
}
.tag {
  font-size: 0.62rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 99px;
  background: var(--accent-glow);
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.rank-cell {
  font-weight: 800;
  color: var(--text-muted);
  font-size: 0.93rem;
  min-width: 36px;
  text-align: center;
}

.rank-change {
  font-size: 0.78rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 2px;
}
.rank-change.up { color: var(--green); }
.rank-change.down { color: var(--red); }
.rank-change.same { color: var(--text-muted); }

/* ── CCU Colors ── */
.ccu-high { color: var(--green) !important; }
.ccu-mid { color: var(--amber) !important; }
.ccu-low { color: var(--text-muted) !important; }

.stat-value {
  font-weight: 700;
  font-feature-settings: 'tnum';
}

/* ── Rating Bar ── */
.rating-bar {
  width: 60px;
  height: 5px;
  background: var(--red);
  border-radius: 3px;
  overflow: hidden;
  display: inline-block;
  vertical-align: middle;
  margin-left: 6px;
}
.rating-bar-fill {
  height: 100%;
  background: var(--green);
  border-radius: 3px;
}

/* ── Section Headers ── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 16px;
  flex-wrap: wrap;
}
.section-title {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.3px;
}
.section-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Toolbar ── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.toolbar-group {
  display: flex;
  align-items: center;
  gap: 3px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3px;
}
.toolbar-btn {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  transition: all 0.12s;
}
.toolbar-btn:hover { color: var(--text-primary); background: var(--bg-surface-hover); }
.toolbar-btn.active { background: var(--accent); color: #fff; }

.toolbar-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-right: 4px;
  padding-left: 8px;
}

/* ── Activity Feed ── */
.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius);
  transition: background 0.12s;
}
.activity-item:hover { background: var(--bg-surface); }
.activity-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}
.activity-icon.added { background: var(--green-dim); }
.activity-icon.spike { background: var(--amber-dim); }
.activity-icon.drop { background: var(--red-dim); }
.activity-icon.game { background: var(--accent-glow); }
.activity-icon.peak { background: var(--green-dim); }
.activity-icon.note { background: var(--bg-surface-active); }

.activity-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.45;
}
.activity-text strong { color: var(--text-primary); font-weight: 700; }
.activity-time {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Page Header ── */
.page-header {
  padding: 32px 0 24px;
}
.page-title {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}
.page-desc {
  font-size: 0.87rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── Loading ── */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 0;
  gap: 14px;
  color: var(--text-muted);
  font-size: 0.87rem;
}
.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Empty State ── */
.empty {
  text-align: center;
  padding: 60px 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.empty-big { font-size: 2rem; margin-bottom: 8px; }

/* ── Charts ── */
.chart-container {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.chart-title {
  font-size: 0.87rem;
  font-weight: 700;
}

/* ── Pagination ── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-top: 24px;
}
.pagination button {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-secondary);
  transition: all 0.12s;
}
.pagination button:hover { background: var(--bg-surface-hover); color: var(--text-primary); }
.pagination button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }

/* ═══════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════ */

@media (max-width: 768px) {
  .navbar-inner { gap: 12px; }
  .nav-links { display: none; }
  .nav-search { max-width: 100%; }
  .container { padding: 0 16px; }
  .stat-cards { grid-template-columns: repeat(2, 1fr); }
  .data-table { font-size: 0.8rem; }
  .data-table td, .data-table th { padding: 10px 10px; }
  .page-title { font-size: 1.3rem; }
  .dev-avatar { width: 32px; height: 32px; }
}

/* ── Animations ── */
@keyframes fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fade-in 0.3s ease-out; }

@keyframes flash-green {
  0% { color: #4afa9a; text-shadow: 0 0 8px rgba(34,201,122,0.5); }
  100% { text-shadow: none; }
}
@keyframes flash-red {
  0% { color: #ff6b7a; text-shadow: 0 0 8px rgba(224,72,88,0.5); }
  100% { text-shadow: none; }
}
.flash-up { animation: flash-green 1.5s ease-out; }
.flash-down { animation: flash-red 1.5s ease-out; }
