/* ============================================================
   Portal Comercial Naturinda
   Paleta: invernadero + rojo Naturinda
   ============================================================ */
:root {
  --verde-inv:  #14342B;   /* sidebar, verde invernadero profundo */
  --verde-humo: #1E4438;   /* hover sidebar */
  --brote:      #3E7C59;   /* verde secundario, éxito */
  --rojo-nat:   #D32F2F;   /* rojo marca Naturinda */
  --papel:      #F6F5F1;   /* fondo cálido */
  --blanco:     #FFFFFF;
  --tinta:      #1C1F1D;
  --tinta-2:    #5C635E;
  --niebla:     #E4E2DA;   /* bordes */
  --sombra: 0 1px 3px rgba(20,52,43,.08);
  --f-display: "Archivo", sans-serif;
  --f-body: "Inter", sans-serif;
  --f-mono: "IBM Plex Mono", monospace;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--f-body); font-size: 14px; color: var(--tinta);
  background: var(--papel); display: flex; overflow: hidden;
}
button { font-family: inherit; cursor: pointer; }

/* ---------------- sidebar ---------------- */
.nav {
  width: 232px; flex: 0 0 232px; background: var(--verde-inv); color: #E9EFEA;
  display: flex; flex-direction: column; padding: 18px 0 12px; min-height: 0;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 16px 16px; }
.brand-mark {
  width: 34px; height: 34px; flex: 0 0 34px; border-radius: 8px;
  background: var(--rojo-nat); color: #fff; font-family: var(--f-display);
  font-weight: 800; font-size: 20px; display: grid; place-items: center;
}
.brand-text { line-height: 1.15; }
.brand-text strong { font-family: var(--f-display); font-weight: 700; letter-spacing: .06em; font-size: 14px; display: block; }
.brand-text span { font-size: 11px; color: #A9BFB2; }

.tabs { display: flex; flex-direction: column; gap: 2px; padding: 0 10px; }
.tab {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: none; border: 0; color: #C9D6CD; text-align: left;
  padding: 9px 12px; border-radius: 8px; font-size: 13.5px; font-weight: 500;
  border-left: 3px solid transparent;
}
.tab:hover { background: var(--verde-humo); color: #fff; }
.tab.active { background: var(--verde-humo); color: #fff; border-left-color: var(--rojo-nat); }
.tab-ico { width: 18px; text-align: center; opacity: .85; }
.nav-foot { padding: 10px 16px 0; font-size: 11.5px; color: #7E988A; border-top: 1px solid rgba(255,255,255,.08); }

/* ------- conversaciones dentro del sidebar ------- */
.nav-convs {
  flex: 1; min-height: 0; display: flex; flex-direction: column;
  margin-top: 14px; padding-top: 6px; border-top: 1px solid rgba(255,255,255,.08);
}
.btn-nueva {
  margin: 8px 14px 8px; padding: 8px 12px; border: 0; border-radius: 8px;
  background: var(--rojo-nat); color: #fff; font-weight: 600; font-size: 12.5px;
}
.btn-nueva:hover { filter: brightness(1.08); }
.convs-scroll { overflow-y: auto; flex: 1; padding-bottom: 10px; min-height: 0; }
.convs-scroll::-webkit-scrollbar { width: 8px; }
.convs-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 4px; }
.convs-grupo h4 {
  font-family: var(--f-display); font-size: 10.5px; font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase; color: #7E988A;
  padding: 12px 16px 4px;
}
.convs-grupo ul { list-style: none; }
.convs-grupo li {
  padding: 6px 16px; font-size: 12.5px; cursor: pointer; color: #C9D6CD;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  border-left: 3px solid transparent;
}
.convs-grupo li:hover { background: var(--verde-humo); color: #fff; }
.convs-grupo li.activa { background: var(--verde-humo); color: #fff; border-left-color: var(--rojo-nat); font-weight: 600; }
.convs-grupo li.top-cli { color: #A9BFB2; }
.convs-grupo li.top-cli:hover { color: #fff; }

/* ---------------- layout paneles ---------------- */
.content { flex: 1; display: flex; min-width: 0; }
.panel { flex: 1; display: flex; min-width: 0; }
.panel.oculto { display: none; }
.placeholder { margin: auto; max-width: 420px; text-align: center; color: var(--tinta-2); }
.placeholder h2 { font-family: var(--f-display); font-weight: 700; color: var(--tinta); margin-bottom: 8px; }

/* ---------------- chat ---------------- */
.chat { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-head { padding: 16px 26px 12px; border-bottom: 1px solid var(--niebla); background: var(--papel); }
.chat-head h2 { font-family: var(--f-display); font-weight: 700; font-size: 18px; }
.chat-sub { font-size: 12px; color: var(--tinta-2); }
.chat-scroll { flex: 1; overflow-y: auto; padding: 22px 26px; }

.vacio { max-width: 520px; margin: 12vh auto 0; text-align: center; color: var(--tinta-2); }
.vacio-titulo { font-family: var(--f-display); font-weight: 700; font-size: 20px; color: var(--tinta); margin-bottom: 8px; }

.sep-dia {
  display: flex; align-items: center; gap: 12px; margin: 18px 0 12px;
  font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--tinta-2);
}
.sep-dia::before, .sep-dia::after { content: ""; flex: 1; height: 1px; background: var(--niebla); }

.msg { max-width: 78%; margin-bottom: 14px; line-height: 1.5; white-space: pre-wrap; word-wrap: break-word; }
.msg.user {
  margin-left: auto; background: var(--verde-inv); color: #F0F5F1;
  padding: 10px 14px; border-radius: 14px 14px 4px 14px;
}
.msg.assistant { margin-right: auto; padding: 2px 0; }
.msg .cursor { display: inline-block; width: 8px; height: 15px; background: var(--rojo-nat); animation: parp 1s steps(1) infinite; vertical-align: text-bottom; }
@keyframes parp { 50% { opacity: 0; } }
.tool-chip {
  display: inline-block; font-size: 11px; color: var(--tinta-2);
  background: var(--blanco); border: 1px solid var(--niebla); border-radius: 20px;
  padding: 2px 10px; margin-bottom: 10px;
}

/* --------- elemento firma: ticket de albarán --------- */
.ticket {
  max-width: 520px; margin: 6px 0 18px; background: var(--blanco);
  border: 1px solid var(--niebla); border-top: 2px dashed var(--brote);
  border-radius: 0 0 10px 10px; box-shadow: var(--sombra); overflow: hidden;
}
.ticket-head {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 10px 14px 8px; border-bottom: 1px solid var(--niebla);
}
.ticket-head .t-cli { font-family: var(--f-display); font-weight: 700; font-size: 13px; }
.ticket-head .t-cli small { display: block; font-family: var(--f-mono); font-size: 10px; color: var(--tinta-2); font-weight: 500; }
.sello {
  font-family: var(--f-display); font-weight: 700; font-size: 11px; letter-spacing: .04em;
  color: #fff; background: var(--brote); border-radius: 20px;
  padding: 4px 11px; white-space: nowrap;
}
.ticket table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.ticket td, .ticket th { padding: 6px 14px; text-align: left; }
.ticket th { font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--tinta-2); font-weight: 600; border-bottom: 1px solid var(--niebla); }
.ticket td.mono { font-family: var(--f-mono); font-size: 12px; }
.ticket tr + tr td { border-top: 1px dotted var(--niebla); }
.ticket .t-obs td { font-size: 11px; color: var(--rojo-nat); padding-top: 0; border-top: 0; }
.ticket-foot { padding: 7px 14px; font-family: var(--f-mono); font-size: 10.5px; color: var(--tinta-2); background: var(--papel); }

/* ---------------- input ---------------- */
.chat-input {
  display: flex; gap: 10px; align-items: flex-end;
  padding: 14px 26px 18px; border-top: 1px solid var(--niebla); background: var(--papel);
}
.chat-input textarea {
  flex: 1; resize: none; border: 1px solid var(--niebla); border-radius: 12px;
  background: var(--blanco); padding: 11px 14px; font-family: var(--f-body);
  font-size: 14px; line-height: 1.45; max-height: 180px; outline: none;
}
.chat-input textarea:focus { border-color: var(--brote); box-shadow: 0 0 0 3px rgba(62,124,89,.12); }
.chat-input button {
  width: 42px; height: 42px; border: 0; border-radius: 12px;
  background: var(--rojo-nat); color: #fff; font-size: 16px;
}
.chat-input button:disabled { background: var(--niebla); color: var(--tinta-2); cursor: default; }

.aviso-error { max-width: 78%; margin: 0 0 14px; padding: 8px 12px; border-radius: 8px; background: #FBEAEA; color: #8E1F1F; font-size: 12.5px; }

/* ---------------- responsive (ventana ERP pequeña) ---------------- */
@media (max-width: 760px) {
  .nav { width: 56px; flex-basis: 56px; }
  .brand-text, .tab-txt, .nav-foot, .nav-convs { display: none; }
  .tab { justify-content: center; padding: 12px 0; }
  .msg { max-width: 92%; }
}
@media (prefers-reduced-motion: reduce) {
  .msg .cursor { animation: none; }
}

/* foco visible teclado */
.tab:focus-visible, .btn-nueva:focus-visible, .chat-input button:focus-visible,
.convs-grupo li:focus-visible { outline: 2px solid var(--rojo-nat); outline-offset: 2px; }
