/* =========================================================
   CARDY · Panel de administración
   Estilo: "liquid glass" oscuro sobre degradado violeta/negro,
   fiel al logo de la marca.
   ========================================================= */

:root {
  /* Paleta de marca (extraída del logo) */
  --black: #050208;
  --purple-950: #140627;
  --purple-800: #2d0d55;
  --purple-600: #5b21b6;
  --purple-500: #7c3aed;
  --violet-400: #a78bfa;
  --violet-glow: #8b5cf6;

  --white: #ffffff;
  --text-primary: #f6f4fb;
  --text-secondary: rgba(246, 244, 251, 0.64);
  --text-faint: rgba(246, 244, 251, 0.38);

  /* Vidrio */
  --glass-bg: rgba(255, 255, 255, 0.055);
  --glass-bg-strong: rgba(255, 255, 255, 0.095);
  --glass-border: rgba(255, 255, 255, 0.14);
  --glass-border-strong: rgba(255, 255, 255, 0.26);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);

  /* Estados */
  --ok: #34d399;
  --ok-bg: rgba(52, 211, 153, 0.14);
  --error: #fb7185;
  --error-bg: rgba(251, 113, 133, 0.14);
  --warn: #fbbf24;
  --warn-bg: rgba(251, 191, 36, 0.14);

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --sidebar-w: 264px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--text-primary);
  background: var(--black);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Fondo degradado ambiental, fijo detrás de todo (como el logo) */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(circle at 8% 6%, rgba(124, 58, 237, 0.55), transparent 42%),
    radial-gradient(circle at 96% 92%, rgba(109, 40, 217, 0.45), transparent 45%),
    radial-gradient(circle at 100% 0%, rgba(139, 92, 246, 0.18), transparent 40%),
    var(--black);
}

a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -0.02em; }
p { margin: 0; }

::selection { background: var(--violet-glow); color: var(--white); }

/* Scrollbar discreta */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 10px; }
::-webkit-scrollbar-track { background: transparent; }

/* --- Utilidad de vidrio reutilizable --- */
.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--glass-shadow);
}

/* =========================================================
   LOGIN
   ========================================================= */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  padding: 44px 36px 36px;
  text-align: center;
}

.login-logo { width: 108px; margin: 0 auto 8px; display: block; }
.login-card .subtitle { color: var(--text-secondary); font-size: 14px; margin-top: 6px; margin-bottom: 32px; }

.field { text-align: left; margin-bottom: 18px; }
.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 7px;
  letter-spacing: 0.01em;
}

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=tel], select, textarea {
  width: 100%;
  padding: 13px 15px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14.5px;
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}

input::placeholder, textarea::placeholder { color: var(--text-faint); }

input:focus, select:focus, textarea:focus {
  border-color: var(--violet-400);
  background: rgba(255, 255, 255, 0.08);
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23a78bfa' stroke-width='1.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 15px center;
  padding-right: 36px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
  background: var(--glass-bg-strong);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.15s ease, background 0.15s ease;
}
.btn:hover { border-color: var(--glass-border-strong); background: rgba(255,255,255,0.13); }
.btn:active { transform: scale(0.98); }

.btn-primary {
  background: linear-gradient(135deg, var(--purple-500), var(--violet-glow));
  border-color: transparent;
  box-shadow: 0 6px 20px rgba(124, 58, 237, 0.45);
}
.btn-primary:hover { filter: brightness(1.08); background: linear-gradient(135deg, var(--purple-500), var(--violet-glow)); }

.btn-block { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 13px; }
.btn-danger { color: var(--error); }
.btn-danger:hover { border-color: rgba(251,113,133,0.5); background: var(--error-bg); }

.login-error {
  background: var(--error-bg);
  border: 1px solid rgba(251, 113, 133, 0.35);
  color: #ffc2cb;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  margin-bottom: 18px;
  text-align: left;
}

.login-hint {
  margin-top: 26px;
  font-size: 12px;
  color: var(--text-faint);
  line-height: 1.6;
}

/* =========================================================
   LAYOUT: sidebar + topbar + contenido
   ========================================================= */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  margin: 16px 0 16px 16px;
  padding: 26px 18px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 16px;
  height: calc(100vh - 32px);
}

.sidebar-logo { display: flex; align-items: center; gap: 10px; padding: 0 8px 26px; }
.sidebar-logo img { width: 34px; height: 34px; object-fit: contain; }
.sidebar-logo span { font-size: 19px; font-weight: 800; letter-spacing: -0.02em; }

.nav-group-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  padding: 16px 12px 8px;
  font-weight: 700;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 2px;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-item svg { flex-shrink: 0; opacity: 0.8; }
.nav-item:hover { background: rgba(255,255,255,0.06); color: var(--text-primary); }
.nav-item.active {
  background: linear-gradient(135deg, rgba(124,58,237,0.35), rgba(139,92,246,0.18));
  color: var(--white);
  border: 1px solid rgba(167,139,250,0.35);
}
.nav-item.active svg { opacity: 1; }

.sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--glass-border);
}
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 8px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--purple-500), var(--violet-400));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; color: var(--white); flex-shrink: 0;
}
.sidebar-user-info { min-width: 0; }
.sidebar-user-info .name { font-size: 13.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-info .role { font-size: 11.5px; color: var(--text-faint); }

.main {
  flex: 1;
  min-width: 0;
  padding: 16px 16px 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  margin-bottom: 22px;
}
.topbar h1 { font-size: 21px; }
.topbar .eyebrow { font-size: 12.5px; color: var(--text-faint); margin-bottom: 3px; text-transform: uppercase; letter-spacing: 0.06em; }
.topbar-actions { display: flex; gap: 10px; align-items: center; }

.content { padding: 0 8px; }

/* =========================================================
   COMPONENTES
   ========================================================= */
.card { padding: 24px; margin-bottom: 20px; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.card-header h3 { font-size: 16px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card { padding: 20px 22px; }
.stat-card .label { font-size: 12.5px; color: var(--text-secondary); font-weight: 600; margin-bottom: 10px; }
.stat-card .value { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; }
.stat-card .value.violet { color: var(--violet-400); }
.stat-card .sub { font-size: 12px; color: var(--text-faint); margin-top: 6px; }

table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  font-weight: 700;
  padding: 0 14px 12px;
  border-bottom: 1px solid var(--glass-border);
}
tbody td {
  padding: 14px;
  font-size: 14px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,0.03); }
.table-wrap { overflow-x: auto; }
.cell-muted { color: var(--text-faint); font-size: 13px; }
.cell-strong { font-weight: 700; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-error { background: var(--error-bg); color: var(--error); }
.badge-pendiente { background: var(--warn-bg); color: var(--warn); }
.badge-bronce { background: rgba(205,127,50,0.16); color: #e0a05c; }
.badge-plata { background: rgba(192,192,192,0.16); color: #d9d9de; }
.badge-oro { background: rgba(255,215,0,0.16); color: #f4cf5c; }
.badge-platino { background: rgba(167,139,250,0.2); color: var(--violet-400); }

.empty-state { text-align: center; padding: 60px 20px; color: var(--text-faint); }
.empty-state svg { margin-bottom: 14px; opacity: 0.5; }
.empty-state p { font-size: 14px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 720px) { .grid-2 { grid-template-columns: 1fr; } }

.pill-select { display: flex; gap: 8px; flex-wrap: wrap; }
.pill-select label {
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.15s ease;
}
.pill-select input { display: none; }
.pill-select input:checked + label,
.pill-select label.selected {
  background: linear-gradient(135deg, var(--purple-500), var(--violet-glow));
  color: var(--white);
  border-color: transparent;
}

.alert { padding: 13px 16px; border-radius: var(--radius-sm); font-size: 13.5px; margin-bottom: 18px; }
.alert-ok { background: var(--ok-bg); color: var(--ok); border: 1px solid rgba(52,211,153,0.3); }
.alert-error { background: var(--error-bg); color: #ffc2cb; border: 1px solid rgba(251,113,133,0.3); }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.toolbar input, .toolbar select { max-width: 260px; }

/* =========================================================
   ESCÁNER QR — el momento clave del panel
   ========================================================= */
.scanner-page { max-width: 480px; margin: 0 auto; }
.scanner-frame {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  aspect-ratio: 1 / 1;
  background: #000;
  border: 1px solid var(--glass-border-strong);
  box-shadow: 0 0 0 1px rgba(167,139,250,0.15), 0 20px 60px rgba(124,58,237,0.25);
}
#qr-reader { width: 100%; height: 100%; }
#qr-reader video { object-fit: cover; width: 100% !important; height: 100% !important; }

.scan-corner {
  position: absolute;
  width: 34px; height: 34px;
  border-color: var(--violet-400);
  border-style: solid;
  border-width: 0;
  z-index: 5;
  pointer-events: none;
  filter: drop-shadow(0 0 6px rgba(167,139,250,0.7));
}
.scan-tl { top: 18px; left: 18px; border-top-width: 3px; border-left-width: 3px; border-top-left-radius: 10px; }
.scan-tr { top: 18px; right: 18px; border-top-width: 3px; border-right-width: 3px; border-top-right-radius: 10px; }
.scan-bl { bottom: 18px; left: 18px; border-bottom-width: 3px; border-left-width: 3px; border-bottom-left-radius: 10px; }
.scan-br { bottom: 18px; right: 18px; border-bottom-width: 3px; border-right-width: 3px; border-bottom-right-radius: 10px; }

.scan-laser {
  position: absolute; left: 8%; right: 8%; height: 2px;
  background: linear-gradient(90deg, transparent, var(--violet-400), transparent);
  box-shadow: 0 0 12px 2px rgba(167,139,250,0.8);
  z-index: 5;
  animation: scan-move 2.4s ease-in-out infinite;
  pointer-events: none;
}
@keyframes scan-move {
  0%, 100% { top: 12%; opacity: 0.9; }
  50% { top: 88%; opacity: 0.5; }
}

.scan-result-card { margin-top: 18px; padding: 22px; text-align: center; }
.scan-result-card .influencer-name { font-size: 19px; font-weight: 800; margin-bottom: 3px; }
.scan-result-card .influencer-handle { color: var(--text-secondary); font-size: 13.5px; margin-bottom: 18px; }

/* QR de la tarjeta (vista de un influencer) */
.qr-box { background: #fff; padding: 18px; border-radius: var(--radius-md); display: inline-block; }

/* =========================================================
   MISC
   ========================================================= */
.mobile-toggle { display: none; }

@media (max-width: 920px) {
  .app-shell { flex-direction: column; }
  .sidebar {
    width: auto; margin: 12px; height: auto; position: relative; top: 0;
    flex-direction: row; align-items: center; padding: 14px 16px;
  }
  .sidebar-logo { padding: 0; margin-right: auto; }
  .nav-group-label { display: none; }
  .sidebar-nav { display: none; }
  .sidebar-footer { margin: 0; padding: 0; border: none; }
  .mobile-toggle {
    display: flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border-radius: 10px;
    background: var(--glass-bg-strong); border: 1px solid var(--glass-border); cursor: pointer;
  }
  .main { padding: 0 12px 32px; }
  .topbar { padding: 14px 16px; flex-wrap: wrap; gap: 12px; }
  .grid-2 { grid-template-columns: 1fr; }
}

.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.flex { display: flex; }
.gap-8 { gap: 8px; }
.items-center { align-items: center; }
.w-full { width: 100%; }
