/* TissueArg - Navegacion: menu lateral, cajon en celular y paneles laterales.
   Federico Gomez Arevalo - federicogomez1989@gmail.com
   Usa los tokens de app.css (estetica premium). */

:root { --sb: 244px; --tb: 58px; --bb: 64px; }

/* ---------- menu lateral ---------- */
.sb { --txt: #ffffff; --mute: #c3d0e2; --dim: #8fa3c0; --line: rgba(255,255,255,.12); --acc: #ffffff; --acc-txt: #ffffff;
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--sb); background: #153e76; border-right: 1px solid #0f2f5c;
  display: flex; flex-direction: column; z-index: 35; overflow-y: auto; }
.sb-head { padding: 26px 24px 20px; border-bottom: 1px solid var(--line); }
.sb-head .brand { display: block; }
.sb-logo { display: block; width: 172px; height: auto; }
.sb-pie .prueba { color: #ffd98a; border-color: #ffd98a; }
.sb-grupo > span { opacity: .75; }
.sb-head .sb-sub { display: block; margin-top: 12px; font-family: var(--f-display); font-size: 12px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--mute); }
.sb-grupo { padding: 18px 0 6px; }
.sb-grupo > span { display: block; padding: 0 24px 8px; font-family: var(--f-mono); font-size: 10px; letter-spacing: .22em; text-transform: uppercase; color: var(--acc-txt); }
.sb a.sb-item { display: flex; align-items: center; gap: 10px; padding: 10px 24px 10px 22px; border-left: 2px solid transparent; color: var(--mute);
  text-decoration: none; font-size: 14px; transition: color .15s, background .15s, border-color .15s; }
.sb a.sb-item:hover { color: #fff; background: rgba(255, 255, 255, .07); }
.sb a.sb-item.on { color: #fff; border-left-color: #fff; background: rgba(255, 255, 255, .13); font-weight: 600; }
.sb a.sb-item small { margin-left: auto; font-family: var(--f-mono); font-size: 9px; letter-spacing: .14em; color: var(--dim); }
.sb-pie { margin-top: auto; padding: 18px 24px 22px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 12px; }
.sb-pie .prueba { align-self: flex-start; }
.sb-pie .firma { font-size: 8px; line-height: 1.6; }

body.con-sb { padding-left: var(--sb); }
body.con-sb .top { display: none; }
body.con-sb .tabs { display: none; }
body.con-sb .wrap { padding-top: 34px; }

/* ---------- barra superior y cajon (celular) ---------- */
.tb { display: none; }
.sb-velo { display: none; }
.bb { display: none; }

@media (max-width: 900px) {
  body.con-sb { padding-left: 0; padding-top: var(--tb); padding-bottom: calc(var(--bb) + env(safe-area-inset-bottom, 0px)); }
  .sb { transform: translateX(-100%); transition: transform .25s ease; width: min(300px, 86vw); box-shadow: none; z-index: 61; }
  body.sb-abierto .sb { transform: none; box-shadow: 20px 0 60px rgba(0, 0, 0, .6); }
  .sb-velo { display: block; position: fixed; inset: 0; background: rgba(13, 27, 48, .5); z-index: 60; opacity: 0; pointer-events: none; transition: opacity .25s; }
  body.sb-abierto .sb-velo { opacity: 1; pointer-events: auto; }
  body.sb-abierto { overflow: hidden; }

  .tb { display: flex; align-items: center; gap: 12px; position: fixed; top: 0; left: 0; right: 0; height: var(--tb); padding: 0 12px 0 6px;
    background: #153e76; border-bottom: 1px solid #0f2f5c; z-index: 34; }
  .tb-menu { width: 46px; height: 46px; padding: 0; border: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; background: none; }
  .tb-menu i { display: block; width: 22px; height: 2px; border-radius: 2px; background: #fff; }
  .tb-menu:hover { background: none; }
  .tb-tit { flex: 1; min-width: 0; }
  .tb-icono { width: 30px; height: 30px; border-radius: 50%; background: #fff; padding: 3px; flex: none; }
  .tb-tit b { display: block; font-family: var(--f-display); font-size: 9px; letter-spacing: .24em; color: #c3d0e2; font-weight: 700; }
  .tb-tit span { display: block; font-family: var(--f-display); font-size: 19px; font-weight: 700; line-height: 1.2; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  .bb { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--bb) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px); background: #fff; border-top: 1px solid var(--line); z-index: 34; box-shadow: 0 -4px 16px rgba(17,35,64,.06); }
  .bb a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-decoration: none; color: var(--mute);
    font-family: var(--f-display); font-size: 9px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; border-top: 2px solid transparent; }
  .bb a svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.7; }
  .bb a.on { color: #153e76; border-top-color: #153e76; font-weight: 700; }

  body.con-sb .wrap { padding: 18px 14px 40px; }
  body.con-sb h1 { font-size: 28px; }
  /* las grillas armadas en linea se apilan */
  body.con-sb .wrap [style*="grid-template-columns"] { grid-template-columns: 1fr !important; }
  body.con-sb .g4 { grid-template-columns: 1fr 1fr; }
  body.con-sb .kpi .val { font-size: 26px; }
  body.con-sb .card { padding: 16px; }
  body.con-sb .row { gap: 8px; }
  body.con-sb .card, body.con-sb .modal { overflow-x: auto; }
  body.con-sb table { font-size: 13px; }
  body.con-sb td, body.con-sb th { padding: 10px 6px; }
  body.con-sb #pc-btn { bottom: calc(var(--bb) + 12px); }
  body.con-sb .toast { bottom: calc(var(--bb) + 16px); width: max-content; max-width: 92vw; }
  body.con-sb button, body.con-sb .btn { padding: 12px 14px; }
  body.con-sb .btn-sm { padding: 9px 11px; }
}

/* ---------- panel lateral (detalle que se abre desde la derecha) ---------- */
.pl-velo { position: fixed; inset: 0; background: rgba(13, 27, 48, .4); z-index: 45; opacity: 0; transition: opacity .22s; }
.pl { position: fixed; top: 0; right: 0; bottom: 0; width: min(var(--pl-ancho, 760px), 94vw); background: var(--bg); border-left: 4px solid #153e76;
  z-index: 46; display: flex; flex-direction: column; transform: translateX(100%); transition: transform .26s ease; box-shadow: -24px 0 70px rgba(13, 27, 48, .25); }
.pl.abierto { transform: none; }
.pl-velo.abierto { opacity: 1; }
.pl-cab { display: flex; align-items: center; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--line); background: #fff; }
.pl-cab .pl-tit { flex: 1; min-width: 0; }
.pl-cab .pl-tit b { display: block; font-family: var(--f-mono); font-size: 9px; letter-spacing: .24em; color: var(--acc-txt); font-weight: 500; text-transform: uppercase; }
.pl-cab .pl-tit span { display: block; font-family: var(--f-display); font-weight: 800; font-size: 24px; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-x { width: 42px; height: 42px; padding: 0; font-size: 20px; letter-spacing: 0; line-height: 1; }
.pl-cuerpo { flex: 1; overflow-y: auto; padding: 20px 22px 40px; -webkit-overflow-scrolling: touch; }
.pl-cuerpo .card { padding: 18px; }
body.pl-abierto { overflow: hidden; }
@media (max-width: 900px) {
  .pl { width: 100vw; border-left: 0; }
  .pl-cab { padding: 10px 12px; }
  .pl-cab .pl-tit span { font-size: 22px; }
  .pl-cuerpo { padding: 14px 14px calc(30px + env(safe-area-inset-bottom, 0px)); }
}

/* ventanas y avisos por encima de menus y paneles */
.modal-bg { z-index: 70; }
.toast { z-index: 80; }
.tip { z-index: 75; }
@media (max-width: 900px) { .pl-cuerpo [style*="grid-template-columns"] { grid-template-columns: 1fr !important; } }

/* celular: renglones de factura como tarjetas, sin scroll lateral */
@media (max-width: 900px) {
  body.con-sb #pc-btn { display: none; }
  .pl-cuerpo .g2 { grid-template-columns: 1fr 1fr; }
  .pl-cuerpo .kpi .val { font-size: 24px; }
  table:has(#f-items) thead { display: none; }
  #f-items tr { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
  #f-items td { border: 0; padding: 0; text-align: left !important; }
  #f-items td:nth-child(1) { grid-column: 1 / -1; }
  #f-items td:nth-child(n+2):nth-child(-n+6)::before { display: block; font-family: var(--f-mono); font-size: 9px; letter-spacing: .16em; text-transform: uppercase; color: var(--mute); margin-bottom: 6px; }
  #f-items td:nth-child(2)::before { content: "Stock"; }
  #f-items td:nth-child(3)::before { content: "Bultos"; }
  #f-items td:nth-child(4)::before { content: "Precio x bulto"; }
  #f-items td:nth-child(5)::before { content: "Desc. %"; }
  #f-items td:nth-child(6)::before { content: "Subtotal"; }
  #f-items td:nth-child(2), #f-items td:nth-child(6) { align-self: end; font-size: 16px; }
  #f-items td:nth-child(7) { grid-column: 1 / -1; text-align: right !important; }
}
@media (max-width: 900px) {
  table:has(#ct-body) th:nth-child(2), #ct-body td:nth-child(2),
  table:has(#ct-body) th:nth-child(5), #ct-body td:nth-child(5),
  table:has(#ct-body) th:nth-child(6), #ct-body td:nth-child(6) { display: none; }
}
