/* styles.css — panel mobile-first. Un solo archivo, sin build step.
   Paleta reusada de infra/panelcards/index.html para que el panel interno y
   el gallery publico se sientan de la misma familia. */

:root {
  color-scheme: dark light;
  --bg: #0b0d10;
  --surface: #14171c;
  --surface-2: #1b1f26;
  --border: #262b33;
  --text: #e7e9ec;
  --muted: #8a9099;
  --accent: #5b8cff;
  --danger: #e0685b;
  --ok: #4caf7d;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --surface-2: #eef0f3;
    --border: #e2e5ea;
    --text: #14171c;
    --muted: #5b6470;
    --accent: #3563e0;
    --danger: #c0392b;
    --ok: #2e8b57;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

/* Layout mobile-first: un solo screen a la vez, ancho completo, sin tablas. */
main {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: 1.5rem 1.25rem 3rem;
  display: flex;
  flex-direction: column;
}

.screen { display: none; flex: 1; flex-direction: column; gap: 1rem; }
.screen.active { display: flex; }

h1 { font-size: 1.3rem; font-weight: 600; margin: 0 0 0.25rem; }
.sub { color: var(--muted); font-size: 0.88rem; margin: 0 0 1rem; }

label { font-size: 0.85rem; color: var(--muted); display: block; margin-bottom: 0.35rem; }

input[type="text"],
input[type="password"],
input[type="email"],
select {
  width: 100%;
  font-size: 1rem;
  padding: 0.85rem 0.9rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.field { margin-bottom: 1rem; }

/* Botones grandes, tap-friendly (min 44px de alto). */
button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 600;
  padding: 0.9rem 1.1rem;
  min-height: 48px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
}
button.primary, .btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
button.danger, .btn.danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}
button:disabled { opacity: 0.5; cursor: default; }
button:active, .btn:active { transform: scale(0.98); }

.error-msg {
  color: var(--danger);
  font-size: 0.88rem;
  min-height: 1.2em;
}

.hint { color: var(--muted); font-size: 0.8rem; }

textarea {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  padding: 0.85rem 0.9rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  resize: vertical;
}

/* --- Lista de leads --- */
.list-search { margin-bottom: 0.4rem; }
.list-search input[type="search"] {
  width: 100%;
  font-size: 1rem;
  padding: 0.75rem 0.9rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}
.list-search input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.lead-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.9rem 1.1rem;
  margin-bottom: 0.6rem;
  cursor: pointer;
}
.lead-card-main { min-width: 0; flex: 1; }
.lead-card-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lead-card-meta { color: var(--muted); font-size: 0.8rem; margin-top: 0.15rem; }
.lead-card-side { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }
.status-badge {
  font-size: 0.72rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.lead-delete-btn {
  min-height: unset;
  padding: 0.35rem 0.5rem;
  font-size: 1rem;
  line-height: 1;
  border-radius: 8px;
  background: transparent;
  border-color: var(--border);
  color: var(--muted);
}
.lead-delete-btn:hover { border-color: var(--danger); color: var(--danger); }
.empty-hint { color: var(--muted); text-align: center; padding: 2rem 1rem; }

/* --- Paginador --- */
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin: 0.25rem 0 0.5rem;
}
.pager button { flex: 1; min-height: 44px; padding: 0.6rem 0.8rem; }
.pager-info { color: var(--muted); font-size: 0.82rem; white-space: nowrap; text-align: center; }

/* --- Verify screen --- */
.banner-risk {
  background: rgba(224, 104, 91, 0.12);
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: 10px;
  padding: 0.7rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 600;
}
.field-row { margin-bottom: 0.9rem; }
.field-row label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.field-row .risk-flag { color: var(--danger); }
.field-row-inputs { display: flex; gap: 0.5rem; align-items: stretch; }
.field-row-inputs input, .field-row-inputs select, .field-row-inputs textarea { flex: 1; }
.clear-btn { min-height: unset; padding: 0 0.9rem; font-weight: 700; }

.color-tile {
  border-radius: 12px;
  padding: 0.9rem 1.1rem;
  margin-bottom: 0.4rem;
  border: 1px solid var(--border);
}
.color-role { font-weight: 700; font-size: 0.95rem; }
.color-detail { font-size: 0.82rem; opacity: 0.9; margin-top: 0.15rem; }
.color-edit { display: flex; gap: 0.5rem; margin-bottom: 1rem; flex-wrap: wrap; align-items: stretch; }
.color-edit input { flex: 1; min-width: 8rem; }
.palette-chips { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; }
.chip {
  width: 32px;
  height: 32px;
  min-height: unset;
  border-radius: 8px;
  border: 1px solid var(--border);
  padding: 0;
  cursor: pointer;
}

.attr-row, .field-row { display: flex; flex-direction: column; }
.save-flash { font-size: 0.75rem; color: var(--ok); min-height: 1.1em; }

/* --- Run / progreso --- */
.run-step {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.8rem 1rem;
  margin-bottom: 0.5rem;
}
.run-step-icon { font-size: 1.1rem; width: 1.5rem; text-align: center; flex-shrink: 0; }
.run-step-label { font-weight: 500; }

/* --- Links --- */
.link-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.1rem;
  margin-bottom: 0.75rem;
}
.link-row label { margin-bottom: 0.5rem; }
.link-row .field-row-inputs a.btn { flex: 1; text-align: center; }
.link-url { word-break: break-all; font-size: 0.8rem; color: var(--muted); margin: 0.3rem 0 0.6rem; }
/* Mensaje de outreach: preserva saltos de linea, scroll si es largo. */
.msg-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--text, var(--muted));
  margin: 0.3rem 0 0.6rem;
  max-height: 11rem;
  overflow-y: auto;
}

/* --- Barra de operador --- */
.operator-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.operator-who { font-size: 0.85rem; color: var(--muted); }
.operator-who strong { color: var(--text); }
.mini-btn {
  min-height: unset;
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
}

/* --- Filtros de la lista (carpeta + estado) --- */
.filter-bar { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 0.5rem; }
.folder-chips { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.fchip {
  min-height: unset;
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
}
.fchip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.fchip-count { opacity: 0.7; font-size: 0.72rem; }
.sendstate-filter { padding: 0.55rem 0.7rem; font-size: 0.9rem; }

/* --- Badges de la card (estado de envio + status del pipeline) --- */
.badge-col { display: flex; flex-direction: column; gap: 0.25rem; align-items: flex-end; }
.lead-card-people { color: var(--muted); font-size: 0.75rem; margin-top: 0.2rem; }
.send-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  white-space: nowrap;
  border: 1px solid transparent;
}
.send-draft { background: var(--surface-2); color: var(--muted); border-color: var(--border); }
.send-ready { background: rgba(91, 140, 255, 0.16); color: var(--accent); border-color: var(--accent); }
.send-sent { background: rgba(76, 175, 125, 0.16); color: var(--ok); border-color: var(--ok); }
.send-test { background: rgba(224, 104, 91, 0.14); color: var(--danger); border-color: var(--danger); }

/* --- Galeria de imagenes --- */
.images-gallery { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.images-gallery .thumb { margin: 0; width: 120px; }
.images-gallery .thumb img {
  width: 100%;
  height: 90px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: zoom-in;
  display: block;
}
.images-gallery figcaption { font-size: 0.72rem; color: var(--muted); text-align: center; margin-top: 0.2rem; }

/* --- Panel de tracking (pantalla Publicar) --- */
.tracking-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.tp-row { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; }
.tp-label { font-size: 0.8rem; color: var(--muted); }
.tp-states { display: flex; flex-direction: column; gap: 0.4rem; }
.seg { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.seg-btn {
  min-height: unset;
  flex: 1;
  min-width: 4.5rem;
  padding: 0.5rem 0.4rem;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
}
.seg-btn.active { color: #fff; }
.seg-btn.seg-draft.active { background: var(--muted); border-color: var(--muted); }
.seg-btn.seg-ready.active { background: var(--accent); border-color: var(--accent); }
.seg-btn.seg-sent.active { background: var(--ok); border-color: var(--ok); }
.seg-btn.seg-test.active { background: var(--danger); border-color: var(--danger); }
.tp-people { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.8rem; color: var(--muted); }
.tp-people strong { color: var(--text); font-weight: 600; }
.tp-date { font-size: 0.75rem; }

/* --- Modal generico --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.2rem;
  z-index: 50;
}
.modal-overlay[hidden] { display: none; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.3rem;
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}
.modal h2 { font-size: 1.1rem; margin: 0; }
.modal-quick { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.modal-actions { display: flex; gap: 0.6rem; margin-top: 0.3rem; }
.modal-actions button { flex: 1; }

/* --- Lightbox --- */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 60;
}
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 100%; max-height: 90dvh; border-radius: 8px; }
.lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  min-height: unset;
  padding: 0.4rem 0.7rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #fff;
  font-size: 1.1rem;
}

/* --- Desktop / tablet: vista mas ancha y lista en grilla ---
   El panel es mobile-first (main capado a 480px). En pantallas anchas damos
   mas aire y pintamos la lista de leads en 2-3 columnas para no dejar una
   sola tira de cards en medio de una pantalla vacia. Solo afecta la pantalla
   de lista: los formularios de captura/verify se mantienen legibles al centro. */
@media (min-width: 720px) {
  main { max-width: 920px; padding-top: 2.5rem; }
  /* Los formularios se mantienen angostos y centrados (mas legibles). */
  .screen { max-width: 520px; width: 100%; margin: 0 auto; }
  /* La lista rompe el ancho para aprovechar la pantalla. */
  #screen-list.active { max-width: 920px; }
  #leads-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0.6rem;
  }
  #leads-list .lead-card { margin-bottom: 0; }
  #leads-list .empty-hint { grid-column: 1 / -1; }
}
