/* Multidata · Plataforma — estilos compartidos de la bandeja y de Redes
   Paleta del sitio institucional (www.multidata.com.ar): tinta como color base,
   magenta como acento, violeta/cian/naranja de apoyo. Tipografía del sistema.
   Mobile-first: los que atienden entran del celular. */

:root {
  /* paleta Multidata */
  --tinta: #1E2A4F;
  --violeta: #5C2E82;
  --magenta: #D4275E;
  --cian: #45C4E6;
  --naranja: #E8892C;

  --primary: var(--tinta);
  --primary-dark: #141C36;
  --primary-soft: #ECEBF5;
  --acento: var(--magenta);
  --acento-dark: #B01E4C;
  --fg: #1E2A4F;
  --bg: #ffffff;
  --muted: #F5F4FA;
  --muted-fg: #4A5878;
  --border: #E4E2EE;
  --whatsapp: hsl(142 70% 49%);
  --danger: hsl(0 84% 60%);
  --radius: 8px;
  --radius-card: 16px;
  --shadow: 0 4px 24px rgba(0, 0, 0, .08);
  --topbar-h: 56px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--muted);
  color: var(--fg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--violeta); }
a:hover { color: var(--acento); }

.oculto { display: none !important; }

/* ---------------- Topbar ---------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--topbar-h);
  padding: 0 12px;
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .15);
}
.topbar .marca { font-weight: 700; font-size: 15px; white-space: nowrap; }
.topbar .marca span { opacity: .8; font-weight: 600; }
.topbar .empresa { font-size: 12px; opacity: .95; font-weight: 600; }
.topbar select.sel-cliente {
  font: inherit; font-size: 12px; font-weight: 600; max-width: 160px;
  padding: 4px 6px; border-radius: 6px; border: 1px solid rgba(255,255,255,.5);
  background: rgba(255,255,255,.12); color: #fff;
}
.topbar select.sel-cliente option { color: #1f2a37; }
.topbar .titulo { font-weight: 700; font-size: 14px; letter-spacing: .2px; }
.topbar .sep { flex: 1; }
.topbar .yo { font-size: 12px; opacity: .95; text-align: right; line-height: 1.25; }
.topbar .yo b { display: block; font-size: 13px; }

.nav {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  background: var(--primary-dark);
  padding: 0 8px;
  position: sticky;
  top: var(--topbar-h);
  z-index: 19;
}
.nav a {
  color: #fff;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 12px;
  white-space: nowrap;
  border-bottom: 3px solid transparent;
  opacity: .82;
}
.nav a.activo { opacity: 1; border-bottom-color: var(--acento); }

/* ---------------- Botones y controles ---------------- */
.btn {
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--fg);
  border-radius: var(--radius);
  padding: 10px 14px;
  cursor: pointer;
  min-height: 42px;
}
.btn:hover { background: var(--muted); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primario { background: var(--acento); border-color: var(--acento); color: #fff; }
.btn-primario:hover { background: var(--acento-dark); }
.btn-chico { padding: 6px 10px; min-height: 34px; font-size: 13px; }
.btn-peligro { color: var(--danger); border-color: var(--danger); }
.btn-full { width: 100%; }
.link-btn {
  background: none; border: 0; color: inherit; font: inherit;
  text-decoration: underline; cursor: pointer; padding: 0;
}

.ctrl {
  font: inherit;
  font-size: 15px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--fg);
  min-height: 42px;
}
.ctrl:focus { outline: 2px solid var(--cian); outline-offset: 1px; }
label.campo { display: block; font-size: 13px; font-weight: 600; margin-bottom: 10px; }
label.campo span { display: block; margin-bottom: 4px; color: var(--muted-fg); }

/* ---------------- Login ---------------- */
.login-wrap {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 16px;
  background:
    radial-gradient(700px 380px at 90% -10%, rgba(69,196,230,.28), transparent 60%),
    radial-gradient(600px 360px at 0% 110%, rgba(212,39,94,.22), transparent 60%),
    linear-gradient(160deg, var(--tinta) 0%, var(--violeta) 100%);
}
.login-caja {
  width: 100%;
  max-width: 380px;
  background: #fff;
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  padding: 24px 20px;
  text-align: center;
}
.login-caja .marca { font-weight: 800; font-size: 20px; color: var(--primary); margin-bottom: 8px; }
.login-caja h1 { font-size: 18px; margin: 0 0 4px; }
.login-caja .sub { color: var(--muted-fg); font-size: 13px; margin: 0 0 18px; }
.login-caja form { text-align: left; }
.error { color: var(--danger); font-size: 13px; margin: 10px 0 0; min-height: 18px; }
.ok { color: hsl(142 60% 30%); font-size: 13px; }

/* ---------------- Layout general ---------------- */
.wrap { max-width: 1100px; margin: 0 auto; padding: 14px 12px 40px; }
.tarjeta {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 14px;
}
.tarjeta h2 { font-size: 15px; margin: 0 0 10px; }
h1.pagina { font-size: 20px; margin: 4px 0 12px; }
.sub { color: var(--muted-fg); font-size: 13px; }
.fila { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.aviso {
  background: var(--primary-soft);
  border: 1px solid var(--primary);
  color: var(--primary-dark);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 12px;
}
.vacio { color: var(--muted-fg); font-size: 14px; padding: 18px; text-align: center; }

/* ---------------- Bandeja ---------------- */
.bandeja {
  display: grid;
  grid-template-columns: 1fr;
  height: calc(100dvh - var(--topbar-h) - 40px);
  background: #fff;
}
.col-lista, .col-chat { display: flex; flex-direction: column; min-height: 0; }
@media (max-width: 799px) {
  .col-lista.esconder-mobile, .col-chat.esconder-mobile { display: none; }
}
@media (min-width: 800px) {
  .bandeja { grid-template-columns: 340px 1fr; border-top: 1px solid var(--border); }
  .col-lista { border-right: 1px solid var(--border); }
  .col-lista.esconder-mobile, .col-chat.esconder-mobile { display: flex; }
  .btn-volver { display: none !important; }
}

.filtros { padding: 10px; border-bottom: 1px solid var(--border); background: var(--muted); }
.filtros .tabs { display: flex; gap: 6px; margin-top: 8px; }
.filtros .tabs button {
  flex: 1; font: inherit; font-size: 13px; font-weight: 600;
  padding: 8px 4px; border: 1px solid var(--border); background: #fff;
  border-radius: var(--radius); cursor: pointer;
}
.filtros .tabs button.activo { background: var(--acento); border-color: var(--acento); color: #fff; }

.lista { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.conv {
  display: block; width: 100%; text-align: left;
  border: 0; border-bottom: 1px solid var(--border);
  background: #fff; padding: 10px 12px; cursor: pointer; font: inherit;
}
.conv:hover { background: var(--muted); }
.conv.activa { background: var(--primary-soft); }
.conv .linea1 { display: flex; align-items: baseline; gap: 8px; }
.conv .nombre { font-weight: 700; font-size: 14px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv .hora { font-size: 11px; color: var(--muted-fg); white-space: nowrap; }
.conv .prev { font-size: 13px; color: var(--muted-fg); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv .linea3 { margin-top: 5px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

.chip {
  font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  background: var(--muted); color: var(--muted-fg); border: 1px solid var(--border);
}
.chip-estado { background: var(--primary-soft); color: var(--primary-dark); border-color: var(--primary-soft); }
.chip-no-leidos { background: var(--whatsapp); color: #fff; border-color: var(--whatsapp); }

/* Hilo */
.chat-head {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-bottom: 1px solid var(--border); background: var(--muted);
}
.chat-head h2 { font-size: 15px; margin: 0; }
.chat-head .meta { font-size: 12px; color: var(--muted-fg); }
.btn-volver { border: 0; background: none; font-size: 22px; cursor: pointer; padding: 0 6px; line-height: 1; }

.mensajes {
  flex: 1; overflow-y: auto; padding: 12px;
  background: #efe7e1;
  display: flex; flex-direction: column; gap: 6px;
}
.dia {
  align-self: center; font-size: 11px; font-weight: 700; color: var(--muted-fg);
  background: #fff; border-radius: 999px; padding: 3px 10px; margin: 6px 0;
}
.msg {
  max-width: 86%; padding: 7px 10px; border-radius: 10px; font-size: 14px;
  white-space: pre-wrap; word-break: break-word; box-shadow: 0 1px 1px rgba(0,0,0,.1);
}
.msg.in { align-self: flex-start; background: #fff; }
.msg.out { align-self: flex-end; background: #d8fdd2; }
.msg.nota { align-self: center; background: #fff5c2; border: 1px dashed #d6b600; max-width: 92%; font-size: 13px; }
.msg .pie { font-size: 10px; color: var(--muted-fg); margin-top: 3px; text-align: right; }

.redactor { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--border); background: var(--muted); }
.redactor textarea { resize: none; max-height: 120px; }
.acciones-hilo { display: flex; gap: 6px; flex-wrap: wrap; padding: 8px 10px; border-top: 1px solid var(--border); background: #fff; }

/* ---------------- KPIs / tablas / barras ---------------- */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
@media (min-width: 700px) { .kpis { grid-template-columns: repeat(5, 1fr); } }
.kpi {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius-card);
  padding: 12px; text-align: center; box-shadow: var(--shadow);
}
.kpi .valor { font-size: 24px; font-weight: 800; color: var(--primary); line-height: 1.1; }
.kpi .rotulo { font-size: 12px; color: var(--muted-fg); margin-top: 4px; }

.barra-fila { margin-bottom: 8px; }
.barra-fila .rot { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 3px; }
.barra { height: 10px; background: var(--muted); border-radius: 999px; overflow: hidden; }
.barra > span { display: block; height: 100%; background: linear-gradient(90deg, var(--violeta), var(--acento)); }

.tabla-cont { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { background: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted-fg); }

/* En el celular la tabla se vuelve una lista de fichas: si no, las acciones
   quedan fuera de la pantalla. */
@media (max-width: 699px) {
  table.responsive, table.responsive tbody, table.responsive tr, table.responsive td { display: block; width: 100%; }
  table.responsive thead { display: none; }
  table.responsive tr { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 10px; padding: 4px 0; }
  table.responsive td { border: 0; white-space: normal; display: flex; justify-content: space-between; gap: 10px; padding: 6px 10px; }
  table.responsive td::before {
    content: attr(data-rot); font-size: 11px; text-transform: uppercase;
    letter-spacing: .4px; color: var(--muted-fg); font-weight: 700; flex: 0 0 auto;
  }
  table.responsive td.acciones { display: flex; flex-wrap: wrap; justify-content: flex-start; }
  table.responsive td.acciones::before { flex-basis: 100%; }
}

/* ---------------- Novedades ---------------- */
.novedad { background: #fff; border: 1px solid var(--border); border-radius: var(--radius-card); padding: 14px; margin-bottom: 12px; box-shadow: var(--shadow); }
.novedad h3 { margin: 0 0 4px; font-size: 16px; }
.novedad .meta { font-size: 12px; color: var(--muted-fg); margin-bottom: 8px; }
.novedad .cuerpo { white-space: pre-wrap; font-size: 14px; line-height: 1.5; }

/* ---------------- Toast ---------------- */
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  background: rgba(0, 0, 0, .88); color: #fff; padding: 10px 16px;
  border-radius: 999px; font-size: 13px; z-index: 99; max-width: 90vw; text-align: center;
}

/* ---------------- Marca Multidata ---------------- */
.topbar .marca img { height: 22px; width: auto; display: block; }
.login-caja .marca img { height: 34px; width: auto; display: block; margin: 0 auto; }

/* ---------------- Redes ---------------- */
.tabs-redes { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 14px; }
.tabs-redes button {
  font: inherit; font-weight: 600; font-size: 13px; cursor: pointer;
  padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border); background: #fff; color: var(--fg);
}
.tabs-redes button.activo { background: var(--acento); border-color: var(--acento); color: #fff; }
.item-red { background: #fff; border: 1px solid var(--border); border-radius: var(--radius-card); padding: 14px; margin-bottom: 12px; box-shadow: var(--shadow); }
.item-red h3 { margin: 0 0 4px; font-size: 15px; }
.item-red .meta { font-size: 12px; color: var(--muted-fg); }
.item-red .cuerpo { white-space: pre-wrap; word-break: break-word; margin: 8px 0; }
.item-red .hilo { border-left: 3px solid var(--primary-soft); margin: 8px 0 0; padding-left: 10px; }
.item-red .renglon { font-size: 13px; margin: 6px 0; }
.item-red .responder { display: flex; gap: 6px; margin-top: 6px; }
.item-red .responder .ctrl { flex: 1; min-width: 0; }
.pastilla { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); margin-right: 4px; }
.pastilla.ig { background: rgba(212,39,94,.1); color: var(--magenta); }
.pastilla.ads { background: rgba(232,137,44,.14); color: #8a4a0c; }
