/* =========================================================================
   ugc-scout · Design System Pampling
   Tokens + componentes (sidebar, cards, tabla, form, chips, botones,
   avatar, modal). Estética glassmorphism, violeta, Poppins.
   ========================================================================= */

:root {
  /* --- Tokens base --- */
  --bg-base: #F5F0EB;
  --text-primary: #2D2A26;
  --text-secondary: rgba(45, 42, 38, 0.60);

  --accent: #7947F8;
  --accent-end: #A855F7;
  --accent-soft: rgba(121, 71, 248, 0.10);
  --accent-b: #4A9EFF;

  --green: #5C8A6C;
  --amber: #C99555;
  --red: #E05252;

  --border: rgba(45, 42, 38, 0.08);
  --radius: 16px;
  --shadow: 0 4px 16px rgba(45, 42, 38, 0.08);

  /* Versiones -soft de los colores de estado (chips) */
  --green-soft: rgba(92, 138, 108, 0.12);
  --amber-soft: rgba(201, 149, 85, 0.14);
  --red-soft: rgba(224, 82, 82, 0.12);

  --sidebar-w: 240px;
}

/* --- Reset ligero --- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: "Poppins", system-ui, -apple-system, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  /* Fondo con suaves halos violeta para dar profundidad al glassmorphism */
  background-image:
    radial-gradient(900px 500px at 12% -8%, rgba(121, 71, 248, 0.10), transparent 60%),
    radial-gradient(800px 500px at 110% 10%, rgba(74, 158, 255, 0.08), transparent 55%);
  background-attachment: fixed;
}

a {
  color: inherit;
  text-decoration: none;
}

h1, h2, h3, h4 {
  margin: 0;
  font-weight: 600;
}

.muted {
  color: var(--text-secondary);
}

/* =========================================================================
   Layout: shell con sidebar
   ========================================================================= */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px 16px;
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-right: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  color: #fff;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent-end));
}

.brand-name {
  font-weight: 600;
  font-size: 16px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  padding: 10px 14px;
  border-radius: 12px;
  color: var(--text-secondary);
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-item:hover {
  background: rgba(45, 42, 38, 0.04);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.sidebar-foot {
  margin-top: auto;
  font-size: 12px;
  padding: 0 8px;
}

.view {
  padding: 32px 40px;
  max-width: 1200px;
  width: 100%;
}

/* =========================================================================
   Cabecera de vista
   ========================================================================= */
.view-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.view-head h1 {
  font-size: 24px;
}

.view-head .sub {
  color: var(--text-secondary);
  font-size: 13px;
  margin-top: 2px;
}

/* =========================================================================
   Cards (glassmorphism)
   ========================================================================= */
.card {
  background: rgba(255, 255, 255, 0.62);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.card h3 {
  font-size: 16px;
  margin-bottom: 6px;
}

.card .card-foot {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.card .field-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  margin-top: 12px;
  margin-bottom: 4px;
}

/* =========================================================================
   Botones
   ========================================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.btn:hover {
  background: #fff;
}

.btn:active {
  transform: translateY(1px);
}

/* Botón primario con degradado violeta */
.btn-primary {
  border: none;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-end));
  box-shadow: 0 4px 14px rgba(121, 71, 248, 0.30);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--accent), var(--accent-end));
  box-shadow: 0 6px 18px rgba(121, 71, 248, 0.38);
}

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

.btn-ghost {
  background: transparent;
  border-color: transparent;
}

.btn-ghost:hover {
  background: rgba(45, 42, 38, 0.05);
}

.btn-success {
  border: none;
  color: var(--green);
  background: var(--green-soft);
}

.btn-danger {
  border: none;
  color: var(--red);
  background: var(--red-soft);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* =========================================================================
   Chips de estado (versión -soft: texto en color, fondo suave)
   ========================================================================= */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.chip-neutral { background: rgba(45, 42, 38, 0.06); color: var(--text-secondary); }
.chip-accent  { background: var(--accent-soft); color: var(--accent); }
.chip-green   { background: var(--green-soft); color: var(--green); }
.chip-amber   { background: var(--amber-soft); color: var(--amber); }
.chip-red     { background: var(--red-soft); color: var(--red); }
.chip-blue    { background: rgba(74, 158, 255, 0.12); color: var(--accent-b); }

/* Badge de score (violeta) */
.score-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-end));
}

/* =========================================================================
   Avatar con iniciales en degradado
   ========================================================================= */
.avatar {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent-b));
}

.avatar-lg {
  width: 56px;
  height: 56px;
  font-size: 18px;
}

/* =========================================================================
   Tabla
   ========================================================================= */
.table-wrap {
  background: rgba(255, 255, 255, 0.62);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

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

thead th {
  text-align: left;
  padding: 14px 16px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

thead th.sortable {
  cursor: pointer;
  user-select: none;
}

thead th.sortable:hover {
  color: var(--accent);
}

thead th .sort-arrow {
  font-size: 10px;
  opacity: 0.7;
}

tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr.clickable {
  cursor: pointer;
  transition: background 0.12s ease;
}

tbody tr.clickable:hover {
  background: rgba(121, 71, 248, 0.05);
}

.cell-handle {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
}

/* =========================================================================
   Formularios
   ========================================================================= */
.form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.field input,
.field select,
.field textarea {
  font-family: inherit;
  font-size: 14px;
  color: var(--text-primary);
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.8);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  width: 100%;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field textarea {
  resize: vertical;
  min-height: 80px;
}

/* Filtros en barra horizontal */
.filters {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.filters .field {
  min-width: 150px;
}

/* =========================================================================
   Chips editables (criterios / descartes)
   ========================================================================= */
.chip-editor {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip-edit {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px 4px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
}

.chip-edit button {
  border: none;
  background: rgba(121, 71, 248, 0.18);
  color: var(--accent);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  cursor: pointer;
  line-height: 1;
  font-size: 12px;
}

.chip-add {
  display: flex;
  gap: 8px;
}

.chip-add input {
  flex: 1;
}

/* =========================================================================
   Estados de carga / error / vacío
   ========================================================================= */
.state {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-secondary);
}

.state.error {
  color: var(--red);
}

.spinner {
  display: inline-block;
  width: 22px;
  height: 22px;
  border: 3px solid var(--accent-soft);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* =========================================================================
   Modal simple
   ========================================================================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(45, 42, 38, 0.35);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 100;
}

.modal {
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 16px 48px rgba(45, 42, 38, 0.22);
  padding: 24px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-head h2 {
  font-size: 18px;
}

.modal-close {
  border: none;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: var(--text-secondary);
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

/* =========================================================================
   Utilidades
   ========================================================================= */
.row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.gap-sm { gap: 8px; }
.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.metric {
  padding: 14px 16px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--border);
}

.metric .value {
  font-size: 22px;
  font-weight: 600;
}

.metric .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
}

/* Grid de posts */
.posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

.post-tile {
  aspect-ratio: 1 / 1;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: linear-gradient(135deg, var(--accent-soft), rgba(74, 158, 255, 0.12));
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  position: relative;
}

.post-tile img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.post-tile .post-meta {
  position: relative;
  z-index: 1;
  padding: 8px 10px;
  font-size: 11px;
  color: #fff;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.55));
}

.post-tile.placeholder .post-meta {
  color: var(--text-secondary);
  background: none;
}

/* Toast de notificaciones */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 14px 18px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  font-size: 13px;
  z-index: 200;
  max-width: 360px;
  animation: toast-in 0.2s ease;
}

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

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Histórico de evaluaciones */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.timeline-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid var(--border);
}

@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar-foot { display: none; }
  .view { padding: 20px; }
}

/* =========================================================================
   Autenticación (login / registro) — card centrada sobre el fondo base
   ========================================================================= */
.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 16px 48px rgba(45, 42, 38, 0.16);
  padding: 32px;
}

.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  text-align: center;
}

.auth-brand .brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  font-size: 22px;
}

.auth-brand h1 {
  font-size: 20px;
}

.auth-brand .sub {
  font-size: 13px;
  color: var(--text-secondary);
}

.auth-card .form { gap: 14px; }

.auth-submit {
  margin-top: 6px;
  width: 100%;
}

/* Mensaje de feedback (error / info) dentro de la card */
.auth-msg {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  margin-bottom: 4px;
}

.auth-msg.error {
  background: var(--red-soft);
  color: var(--red);
}

.auth-msg.info {
  background: var(--accent-soft);
  color: var(--accent);
}

/* Toggle entre login y registro */
.auth-toggle {
  margin-top: 20px;
  text-align: center;
  font-size: 13px;
  color: var(--text-secondary);
}

.auth-toggle button {
  border: none;
  background: none;
  color: var(--accent);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}

/* =========================================================================
   Caja de usuario en la sidebar
   ========================================================================= */
.user-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid var(--border);
  margin-bottom: 12px;
}

.avatar-sm {
  width: 32px;
  height: 32px;
  font-size: 12px;
}

.user-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.user-email {
  font-size: 12px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 150px;
}

.btn-logout {
  border: none;
  background: none;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
  padding: 0;
  text-align: left;
}

.btn-logout:hover { color: var(--red); }

/* =========================================================================
   Admin: fila de usuario pendiente, aviso secreto, etc.
   ========================================================================= */
tbody tr.pendiente {
  background: var(--amber-soft);
}

tbody tr.pendiente:hover {
  background: rgba(201, 149, 85, 0.20);
}

.inline-select {
  font-family: inherit;
  font-size: 12px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.8);
  color: var(--text-primary);
}

/* Aviso de secreto (worker_token) */
.secret-warn {
  font-size: 12px;
  color: var(--amber);
  margin-top: 4px;
}

.bootstrap-out code {
  display: block;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(45, 42, 38, 0.05);
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 12px;
  word-break: break-all;
}

.bootstrap-out textarea {
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 12px;
  min-height: 220px;
}
