/* ══ Panel del Bot de Ventas — Raíces Sonoras ══
   Tema oscuro con acentos de madera/ámbar, a juego con la marca del taller. */

:root {
  --fondo: #14100c;
  --panel: #1d1712;
  --panel-2: #251d16;
  --borde: #35291f;
  --texto: #f3ece3;
  --texto-suave: #b3a493;
  --ambar: #e0a458;
  --ambar-fuerte: #f0b56b;
  --verde: #6fca87;
  --rojo: #e07a6a;
  --azul: #7ab3e0;
  --sombra: 0 12px 32px rgba(0, 0, 0, 0.45);
  --radio: 14px;
  --fuente-titulo: 'Sora', system-ui, sans-serif;
  --fuente-texto: 'Inter', system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--fuente-texto);
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(224, 164, 88, 0.08), transparent 60%),
    var(--fondo);
  color: var(--texto);
  font-size: 15px;
  line-height: 1.5;
}

.oculto { display: none !important; }

h1, h2, h3, h4 { font-family: var(--fuente-titulo); }

button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; font-size: 14px; }

/* ── Botones ─────────────────────────────────── */
.boton {
  border: 1px solid var(--borde);
  background: var(--panel-2);
  color: var(--texto);
  border-radius: 10px;
  padding: 9px 16px;
  font-weight: 600;
  font-size: 14px;
  transition: 0.15s;
}
.boton:hover { border-color: var(--ambar); color: var(--ambar-fuerte); }
.boton.primario {
  background: linear-gradient(135deg, var(--ambar), #c9853d);
  border: none;
  color: #241708;
}
.boton.primario:hover { filter: brightness(1.08); color: #241708; }
.boton.peligro:hover { border-color: var(--rojo); color: var(--rojo); }
.boton.fantasma { background: transparent; }
.boton.ancho { width: 100%; }
.boton.mini { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.boton:disabled { opacity: 0.5; cursor: wait; }

/* ── Login ───────────────────────────────────── */
.login-fondo {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(900px 500px at 50% -10%, rgba(224, 164, 88, 0.14), transparent 60%),
    var(--fondo);
  padding: 20px;
}
.login-tarjeta {
  width: 100%; max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--borde);
  border-radius: 20px;
  padding: 38px 32px;
  text-align: center;
  box-shadow: var(--sombra);
}
.login-logo { width: 76px; height: 76px; object-fit: contain; border-radius: 18px; margin-bottom: 14px; }
.login-tarjeta h1 { font-size: 24px; letter-spacing: 0.3px; }
.login-sub { color: var(--texto-suave); font-size: 13.5px; margin: 6px 0 22px; }
.login-tarjeta input {
  width: 100%; padding: 12px 14px; margin-bottom: 12px;
  background: var(--panel-2); border: 1px solid var(--borde);
  border-radius: 10px; color: var(--texto);
}
.login-tarjeta input:focus { outline: none; border-color: var(--ambar); }
.login-error { color: var(--rojo); font-size: 13px; margin-top: 12px; min-height: 18px; }

/* ── Estructura ──────────────────────────────── */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 250px; flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--borde);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.marca {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 18px; border-bottom: 1px solid var(--borde);
}
.marca img { width: 44px; height: 44px; object-fit: contain; border-radius: 12px; }
.marca strong { font-family: var(--fuente-titulo); display: block; font-size: 15.5px; }
.marca span { color: var(--texto-suave); font-size: 12px; }

.menu { flex: 1; padding: 14px 10px; overflow-y: auto; }
.menu a {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 13px; margin-bottom: 3px;
  color: var(--texto-suave); text-decoration: none;
  border-radius: 10px; font-weight: 500; font-size: 14.5px;
  transition: 0.15s;
}
.menu a:hover { background: var(--panel-2); color: var(--texto); }
.menu a.activo {
  background: linear-gradient(90deg, rgba(224, 164, 88, 0.16), transparent);
  color: var(--ambar-fuerte);
  border-left: 3px solid var(--ambar);
  padding-left: 10px;
}
.menu .icono { font-size: 17px; width: 22px; text-align: center; }
.chip {
  margin-left: auto; background: var(--ambar); color: #241708;
  font-size: 11px; font-weight: 700; border-radius: 20px; padding: 1px 8px;
}

.sidebar-pie { padding: 14px; border-top: 1px solid var(--borde); }
.estado-pills { display: flex; gap: 8px; margin-bottom: 12px; }
.pill {
  flex: 1; text-align: center; font-size: 11.5px; font-weight: 600;
  padding: 5px 8px; border-radius: 20px;
  background: var(--panel-2); border: 1px solid var(--borde); color: var(--texto-suave);
}
.pill.ok { color: var(--verde); border-color: rgba(111, 202, 135, 0.4); }
.pill.mal { color: var(--rojo); border-color: rgba(224, 122, 106, 0.4); }
.pill::before { content: '● '; font-size: 9px; }

.contenido { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 16px 26px;
  border-bottom: 1px solid var(--borde);
  background: rgba(29, 23, 18, 0.7);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 10;
}
.topbar h2 { font-size: 19px; flex: 1; }
.boton-menu {
  display: none; background: none; border: none; color: var(--texto);
  font-size: 22px;
}

/* Interruptor del bot */
.interruptor { display: flex; align-items: center; gap: 9px; cursor: pointer; font-size: 13.5px; color: var(--texto-suave); font-weight: 600; }
.interruptor input { display: none; }
.pista {
  width: 40px; height: 22px; border-radius: 20px;
  background: var(--panel-2); border: 1px solid var(--borde);
  position: relative; transition: 0.2s;
}
.pista::after {
  content: ''; position: absolute; top: 2px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--texto-suave); transition: 0.2s;
}
.interruptor input:checked + .pista { background: rgba(111, 202, 135, 0.25); border-color: var(--verde); }
.interruptor input:checked + .pista::after { left: 19px; background: var(--verde); }

.vista { padding: 26px; max-width: 1300px; width: 100%; margin: 0 auto; }

/* ── Tarjetas y grids ────────────────────────── */
.grid-kpis {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px; margin-bottom: 22px;
}
.kpi {
  background: var(--panel); border: 1px solid var(--borde);
  border-radius: var(--radio); padding: 18px;
}
.kpi .valor { font-family: var(--fuente-titulo); font-size: 28px; font-weight: 700; color: var(--ambar-fuerte); }
.kpi .nombre { color: var(--texto-suave); font-size: 12.5px; margin-top: 2px; }
.kpi .detalle { color: var(--verde); font-size: 12px; margin-top: 6px; }

.tarjeta {
  background: var(--panel); border: 1px solid var(--borde);
  border-radius: var(--radio); padding: 20px; margin-bottom: 18px;
}
.tarjeta h3 { font-size: 15.5px; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.dos-columnas { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; align-items: start; }

/* Gráfica de barras */
.grafica { display: flex; align-items: flex-end; gap: 5px; height: 130px; padding-top: 8px; }
.grafica .barra {
  flex: 1; min-width: 8px; border-radius: 5px 5px 2px 2px;
  background: linear-gradient(180deg, var(--ambar), rgba(224, 164, 88, 0.25));
  position: relative; transition: 0.3s;
}
.grafica .barra:hover { filter: brightness(1.25); }
.grafica .barra span {
  position: absolute; bottom: -20px; left: 50%; transform: translateX(-50%);
  font-size: 9.5px; color: var(--texto-suave); white-space: nowrap;
}
.grafica-pie { height: 24px; }

/* ── Tablas ──────────────────────────────────── */
.tabla-envoltura { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; color: var(--texto-suave); font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.6px;
  padding: 10px 12px; border-bottom: 1px solid var(--borde);
}
td { padding: 12px; border-bottom: 1px solid rgba(53, 41, 31, 0.55); vertical-align: middle; }
tr:hover td { background: rgba(224, 164, 88, 0.04); }

.etiqueta {
  display: inline-block; font-size: 11.5px; font-weight: 600;
  padding: 3px 10px; border-radius: 20px; margin: 1px 2px;
  background: var(--panel-2); border: 1px solid var(--borde); color: var(--texto-suave);
}
.etiqueta.verde { color: var(--verde); border-color: rgba(111, 202, 135, 0.45); }
.etiqueta.ambar { color: var(--ambar-fuerte); border-color: rgba(224, 164, 88, 0.5); }
.etiqueta.rojo { color: var(--rojo); border-color: rgba(224, 122, 106, 0.45); }
.etiqueta.azul { color: var(--azul); border-color: rgba(122, 179, 224, 0.45); }

/* ── Actividad ───────────────────────────────── */
.linea-tiempo { list-style: none; }
.linea-tiempo li {
  display: flex; gap: 12px; padding: 10px 0;
  border-bottom: 1px solid rgba(53, 41, 31, 0.5);
  font-size: 13.5px;
}
.linea-tiempo .icono-ev { font-size: 16px; width: 24px; text-align: center; flex-shrink: 0; }
.linea-tiempo .cuerpo { flex: 1; min-width: 0; }
.linea-tiempo .texto-ev { word-wrap: break-word; }
.linea-tiempo time { color: var(--texto-suave); font-size: 11.5px; }

/* ── Chats ───────────────────────────────────── */
.chats-layout {
  display: grid; grid-template-columns: 320px 1fr; gap: 18px;
  height: calc(100vh - 150px); min-height: 420px;
}
.lista-chats {
  background: var(--panel); border: 1px solid var(--borde); border-radius: var(--radio);
  overflow-y: auto;
}
.item-chat {
  display: block; width: 100%; text-align: left; background: none; border: none;
  border-bottom: 1px solid rgba(53, 41, 31, 0.5);
  padding: 13px 15px; color: var(--texto); transition: 0.12s;
}
.item-chat:hover { background: var(--panel-2); }
.item-chat.activo { background: rgba(224, 164, 88, 0.1); border-left: 3px solid var(--ambar); padding-left: 12px; }
.item-chat .fila1 { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.item-chat .nombre-chat { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-chat .previa { color: var(--texto-suave); font-size: 12.5px; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.panel-chat {
  background: var(--panel); border: 1px solid var(--borde); border-radius: var(--radio);
  display: flex; flex-direction: column; overflow: hidden;
}
.cabecera-chat {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 14px 18px; border-bottom: 1px solid var(--borde);
}
.cabecera-chat .quien { flex: 1; min-width: 140px; }
.cabecera-chat strong { display: block; }
.cabecera-chat small { color: var(--texto-suave); }
.mensajes { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.burbuja {
  max-width: 72%; padding: 10px 14px; border-radius: 14px;
  font-size: 14px; white-space: pre-wrap; word-wrap: break-word;
}
.burbuja.cliente { align-self: flex-start; background: var(--panel-2); border: 1px solid var(--borde); border-bottom-left-radius: 4px; }
.burbuja.bot { align-self: flex-end; background: rgba(224, 164, 88, 0.16); border: 1px solid rgba(224, 164, 88, 0.35); border-bottom-right-radius: 4px; }
.burbuja.humano { align-self: flex-end; background: rgba(122, 179, 224, 0.14); border: 1px solid rgba(122, 179, 224, 0.4); border-bottom-right-radius: 4px; }
.burbuja .meta-msg { display: block; font-size: 10.5px; color: var(--texto-suave); margin-top: 5px; }
.caja-envio { display: flex; gap: 10px; padding: 14px; border-top: 1px solid var(--borde); }
.caja-envio textarea {
  flex: 1; resize: none; height: 48px;
  background: var(--panel-2); border: 1px solid var(--borde);
  border-radius: 10px; padding: 12px 14px; color: var(--texto);
}
.caja-envio textarea:focus { outline: none; border-color: var(--ambar); }
.vacio-chat { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; color: var(--texto-suave); gap: 8px; }
.vacio-chat .grande { font-size: 42px; }

/* ── Formularios ─────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.campo { display: flex; flex-direction: column; gap: 6px; }
.campo.ancho-total { grid-column: 1 / -1; }
.campo label { font-size: 12.5px; font-weight: 600; color: var(--texto-suave); }
.campo input, .campo select, .campo textarea {
  background: var(--panel-2); border: 1px solid var(--borde);
  border-radius: 10px; padding: 10px 12px; color: var(--texto);
}
.campo input:focus, .campo select:focus, .campo textarea:focus { outline: none; border-color: var(--ambar); }
.campo textarea { resize: vertical; min-height: 70px; }
.acciones-form { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }

/* ── Modal ───────────────────────────────────── */
.modal-fondo {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(10, 7, 5, 0.7); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--borde);
  border-radius: 18px; padding: 26px; box-shadow: var(--sombra);
}
.modal h3 { margin-bottom: 18px; }

/* ── Avisos (toasts) ─────────────────────────── */
.avisos { position: fixed; right: 18px; bottom: 18px; z-index: 60; display: flex; flex-direction: column; gap: 10px; }
.aviso {
  background: var(--panel); border: 1px solid var(--borde); border-left: 4px solid var(--ambar);
  border-radius: 12px; padding: 13px 17px; max-width: 340px;
  box-shadow: var(--sombra); font-size: 13.5px;
  animation: entrar 0.25s ease;
}
.aviso.exito { border-left-color: var(--verde); }
.aviso.error { border-left-color: var(--rojo); }
@keyframes entrar { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Cabecera de vista con acciones */
.cabecera-vista { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.cabecera-vista p { color: var(--texto-suave); font-size: 13.5px; }
.filtros { display: flex; gap: 8px; flex-wrap: wrap; }
.filtros .boton.activo { border-color: var(--ambar); color: var(--ambar-fuerte); }

/* Simulador */
.simulador-caja { max-width: 720px; margin: 0 auto; }
.nota {
  background: rgba(122, 179, 224, 0.08); border: 1px solid rgba(122, 179, 224, 0.3);
  color: var(--texto-suave); border-radius: 12px; padding: 12px 16px; font-size: 13.5px; margin-bottom: 16px;
}

/* ── Responsive ──────────────────────────────── */
@media (max-width: 980px) {
  .dos-columnas { grid-template-columns: 1fr; }
  .chats-layout { grid-template-columns: 1fr; height: auto; }
  .lista-chats { max-height: 280px; }
  .panel-chat { height: 60vh; }
}
@media (max-width: 760px) {
  .sidebar {
    position: fixed; z-index: 30; left: -260px; transition: left 0.22s ease;
    box-shadow: var(--sombra);
  }
  .sidebar.abierta { left: 0; }
  .boton-menu { display: block; }
  .vista { padding: 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .burbuja { max-width: 88%; }
}
