/* Shell agent-first de Proveemás (/app): la conversación es la pantalla raíz.
   Reutiliza de styles.css las burbujas, chips, botones, tarjetas y la modal; aquí solo va el layout.
   Móvil: una vista a la vez + barra inferior. Escritorio (≥ 960px): conversación + panel lateral, ancho real. */

html, body.shell-body { height: 100%; }
body.shell-body { margin: 0; overflow: hidden; overscroll-behavior: none; }

.shell {
  height: 100vh; height: 100dvh;
  display: flex; flex-direction: column;
  background: var(--ground);
}

/* ---------- cabecera ---------- */
.sh-top {
  display: flex; align-items: center; gap: 12px;
  padding: calc(8px + env(safe-area-inset-top)) 14px 8px;
  background: var(--surface); border-bottom: 1px solid var(--line);
  flex: none;
}
.sh-top .wordmark { font-size: 20px; }
.sh-agent { display: flex; align-items: center; gap: 9px; min-width: 0; margin-left: 2px; }
.avatar.sm { width: 32px; height: 32px; border-radius: 10px; }
.avatar.sm svg { width: 18px; height: 18px; }
.sh-agent .who b { display: block; font-family: 'Bricolage', sans-serif; font-weight: 700; font-size: 14.5px; line-height: 1.15; }
.sh-agent .who > span { font-size: 12px; color: var(--muted); white-space: nowrap; }
.sh-top .topnav { margin-left: auto; }
.sh-top .userchip { padding: 6px 12px; font-size: 13px; }
#sh-dot.off { background: var(--muted); }

/* ---------- vistas ---------- */
.sh-main { flex: 1; min-height: 0; display: flex; }
.view { display: none; flex-direction: column; min-height: 0; width: 100%; }
.view.on { display: flex; }
.view[hidden] { display: none; }

/* conversación: los mensajes ocupan el alto disponible */
.view-chat .msgs {
  flex: 1; height: auto; min-height: 0;
  padding: 16px 14px 8px;
}
.view-chat .chips { padding: 4px 14px 8px; flex: none; }
.view-chat .inbar {
  flex: none; padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--surface); align-items: center;
}
.view-chat .inbar input { min-width: 0; }
.micbtn {
  width: 44px; height: 44px; border-radius: 50%; border: 1.5px solid var(--line); flex: none;
  background: var(--surface2); color: var(--ok); cursor: pointer;
  display: grid; place-items: center; transition: border-color .12s, transform .12s;
}
.micbtn:hover { border-color: var(--ok); transform: translateY(-1px); }
.micbtn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.micbtn svg { width: 20px; height: 20px; }
.view-chat .send { width: 44px; height: 44px; padding: 0; border-radius: 50%; display: grid; place-items: center; flex: none; }
.view-chat .send svg { width: 20px; height: 20px; }
.view-chat .msg { max-width: 92%; }
.view-chat .msg.bot { font-size: 15px; }

/* paneles (cotizaciones, cuenta) */
.view-panel { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 16px 16px 8px;
}
.panel-head h2 { margin: 0; font-size: 20px; font-weight: 800; letter-spacing: -.02em; }
.panel-body { padding: 4px 14px 24px; }
.panel-body .empty { padding: 34px 10px; }
.panel-body .empty .btn { margin-top: 14px; }

/* tarjeta de pedido */
.ped {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 14px 16px; margin-bottom: 12px;
}
.ped-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.ped-head b { font-family: 'Bricolage', sans-serif; font-size: 16px; font-weight: 700; }
.ped-head .meta { color: var(--muted); font-size: 12.5px; margin-left: auto; }
.ped-detalle { color: var(--muted); font-size: 14px; margin: 0 0 10px; }
.q {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center;
  padding: 9px 0; border-top: 1px solid var(--line); font-size: 14px;
}
.q .nombre { font-weight: 600; }
.q .badge { justify-self: end; }
.q .analisis { grid-column: 1 / -1; font-size: 13.5px; color: var(--muted); margin-top: 2px; }
.q .analisis b { color: var(--ink); font-weight: 600; }
.q .datos { display: flex; gap: 6px; flex-wrap: wrap; grid-column: 1 / -1; margin-top: 4px; }
.q .datos i {
  font-style: normal; font-size: 12px; padding: 3px 9px; border-radius: 999px;
  background: var(--surface2); border: 1px solid var(--line); color: var(--ink);
}
.ped-reco {
  margin-top: 10px; padding: 10px 12px; border-radius: 10px; font-size: 13.5px;
  background: var(--ok-soft); color: var(--ink); border: 1px solid transparent;
}
.ped-reco b { color: var(--ok); }

/* cuenta */
.cuenta-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 18px; margin-bottom: 12px; }
.cuenta-card b.nombre { display: block; font-family: 'Bricolage', sans-serif; font-size: 20px; font-weight: 800; letter-spacing: -.02em; }
.cuenta-card .sub { color: var(--muted); font-size: 14px; margin: 2px 0 14px; }
.cuenta-acts { display: flex; gap: 8px; flex-wrap: wrap; }
.cuenta-meta { color: var(--muted); font-size: 12px; margin-top: 16px; }

/* ---------- barra inferior ---------- */
.sh-nav {
  flex: none; display: grid; grid-template-columns: repeat(3, 1fr);
  background: var(--surface); border-top: 1px solid var(--line);
  padding: 4px 6px calc(4px + env(safe-area-inset-bottom));
}
.tab-btn {
  position: relative; font: inherit; font-size: 11.5px; font-weight: 600; color: var(--muted);
  background: none; border: 0; border-radius: 12px; padding: 6px 4px 5px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.tab-btn svg { width: 22px; height: 22px; }
.tab-btn.on { color: var(--accent-deep); }
@media (prefers-color-scheme: dark) { .tab-btn.on { color: var(--accent); } }
.tab-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
.tab-badge {
  position: absolute; top: 4px; right: calc(50% - 22px);
  min-width: 18px; height: 18px; border-radius: 9px; padding: 0 5px;
  background: var(--accent-deep); color: #fff; font-style: normal; font-size: 11px; font-weight: 700;
  display: grid; place-items: center;
}
.tab-badge[hidden] { display: none; }

/* ---------- banner de instalación ---------- */
.install {
  position: fixed; left: 12px; right: 12px; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 40;
  background: var(--band); color: var(--band-ink); border-radius: 16px; padding: 14px 16px;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  box-shadow: 0 16px 40px rgba(0, 0, 0, .35); animation: pop .2s ease;
}
.install[hidden] { display: none; }
.install-txt { flex: 1; min-width: 200px; }
.install-txt b { display: block; font-family: 'Bricolage', sans-serif; font-size: 15px; }
.install-txt span { font-size: 13px; opacity: .8; }
.install-acts { display: flex; gap: 8px; }
.install .btn-ghost { color: var(--band-ink); border-color: rgba(255, 255, 255, .3); }

/* aviso breve (toast) */
.toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: var(--ground); font-size: 13.5px; font-weight: 600;
  padding: 10px 16px; border-radius: 999px; z-index: 45; box-shadow: var(--shadow);
  animation: pop .18s ease;
}

/* ---------- escritorio: conversación + panel lateral, ancho real ---------- */
@media (min-width: 960px) {
  .sh-top { padding: 12px 24px; }
  .sh-top .wordmark { font-size: 24px; }
  .sh-main {
    display: grid; grid-template-columns: minmax(0, 1fr) 380px;
    max-width: 1280px; width: 100%; margin: 0 auto; gap: 0;
  }
  .view-chat { display: flex !important; border-right: 1px solid var(--line); }
  .view-chat .msgs { padding: 24px 28px 10px; }
  .view-chat .msg { max-width: 78%; }
  .view-chat .chips, .view-chat .inbar { padding-left: 24px; padding-right: 24px; }
  .view-panel { background: var(--surface2); }
  .view-panel:not(.on) { display: none; }
  .sh-nav {
    position: absolute; top: calc(8px + env(safe-area-inset-top)); right: 24px;
    grid-template-columns: auto auto; gap: 4px; border: 1px solid var(--line); border-top: 1px solid var(--line);
    border-radius: 12px; padding: 3px; background: var(--surface2);
  }
  .sh-nav .tab-btn[data-view="chat"] { display: none; }
  .tab-btn { flex-direction: row; gap: 7px; padding: 7px 12px; font-size: 13px; border-radius: 9px; }
  .tab-btn svg { width: 18px; height: 18px; }
  .tab-btn.on { background: var(--surface); color: var(--ink); box-shadow: 0 2px 6px rgba(19,43,42,.08); }
  .tab-badge { position: static; margin-left: 2px; }
  .sh-top { position: relative; }
  .sh-top .topnav { margin-right: 250px; }
  .install { left: auto; right: 24px; bottom: 24px; max-width: 420px; }
  .toast { bottom: 90px; }
}
@media (min-width: 1200px) {
  .sh-main { grid-template-columns: minmax(0, 1fr) 440px; }
}
