/* ============================
   Design Tokens
   ============================ */
:root {
  --bg-base:      #0c0c11;
  --bg-surface:   #14141c;
  --bg-elevated:  #1c1c28;
  --bg-input:     #1e1e2c;
  --border:       #2a2a3a;
  --border-focus: #7c3aed;

  --text-primary:   #f0f0fa;
  --text-secondary: #9090b0;
  --text-muted:     #5555700;

  --accent:        #7c3aed;
  --accent-light:  #a78bfa;
  --accent-glow:   rgba(124, 58, 237, 0.25);

  --success: #34d399;
  --danger:  #f87171;
  --warning: #fbbf24;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 24px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 24px var(--accent-glow);
}

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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ============================
   Screens
   ============================ */
.screen { display: none; }
.screen.active { display: block; }

/* ============================
   Auth Screen
   ============================ */
#screen-auth {
  display: none;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse 60% 50% at 50% -10%, rgba(124,58,237,0.25), transparent),
    var(--bg-base);
}
#screen-auth.active { display: flex; }

.auth-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-md);
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 1.5rem;
  font-size: 1.1rem;
  font-weight: 700;
}
.logo-icon { font-size: 1.4rem; color: var(--accent-light); }
.logo-text { color: var(--text-primary); }
.logo-accent { color: var(--accent-light); }

.auth-card h1 {
  font-size: 1.75rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
}
.subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 1.75rem;
}

.auth-buttons { display: flex; flex-direction: column; gap: 0.75rem; }

.divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-secondary);
  font-size: 0.8rem;
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ============================
   Buttons
   ============================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s, box-shadow 0.15s;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  color: #fff;
  box-shadow: 0 2px 12px var(--accent-glow);
}
.btn-primary:hover { box-shadow: var(--shadow-glow); opacity: 0.93; }

.btn-google {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-google:hover { border-color: var(--accent-light); }

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

.btn-sm { padding: 0.4rem 0.85rem; font-size: 0.8rem; }

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(248,113,113,0.3);
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
}
.btn-danger:hover { background: rgba(248,113,113,0.1); }

/* ============================
   Inputs
   ============================ */
.input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.65rem 0.875rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.input::placeholder { color: var(--text-secondary); }

.form-group { display: flex; flex-direction: column; gap: 0.4rem; }
.form-group label { font-size: 0.85rem; font-weight: 500; color: var(--text-secondary); }
.hint { font-size: 0.78rem; color: var(--text-secondary); }

/* ============================
   Top Bar
   ============================ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 2rem;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-brand { display: flex; align-items: center; gap: 0.4rem; font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 1rem; }

.user-email { font-size: 0.85rem; color: var(--text-secondary); }

.role-badge {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: var(--accent-glow);
  color: var(--accent-light);
  border: 1px solid rgba(167,139,250,0.3);
}
.role-badge.admin    { background: rgba(251,191,36,0.15); color: var(--warning); border-color: rgba(251,191,36,0.3); }
.role-badge.premium  { background: rgba(52,211,153,0.15); color: var(--success); border-color: rgba(52,211,153,0.3); }
.role-badge.verified { background: var(--accent-glow); color: var(--accent-light); border-color: rgba(167,139,250,0.3); }
.role-badge.unverified { background: rgba(90,90,110,0.2); color: var(--text-secondary); border-color: var(--border); }

/* ============================
   Main Layout
   ============================ */
.main-content {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}
.panel h2 { font-size: 1.1rem; font-weight: 700; }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.count-label { font-size: 0.8rem; color: var(--text-secondary); }

/* ============================
   Codes List
   ============================ */
.codes-list { display: flex; flex-direction: column; gap: 0.75rem; }

.code-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: border-color 0.15s;
}
.code-card:hover { border-color: rgba(124,58,237,0.4); }

.code-main { flex: 1; min-width: 0; }
.code-tag {
  font-size: 0.95rem;
  font-weight: 700;
  font-family: 'Courier New', monospace;
  color: var(--accent-light);
}
.code-vanity-badge {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  background: rgba(52,211,153,0.15);
  color: var(--success);
  margin-left: 0.4rem;
  vertical-align: middle;
}
.code-url {
  font-size: 0.8rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 0.15rem;
}
.code-hits {
  font-size: 0.75rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.code-actions { display: flex; gap: 0.5rem; align-items: center; }

.empty-state {
  text-align: center;
  color: var(--text-secondary);
  padding: 2.5rem 1rem;
  font-size: 0.9rem;
}

/* ============================
   Spinner
   ============================ */
.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent-light);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 1.5rem auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================
   Users List
   ============================ */
.users-list { display: flex; flex-direction: column; gap: 0.6rem; }

.user-row {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.user-row-info { flex: 1; }
.user-row-email { font-size: 0.9rem; font-weight: 500; }
.user-row-codes { font-size: 0.75rem; color: var(--text-secondary); }

.role-select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.8rem;
  padding: 0.3rem 0.6rem;
  cursor: pointer;
}

.badge-admin {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: rgba(251,191,36,0.15);
  color: var(--warning);
  margin-left: 0.5rem;
  vertical-align: middle;
}

/* ============================
   QR Modal
   ============================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.15s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  width: 100%;
  max-width: 420px;
  position: relative;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  animation: slideUp 0.2s ease;
}
@keyframes slideUp { from { transform: translateY(16px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1rem;
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
}
.modal-close:hover { color: var(--text-primary); }

.modal-card h3 { font-size: 1.1rem; font-weight: 700; }

/* Checkered background to visualize transparency */
.qr-checkerboard {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
  background-image:
    linear-gradient(45deg, #2a2a3a 25%, transparent 25%),
    linear-gradient(-45deg, #2a2a3a 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #2a2a3a 75%),
    linear-gradient(-45deg, transparent 75%, #2a2a3a 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-color: #1e1e2c;
  padding: 1rem;
}
.qr-preview-img {
  max-width: 200px;
  max-height: 200px;
  display: block;
  border-radius: 4px;
}

.qr-options { display: flex; flex-direction: column; gap: 1rem; }

input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: 999px;
  outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-light);
  box-shadow: 0 0 6px var(--accent-glow);
}

.toggle-group { display: flex; gap: 0.5rem; }
.toggle-btn {
  flex: 1;
  padding: 0.5rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
}
.toggle-btn.active {
  background: var(--accent-glow);
  border-color: var(--accent-light);
  color: var(--accent-light);
  font-weight: 600;
}

/* ============================
   Pending Verification Panel
   ============================ */
.pending-panel {
  text-align: center;
  gap: 0.75rem;
  border-color: rgba(251, 191, 36, 0.25);
  background: rgba(251, 191, 36, 0.05);
}
.pending-icon { font-size: 2.5rem; line-height: 1; }
.pending-panel h2 { color: var(--warning); }
.pending-panel p { color: var(--text-secondary); font-size: 0.9rem; max-width: 400px; margin: 0 auto; }

/* ============================
   Misc
   ============================ */
.error-msg {
  font-size: 0.82rem;
  color: var(--danger);
  background: rgba(248,113,113,0.1);
  border: 1px solid rgba(248,113,113,0.25);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
}
.hidden { display: none !important; }

/* ============================
   Responsive
   ============================ */
@media (max-width: 600px) {
  .topbar { padding: 0.75rem 1rem; }
  .main-content { padding: 1rem; }
  .panel { padding: 1.25rem; }
  .code-card { flex-wrap: wrap; }
}
