/* Identidad visual tomada de tecnocobben.com (tokens de su styles.css) */
:root {
  --white: #ffffff;
  --gray: #f5f5f7;
  --sand: #e6e3dc;
  --line: #e2e2e6;
  --ink: #0b0b0c;
  --ink-2: #1d1d1f;
  --muted: #6e6e73;
  --accent: #8a6a45;
  --wa: #25d366;
  --wa-dark: #128c4a;
  --ok: #1f6f4a;
  --ok-bg: #e3f2ea;
  --warn: #8a5a12;
  --warn-bg: #f6ecdc;
  --danger: #bf4800;
  --danger-bg: #fbeee6;
  --info-bg: #eef0f6;

  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", system-ui, "Segoe UI", Roboto, sans-serif;
  --radius: 22px;
  --radius-sm: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 12px 32px -12px rgba(0, 0, 0, 0.14);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink-2);
  background: var(--gray);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { color: var(--ink); letter-spacing: -0.02em; line-height: 1.15; }
::selection { background: var(--ink); color: var(--sand); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }

.container { max-width: 1120px; margin-inline: auto; padding-inline: 16px; }

/* ---------- Header ---------- */
.topbar { background: var(--white); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar .container { display: flex; align-items: center; gap: 20px; min-height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.brand img { height: 34px; width: auto; }
.brand span { font-size: 13px; color: var(--muted); border-left: 1px solid var(--line); padding-left: 10px; }
.nav { display: flex; gap: 4px; margin-left: auto; align-items: center; flex-wrap: wrap; }
.nav a, .nav button { padding: 7px 12px; border-radius: 999px; font-size: 14px; font-weight: 500; color: var(--muted); background: none; border: 0; cursor: pointer; }
.nav a:hover, .nav button:hover { background: var(--gray); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--ink); color: var(--white); }

main { padding-block: 24px 64px; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 34px; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--white); font-size: 13.5px; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: background-color 0.15s, border-color 0.15s, transform 0.1s;
}
.btn:hover { border-color: #c9c9ce; background: #fafafa; }
.btn:active { transform: scale(0.98); }
.btn-dark { background: var(--ink); color: var(--white); border-color: var(--ink); }
.btn-dark:hover { background: var(--ink-2); border-color: var(--ink-2); }
.btn-wa { background: var(--wa); border-color: var(--wa); color: #06331b; }
.btn-wa:hover { background: #20bd5b; border-color: #20bd5b; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--gray); border-color: transparent; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.btn-lg { min-height: 44px; padding: 10px 22px; font-size: 15px; }

/* ---------- Formularios ---------- */
.input, select.input, textarea.input {
  width: 100%; min-height: 38px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--white); font-size: 14px;
}
textarea.input { resize: vertical; min-height: 84px; }
.input:focus { outline: none; border-color: var(--ink); }
label.field { display: grid; gap: 4px; font-size: 13px; font-weight: 600; color: var(--muted); }

/* ---------- Avisos ---------- */
.notice { padding: 10px 14px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 16px; border: 1px solid transparent; }
.notice-ok { background: var(--ok-bg); color: var(--ok); }
.notice-error { background: var(--danger-bg); color: var(--danger); }
.notice-warn { background: var(--warn-bg); color: var(--warn); }
.notice-info { background: var(--info-bg); color: var(--ink-2); }
.notice a { text-decoration: underline; font-weight: 600; }

/* ---------- Encabezado de la lista ---------- */
.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { font-size: 26px; }
.page-head p { color: var(--muted); font-size: 14px; }
.search { margin-left: auto; display: flex; gap: 8px; min-width: min(100%, 360px); }

.tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 14px; scrollbar-width: none; }
.tab {
  display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px;
  background: var(--white); border: 1px solid var(--line); font-size: 14px; font-weight: 600; white-space: nowrap;
}
.tab:hover { border-color: #c9c9ce; }
.tab[aria-current="page"] { background: var(--ink); color: var(--white); border-color: var(--ink); }
.tab .count { font-size: 12px; min-width: 22px; text-align: center; padding: 1px 7px; border-radius: 999px; background: var(--gray); color: var(--ink); }
.tab[aria-current="page"] .count { background: rgba(255, 255, 255, 0.18); color: var(--white); }
.tab .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--wa); }
.tab-hint { color: var(--muted); font-size: 13px; margin: -4px 0 14px; }

/* ---------- Lista ---------- */
.list { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.row { display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; padding: 14px 18px; border-top: 1px solid var(--line); align-items: center; }
.row:first-child { border-top: 0; }
.row:hover { background: #fcfcfd; }
.row-main { min-width: 0; display: grid; gap: 3px; }
.row-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-title a { font-weight: 650; color: var(--ink); font-size: 15.5px; }
.row-title a:hover { text-decoration: underline; }
.row-phone { color: var(--muted); font-size: 13px; }
.row-msg { color: var(--ink-2); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-msg .who { color: var(--muted); }
.row-meta { color: var(--muted); font-size: 12.5px; display: flex; gap: 10px; flex-wrap: wrap; }
.row-side { display: grid; justify-items: end; gap: 8px; }
.elapsed { font-size: 13px; font-weight: 600; color: var(--ink); }
.elapsed.late { color: var(--danger); }
.actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; align-items: center; }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); }

.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 650; padding: 2px 8px; border-radius: 999px; background: var(--gray); color: var(--muted); }
.badge-new { background: var(--wa); color: #06331b; }
.b-sin_responder { background: var(--danger-bg); color: var(--danger); }
.b-sin_respuesta_cliente { background: var(--warn-bg); color: var(--warn); }
.b-seguimiento_pendiente { background: #efe9e1; color: var(--accent); }
.b-respondido { background: var(--ok-bg); color: var(--ok); }
.b-archivado { background: var(--gray); color: var(--muted); }

/* Menú de seguimiento (details/summary, sin JS) */
.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-panel {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; width: 260px; padding: 12px;
  background: var(--white); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); display: grid; gap: 10px;
}
.menu-panel .title { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.menu-panel .presets { display: flex; gap: 6px; flex-wrap: wrap; }
.menu-panel .inline { display: flex; gap: 6px; }
.menu-panel hr { border: 0; border-top: 1px solid var(--line); }

/* ---------- Contacto ---------- */
.back { display: inline-flex; gap: 6px; color: var(--muted); font-size: 14px; margin-bottom: 12px; }
.back:hover { color: var(--ink); }
.contact-head { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 18px; }
.contact-head h1 { font-size: 24px; }
.contact-head .sub { color: var(--muted); font-size: 14px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 4px; }
.contact-head .actions { margin-left: auto; }
.contact-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
.card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card h2 { font-size: 15px; margin-bottom: 12px; }
.stack { display: grid; gap: 12px; }

.thread { display: flex; flex-direction: column; gap: 8px; max-height: 60vh; overflow-y: auto; padding: 4px 2px 8px; }
.bubble { max-width: 78%; padding: 8px 12px; border-radius: 16px; font-size: 14.5px; white-space: pre-wrap; word-wrap: break-word; }
.bubble.in { align-self: flex-start; background: var(--gray); border-bottom-left-radius: 6px; }
.bubble.out { align-self: flex-end; background: var(--ink); color: var(--white); border-bottom-right-radius: 6px; }
.bubble.out.failed { background: var(--danger-bg); color: var(--danger); }
.bubble .meta { display: block; font-size: 11px; opacity: 0.65; margin-top: 3px; text-align: right; }
.bubble .tpl { display: block; font-size: 11px; font-weight: 700; opacity: 0.7; margin-bottom: 2px; }
.day-sep { align-self: center; font-size: 11.5px; color: var(--muted); background: var(--gray); padding: 2px 10px; border-radius: 999px; margin: 6px 0; }

.composer { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 12px; display: grid; gap: 10px; }
.window { font-size: 13px; display: flex; gap: 8px; align-items: center; }
.window .pill { font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.window .open { background: var(--ok-bg); color: var(--ok); }
.window .closed { background: var(--warn-bg); color: var(--warn); }
.tpl-preview { background: var(--gray); border-radius: 12px; padding: 10px 12px; font-size: 13.5px; white-space: pre-wrap; }

.history { display: grid; gap: 10px; font-size: 13.5px; }
.history li { list-style: none; display: grid; gap: 1px; }
.history .when { color: var(--muted); font-size: 12px; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.check { font-weight: 700; }
.check.ok { color: var(--ok); }
.check.no { color: var(--danger); }
table.simple { width: 100%; border-collapse: collapse; font-size: 13px; }
table.simple th, table.simple td { text-align: left; padding: 7px 8px; border-top: 1px solid var(--line); vertical-align: top; }
table.simple th { color: var(--muted); font-weight: 600; border-top: 0; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; background: var(--gray); padding: 2px 6px; border-radius: 6px; word-break: break-all; }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--white); }
.login .card { width: min(100%, 380px); display: grid; gap: 16px; text-align: center; box-shadow: none; border: 1px solid var(--line); }
.login img { height: 72px; width: auto; margin-inline: auto; }

@media (max-width: 860px) {
  .contact-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .brand span { display: none; }
  .row { grid-template-columns: 1fr; }
  .row-side { justify-items: start; }
  .actions { justify-content: flex-start; }
  .menu-panel { left: 0; right: auto; }
  .search { min-width: 100%; }
  .bubble { max-width: 92%; }
}

/* Versión PHP */
.btn-block { width: 100%; }
.tpl-fields { display: grid; gap: 10px; }
