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

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

:root {
  --bg-primary:    #0a0e1a;
  --bg-secondary:  #0f1524;
  --bg-card:       rgba(255,255,255,0.04);
  --bg-card-hover: rgba(255,255,255,0.07);
  --border:        rgba(255,255,255,0.08);
  --border-hover:  rgba(255,255,255,0.15);

  --accent:        #6c63ff;
  --accent-2:      #00d4aa;
  --accent-3:      #ff6b6b;
  --accent-4:      #ffd93d;

  --text-primary:  #f0f4ff;
  --text-secondary:#8892a4;
  --text-muted:    #4a5568;

  --green:  #00d4aa;
  --red:    #ff6b6b;
  --yellow: #ffd93d;
  --purple: #6c63ff;
  --blue:   #4dabf7;

  --sidebar-width: 260px;
  --header-height: 72px;
  --radius:  16px;
  --radius-sm: 8px;
  --shadow:  0 4px 24px rgba(0,0,0,0.4);
  --shadow-glow: 0 0 30px rgba(108,99,255,0.15);
}

html, body {
  height: 100%;
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow-x: hidden;
  font-size: 14px;
  line-height: 1.6;
}

/* ── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

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

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar-logo {
  padding: 24px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}

.logo-icon {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  box-shadow: 0 4px 16px rgba(108,99,255,0.4);
  flex-shrink: 0;
}

.logo-text { font-size: 16px; font-weight: 700; color: var(--text-primary); line-height: 1.2; }
.logo-sub  { font-size: 11px; color: var(--text-secondary); font-weight: 400; }

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

.nav-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 12px 8px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 500;
  border: 1px solid transparent;
  user-select: none;
}

.nav-item:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: rgba(108,99,255,0.15);
  border-color: rgba(108,99,255,0.25);
  color: var(--accent);
}

.nav-item .icon { font-size: 18px; width: 20px; text-align: center; flex-shrink: 0; }
.nav-item .label { font-size: 13.5px; }

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

.server-status {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); flex-shrink: 0; animation: pulse 2s infinite; }
@keyframes pulse { 0%,100%{opacity:1;} 50%{opacity:0.4;} }
.status-text { font-size: 12px; color: var(--text-secondary); }
.status-text strong { color: var(--text-primary); font-weight: 600; }

/* ── Main Content ─────────────────────────────────────────── */
.main {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Header ──────────────────────────────────────────────── */
.header {
  height: var(--header-height);
  background: rgba(10,14,26,0.8);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-left h1 { font-size: 18px; font-weight: 700; }
.header-left p  { font-size: 12px; color: var(--text-secondary); margin-top: 1px; }

.header-right { display: flex; align-items: center; gap: 12px; }

.date-filter {
  display: flex;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.date-btn {
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border: none;
  background: transparent;
  transition: all 0.2s;
}

.date-btn:hover { color: var(--text-primary); background: var(--bg-card-hover); }
.date-btn.active { background: var(--accent); color: white; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  color: white;
  box-shadow: 0 4px 15px rgba(108,99,255,0.35);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(108,99,255,0.45); }

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

.btn-danger {
  background: rgba(255,107,107,0.15);
  color: var(--red);
  border: 1px solid rgba(255,107,107,0.25);
}
.btn-danger:hover { background: rgba(255,107,107,0.25); }

.btn-sm { padding: 6px 12px; font-size: 12px; }

/* ── Page Content ─────────────────────────────────────────── */
.content { flex: 1; padding: 32px; overflow-y: auto; }

/* ── View Sections ───────────────────────────────────────── */
.view { display: none; }
.view.active { display: block; }

/* ── Stats Grid ───────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--accent-color, var(--accent));
  opacity: 0.7;
}

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

.stat-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.stat-icon {
  width: 42px; height: 42px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
}
.stat-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
  background: rgba(0,212,170,0.15);
  color: var(--green);
  border: 1px solid rgba(0,212,170,0.2);
}
.stat-badge.down { background: rgba(255,107,107,0.1); color: var(--red); border-color: rgba(255,107,107,0.2); }

.stat-value { font-size: 32px; font-weight: 800; line-height: 1; margin-bottom: 6px; letter-spacing: -1px; }
.stat-label { font-size: 12px; color: var(--text-secondary); font-weight: 500; }

/* ── Grid 2 col ───────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.grid-3 { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; margin-bottom: 20px; }

/* ── Card ─────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

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

.card-title { font-size: 15px; font-weight: 700; }
.card-subtitle { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.card-body { padding: 24px; }

/* ── Chart ─────────────────────────────────────────────────── */
.chart-wrap { position: relative; height: 260px; }
.chart-wrap canvas { max-height: 260px; }

/* ── Table ─────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  text-align: left;
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid var(--border);
}

tbody tr {
  border-bottom: 1px solid rgba(255,255,255,0.04);
  transition: background 0.15s;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,0.03); }

tbody td {
  padding: 14px 16px;
  font-size: 13.5px;
  vertical-align: middle;
}

/* ── Badges ───────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
}

.badge-green  { background: rgba(0,212,170,0.12); color: var(--green); border: 1px solid rgba(0,212,170,0.2); }
.badge-red    { background: rgba(255,107,107,0.12); color: var(--red); border: 1px solid rgba(255,107,107,0.2); }
.badge-purple { background: rgba(108,99,255,0.12); color: var(--accent); border: 1px solid rgba(108,99,255,0.2); }
.badge-yellow { background: rgba(255,217,61,0.12); color: var(--yellow); border: 1px solid rgba(255,217,61,0.2); }
.badge-blue   { background: rgba(77,171,247,0.12); color: var(--blue); border: 1px solid rgba(77,171,247,0.2); }

/* ── Partner Code ─────────────────────────────────────────── */
.code-chip {
  font-family: 'Courier New', monospace;
  font-size: 12px;
  font-weight: 700;
  background: rgba(108,99,255,0.12);
  border: 1px solid rgba(108,99,255,0.25);
  color: var(--accent);
  padding: 3px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.05em;
}
.code-chip:hover { background: rgba(108,99,255,0.22); }

/* ── Activity Feed ────────────────────────────────────────── */
.activity-feed { display: flex; flex-direction: column; gap: 0; }

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 24px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  transition: background 0.15s;
}
.activity-item:last-child { border-bottom: none; }
.activity-item:hover { background: rgba(255,255,255,0.02); }

.activity-dot {
  width: 32px; height: 32px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
  margin-top: 2px;
}

.activity-dot.pageview { background: rgba(108,99,255,0.15); }
.activity-dot.convert  { background: rgba(0,212,170,0.15); }
.activity-dot.click    { background: rgba(255,217,61,0.15); }
.activity-dot.custom   { background: rgba(77,171,247,0.15); }

.activity-info { flex: 1; }
.activity-text { font-size: 13px; color: var(--text-primary); font-weight: 500; }
.activity-meta { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }
.activity-time { font-size: 11px; color: var(--text-muted); white-space: nowrap; margin-top: 4px; }

/* ── Conversion Bar ───────────────────────────────────────── */
.conv-bar-wrap { margin-top: 4px; }
.conv-bar-bg {
  height: 5px;
  background: rgba(255,255,255,0.06);
  border-radius: 10px;
  overflow: hidden;
  margin-top: 4px;
}
.conv-bar-fill {
  height: 100%;
  border-radius: 10px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.8s ease;
}

/* ── Modal ────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border-hover);
  border-radius: 20px;
  width: 100%;
  max-width: 520px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.6);
  transform: translateY(16px) scale(0.98);
  transition: transform 0.25s ease;
}
.modal-overlay.open .modal { transform: translateY(0) scale(1); }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 28px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 18px; font-weight: 700; }
.modal-close {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 18px;
  transition: all 0.2s;
}
.modal-close:hover { background: var(--bg-card-hover); color: var(--text-primary); }

.modal-body { padding: 28px; }
.modal-footer { padding: 20px 28px; border-top: 1px solid var(--border); display: flex; gap: 12px; justify-content: flex-end; }

/* ── Form ─────────────────────────────────────────────────── */
.form-group { margin-bottom: 20px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.04em; }

.form-input, .form-textarea, .form-select {
  width: 100%;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 14px;
  color: var(--text-primary);
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}
.form-input:focus, .form-textarea:focus, .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108,99,255,0.15);
}
.form-textarea { resize: vertical; min-height: 80px; }
.form-select option { background: var(--bg-secondary); }

/* ── Snippet Box ──────────────────────────────────────────── */
.snippet-box {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.8;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ── Empty State ──────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-muted);
  gap: 12px;
}
.empty-state .icon { font-size: 48px; }
.empty-state p { font-size: 13px; }

/* ── Loading ──────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.04) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 6px;
  height: 16px;
}
@keyframes shimmer { 0%{background-position:200% 0;} 100%{background-position:-200% 0;} }

/* ── Toast ────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-radius: 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-hover);
  box-shadow: var(--shadow);
  font-size: 13px;
  font-weight: 500;
  min-width: 260px;
  animation: slideUp 0.3s ease;
  max-width: 360px;
}

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

.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--red); }
.toast.info    { border-left: 3px solid var(--accent); }

/* ── Integration Page ─────────────────────────────────────── */
.integration-steps { display: flex; flex-direction: column; gap: 20px; }
.step-item {
  display: flex;
  gap: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: border-color 0.2s;
}
.step-item:hover { border-color: var(--border-hover); }
.step-num {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 800;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(108,99,255,0.3);
}
.step-content h3 { font-size: 15px; font-weight: 700; margin-bottom: 8px; }
.step-content p  { font-size: 13px; color: var(--text-secondary); line-height: 1.7; margin-bottom: 12px; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 1100px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .main { margin-left: 0; }
  .content { padding: 20px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
