/* ─── Reset & Base ─────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f0f2f5; color: #1a1a2e; min-height: 100vh;
}
a { color: #4f46e5; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── Layout ──────────────────────────────────── */
.app-layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; background: #1a1a2e; color: #fff; padding: 1.5rem;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar h1 { font-size: 1.1rem; margin-bottom: 2rem; color: #818cf8; }
.sidebar nav { flex: 1; }
.sidebar nav a {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.7rem 0.8rem; color: #a5b4fc; border-radius: 8px;
  margin-bottom: 0.2rem; transition: all 0.15s; font-size: 0.9rem;
}
.sidebar nav a:hover, .sidebar nav a.active {
  background: rgba(255,255,255,0.08); color: #fff; text-decoration: none;
}
.sidebar .user-info {
  padding-top: 1rem; border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 0.85rem; color: #a5b4fc;
}
.sidebar .user-info .email { color: #fff; font-weight: 500; }

.main-content { flex: 1; padding: 2rem; max-width: 1200px; }

/* ─── Cards ───────────────────────────────────── */
.card {
  background: #fff; border-radius: 12px; padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06); margin-bottom: 1.5rem;
}
.card h2 { font-size: 1rem; color: #374151; margin-bottom: 1rem; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.stat-card {
  background: #fff; border-radius: 12px; padding: 1.2rem 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.stat-card .stat-value { font-size: 1.8rem; font-weight: 700; color: #4f46e5; }
.stat-card .stat-label { font-size: 0.85rem; color: #6b7280; margin-top: 0.3rem; }

/* ─── Forms ───────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.85rem; color: #374151; margin-bottom: 0.3rem; font-weight: 500; }
.form-group input, .form-group select {
  width: 100%; padding: 0.6rem 0.8rem; border: 1px solid #d1d5db; border-radius: 8px;
  font-size: 0.9rem; transition: border-color 0.15s;
}
.form-group input:focus, .form-group select:focus {
  outline: none; border-color: #4f46e5; box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}

/* ─── Buttons ─────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.6rem 1.2rem; border-radius: 8px; font-size: 0.9rem; font-weight: 500;
  border: none; cursor: pointer; transition: all 0.15s;
}
.btn-primary { background: #4f46e5; color: #fff; }
.btn-primary:hover { background: #4338ca; }
.btn-secondary { background: #e5e7eb; color: #374151; }
.btn-secondary:hover { background: #d1d5db; }
.btn-danger { background: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.8rem; }

/* ─── Tables ──────────────────────────────────── */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.7rem 0.5rem; border-bottom: 1px solid #f3f4f6; font-size: 0.9rem; }
th { color: #6b7280; font-weight: 500; font-size: 0.8rem; text-transform: uppercase; }

/* ─── Badges ──────────────────────────────────── */
.badge {
  display: inline-block; padding: 0.2rem 0.6rem; border-radius: 9999px;
  font-size: 0.75rem; font-weight: 500;
}
.badge-active { background: #d1fae5; color: #065f46; }
.badge-suspended { background: #fef3c7; color: #92400e; }
.badge-revoked { background: #fee2e2; color: #991b1b; }

/* ─── Auth Pages ──────────────────────────────── */
.auth-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}
.auth-card {
  background: #fff; border-radius: 16px; padding: 2.5rem; width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.auth-card h1 { font-size: 1.5rem; text-align: center; margin-bottom: 0.5rem; }
.auth-card .subtitle { text-align: center; color: #6b7280; font-size: 0.9rem; margin-bottom: 2rem; }
.auth-card .error { background: #fee2e2; color: #991b1b; padding: 0.6rem; border-radius: 8px; font-size: 0.85rem; margin-bottom: 1rem; display: none; }
.auth-card .toggle-text { text-align: center; font-size: 0.85rem; margin-top: 1rem; color: #6b7280; }
.auth-card .toggle-text a { cursor: pointer; }

/* ─── API Key Display ─────────────────────────── */
.key-display {
  background: #f3f4f6; border: 2px dashed #d1d5db; border-radius: 8px;
  padding: 1rem; font-family: monospace; font-size: 0.85rem;
  word-break: break-all; margin: 1rem 0; position: relative;
}
.key-display .copy-btn {
  position: absolute; top: 0.5rem; right: 0.5rem;
  background: #4f46e5; color: #fff; border: none; border-radius: 6px;
  padding: 0.3rem 0.6rem; font-size: 0.75rem; cursor: pointer;
}
.key-warning { color: #dc2626; font-size: 0.85rem; margin-bottom: 1rem; }

/* ─── Modal ───────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  align-items: center; justify-content: center; z-index: 100;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff; border-radius: 16px; padding: 2rem; width: 480px; max-width: 90vw;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.modal h2 { font-size: 1.2rem; margin-bottom: 1.5rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1.5rem; }

/* ─── Plans ───────────────────────────────────── */
.plans-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; }
.plan-card {
  background: #fff; border-radius: 12px; padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06); border: 2px solid transparent;
  position: relative;
}
.plan-card.current { border-color: #4f46e5; }
.plan-card .plan-name { font-size: 1.1rem; font-weight: 600; }
.plan-card .plan-price { font-size: 2rem; font-weight: 700; color: #4f46e5; margin: 0.5rem 0; }
.plan-card .plan-price small { font-size: 0.9rem; color: #6b7280; font-weight: 400; }
.plan-card .plan-features { list-style: none; margin: 1rem 0; }
.plan-card .plan-features li { padding: 0.3rem 0; font-size: 0.85rem; color: #374151; }
.plan-card .plan-features li::before { content: '✓ '; color: #10b981; }

/* ─── Toast ───────────────────────────────────── */
.toast {
  position: fixed; bottom: 2rem; right: 2rem; background: #1f2937; color: #fff;
  padding: 0.8rem 1.2rem; border-radius: 10px; font-size: 0.85rem;
  z-index: 200; opacity: 0; transform: translateY(20px); transition: all 0.3s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { background: #065f46; }
.toast.error { background: #991b1b; }

/* ─── Empty State ─────────────────────────────── */
.empty-state { text-align: center; padding: 3rem; color: #6b7280; }
.empty-state .icon { font-size: 3rem; margin-bottom: 1rem; }

/* ─── Responsive ──────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { width: 60px; padding: 1rem 0.5rem; }
  .sidebar h1, .sidebar .user-info, .sidebar nav a span { display: none; }
  .sidebar nav a { justify-content: center; padding: 0.7rem; }
  .main-content { padding: 1rem; }
}
