/* ============================================================
   Detoxify · Emails HCP — estilos de marca
   Rojo Detoxify #f02b35 · Gris #B7B6B6 · Bebas Neue (títulos)
   ============================================================ */
:root {
  --rojo: #f02b35;
  --rojo-oscuro: #c81f28;
  --gris: #b7b6b6;
  --gris-claro: #f4f4f4;
  --texto: #1d1d1f;
  --borde: #e3e3e3;
  --ok: #1e9e4a;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Avenir Next", Avenir, "Helvetica Neue", Helvetica, Arial, sans-serif;
  color: var(--texto);
  background: var(--gris-claro);
  font-size: 15px;
}
.bebas { font-family: "Bebas Neue", "Avenir Next", sans-serif; letter-spacing: .04em; font-weight: 400; }
h1.bebas { font-size: 34px; margin: 8px 0 4px; }
h2.bebas { font-size: 24px; margin: 0 0 8px; }
.rojo { color: var(--rojo); }
.muted { color: #777; }
.small { font-size: 13px; }
.tiny { font-size: 11px; }
.error { color: var(--rojo); }
.hidden { display: none !important; }
.mt { margin-top: 22px; }
code { background: #eee; padding: 1px 5px; border-radius: 4px; font-size: 12px; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #fff 0%, #fdeaeb 60%, #fbd8da 100%);
  padding: 20px;
}
.login-card {
  background: #fff; border-radius: 18px; padding: 34px 38px; width: 100%; max-width: 400px;
  box-shadow: 0 12px 40px rgba(240, 43, 53, .12); text-align: center;
}
.login-logo { height: 44px; margin-bottom: 6px; }
.login-card form { text-align: left; margin-top: 18px; }
.login-card label { display: block; margin-bottom: 12px; font-size: 13px; font-weight: 600; }
.login-card input {
  width: 100%; margin-top: 4px; padding: 10px 12px; border: 1px solid var(--borde);
  border-radius: 10px; font-size: 15px;
}
.login-card input:focus { outline: 2px solid var(--rojo); border-color: transparent; }

/* ---------- Barra superior ---------- */
.topbar {
  display: flex; align-items: center; gap: 16px;
  background: var(--rojo); color: #fff; padding: 10px 20px; position: sticky; top: 0; z-index: 5;
}
.topbar-logo { height: 26px; }
.topbar-title { font-size: 22px; letter-spacing: .06em; }
.tabs { display: flex; gap: 4px; margin-left: 12px; flex: 1; }
.tab {
  background: transparent; border: none; color: #ffd9db; font-size: 14px; font-weight: 600;
  padding: 8px 14px; border-radius: 9px; cursor: pointer; font-family: inherit;
}
.tab:hover { background: rgba(255,255,255,.12); }
.tab.active { background: #fff; color: var(--rojo); }
.topbar-right { display: flex; align-items: center; gap: 10px; }
#user-email { opacity: .85; }

/* ---------- Layout ---------- */
.tabpane { padding: 26px; max-width: 1200px; margin: 0 auto; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; }
@media (max-width: 900px) { .cols { grid-template-columns: 1fr; } }
.row { display: flex; align-items: center; }
.row.gap { gap: 10px; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; }

/* ---------- Botones ---------- */
.btn-primary, .btn-ghost, .btn-danger {
  font-family: inherit; font-size: 14px; font-weight: 700; border-radius: 10px;
  padding: 10px 18px; cursor: pointer; border: none;
}
.btn-primary { background: var(--rojo); color: #fff; }
.btn-primary:hover { background: var(--rojo-oscuro); }
.btn-primary:disabled { background: var(--gris); cursor: not-allowed; }
.btn-ghost { background: #fff; color: var(--texto); border: 1px solid var(--borde); }
.btn-ghost:hover { border-color: var(--rojo); color: var(--rojo); }
.btn-danger { background: #fff; color: var(--rojo); border: 1px solid var(--rojo); }
.btn-danger:hover { background: var(--rojo); color: #fff; }
.btn-ghost.small, .btn-primary.small { padding: 6px 12px; font-size: 13px; }
.topbar .btn-ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.5); }
.btn-file { display: inline-block; }

/* ---------- Tarjetas de plantilla (enviar) ---------- */
.tpl-cards { display: flex; flex-direction: column; gap: 8px; }
.tpl-card {
  background: #fff; border: 2px solid var(--borde); border-radius: 12px; padding: 12px 16px;
  cursor: pointer; transition: border-color .12s;
}
.tpl-card:hover { border-color: var(--gris); }
.tpl-card.sel { border-color: var(--rojo); box-shadow: 0 3px 14px rgba(240,43,53,.12); }
.tpl-card .t-nombre { font-weight: 800; }
.tpl-card .t-asunto { color: #666; font-size: 13px; margin-top: 2px; }
.tpl-card .t-adj { font-size: 12px; color: var(--rojo); margin-top: 4px; font-weight: 600; }

/* ---------- Textarea / inputs generales ---------- */
textarea, .dlg-form input[type=text] {
  width: 100%; border: 1px solid var(--borde); border-radius: 10px; padding: 10px 12px;
  font-size: 14px; font-family: inherit; resize: vertical;
}
#tpl-html { font-family: "SF Mono", Menlo, Consolas, monospace; font-size: 12px; }
textarea:focus, .dlg-form input:focus { outline: 2px solid var(--rojo); border-color: transparent; }
.pill {
  background: var(--rojo); color: #fff; padding: 2px 10px; border-radius: 20px;
  font-weight: 700; font-size: 12px;
}

/* ---------- Vista previa ---------- */
.preview {
  width: 100%; height: 420px; border: 1px solid var(--borde); border-radius: 12px;
  background: #fff; margin-top: 8px;
}
.summary { background: #fff; border-radius: 10px; padding: 10px 14px; border: 1px solid var(--borde); }

/* ---------- Resultado del envío ---------- */
.result { margin-top: 14px; background: #fff; border-radius: 12px; padding: 14px 18px; border: 1px solid var(--borde); }
.result.ok { border-color: var(--ok); }
.result.fail { border-color: var(--rojo); }
.result ul { margin: 6px 0 0; padding-left: 18px; font-size: 13px; color: #a33; }

/* ---------- Tablas plantillas / pdfs ---------- */
.tpl-table, .pdf-table { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.list-row {
  background: #fff; border: 1px solid var(--borde); border-radius: 12px;
  padding: 12px 16px; display: flex; align-items: center; gap: 14px;
}
.list-row .info { flex: 1; min-width: 0; }
.list-row .name { font-weight: 800; }
.list-row .meta { font-size: 12px; color: #888; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; }
.list-row .actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ---------- Adjuntos en editor ---------- */
.adj-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.adj-chip {
  background: #fdeaeb; color: var(--rojo); border-radius: 20px; padding: 5px 12px;
  font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 8px;
}
.adj-chip button { background: none; border: none; color: var(--rojo); font-weight: 800; cursor: pointer; font-size: 14px; }

/* ---------- Lista de destinatarios con toggles ---------- */
.recip-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.recip-row {
  background: #fff; border: 1px solid var(--borde); border-radius: 10px;
  padding: 8px 12px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.recip-row .r-info { flex: 1; min-width: 160px; display: flex; flex-direction: column; }
.recip-row .r-saludo { font-weight: 800; font-size: 14px; }
.recip-row .r-toggles { display: flex; gap: 8px; align-items: center; }
.tglgrp { display: inline-flex; border: 1px solid var(--borde); border-radius: 20px; overflow: hidden; }
.tgl {
  background: #fff; border: none; padding: 5px 12px; font-size: 12px; font-weight: 700;
  cursor: pointer; color: #888; font-family: inherit;
}
.tgl + .tgl { border-left: 1px solid var(--borde); }
.tgl.on { background: var(--rojo); color: #fff; }

/* ---------- Diálogos ---------- */
dialog {
  border: none; border-radius: 16px; padding: 0; width: min(720px, 94vw);
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
dialog::backdrop { background: rgba(0,0,0,.35); }
.dlg-form { padding: 26px 30px; }
.dlg-form label { display: block; font-size: 13px; font-weight: 700; margin: 12px 0 4px; }
.pdf-picker { max-height: 300px; overflow: auto; display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.pdf-picker label {
  display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 14px;
  background: var(--gris-claro); border-radius: 8px; padding: 9px 12px; cursor: pointer; margin: 0;
}

/* ---------- Selector de contactos del CRM ---------- */
.crm-filter {
  padding: 8px 10px; border: 1px solid var(--borde); border-radius: 10px;
  font-size: 13px; font-family: inherit; background: #fff;
}
.crm-list { max-height: 320px; overflow: auto; display: flex; flex-direction: column; gap: 5px; }
.crm-row {
  display: flex; align-items: center; gap: 10px; background: var(--gris-claro);
  border-radius: 8px; padding: 8px 12px; font-size: 14px; cursor: pointer; margin: 0; font-weight: 500;
}
.crm-row .c-name { font-weight: 700; white-space: nowrap; }
.crm-row.noemail { opacity: .55; cursor: default; }
.crm-row input { accent-color: var(--rojo); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: var(--texto); color: #fff; padding: 11px 22px; border-radius: 30px;
  font-size: 14px; font-weight: 600; z-index: 50; box-shadow: 0 6px 24px rgba(0,0,0,.3);
}
.toast.err { background: var(--rojo); }

/* ---------- Loader ---------- */
.spin {
  display: inline-block; width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff; border-radius: 50%; animation: sp .7s linear infinite; vertical-align: -2px;
}
@keyframes sp { to { transform: rotate(360deg); } }
