/* Multi Gás — Entregas
 * Tokens do Design System Multi Gás (multigassorriso/claude/design-system-multigas.md).
 * Fontes hospedadas aqui mesmo: a CSP nao libera dominio externo.
 */

@font-face { font-family: 'Signika'; font-weight: 700; font-display: swap; src: url('/fonts/signika-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 400; font-display: swap; src: url('/fonts/inter-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 600; font-display: swap; src: url('/fonts/inter-latin-600-normal.woff2') format('woff2'); }

:root {
  /* Marca */
  --brand-blue-dark: #054A6D;
  --brand-blue:      #0986C6;
  --brand-red:       #DA251D;
  --white:           #FFFFFF;

  /* Produto */
  --gas-blue:        #0040A8;
  --badge-red:       #E30613;

  /* Ambiente / neutros */
  --tile-blue:       #5FA8D6;
  --surface:         #F4F8FB;
  --text:            #1A2B36;
  --text-muted:      #4A6373;
  --border:          #E1ECF4;

  --grad-hero: linear-gradient(135deg, #054A6D 0%, #0986C6 100%);

  --font-display: 'Signika', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-receipt: ui-monospace, 'SFMono-Regular', 'Consolas', 'Liberation Mono', monospace;

  --radius: 16px;
  --shadow: 0 1px 2px rgba(5, 74, 109, .08), 0 4px 12px rgba(5, 74, 109, .06);

  /* Cores de status (plano: aberto=vermelho, separacao=azul vivo, caminho=azul escuro) */
  --st-em_aberto: var(--brand-red);
  --st-em_separacao: var(--brand-blue);
  --st-a_caminho: var(--brand-blue-dark);
  --st-finalizada: var(--text-muted);
  --st-cancelada: #8A99A3;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font: 400 1rem/1.6 var(--font-body);
  color: var(--text);
  background-color: var(--surface);
}

/* Padrao azulejo da fachada, bem sutil, no login e no painel */
body.is-guest,
.page--wide {
  background-image:
    linear-gradient(rgba(95, 168, 214, .10) 1px, transparent 1px),
    linear-gradient(90deg, rgba(95, 168, 214, .10) 1px, transparent 1px);
  background-size: 28px 28px;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 700; color: var(--brand-blue-dark); line-height: 1.2; }
h1 { font-size: clamp(1.5rem, 4vw, 2rem); margin: 0 0 1rem; }
h2 { font-size: 1.125rem; margin: 0 0 .75rem; display: flex; align-items: center; gap: .5rem; }

a { color: var(--brand-blue-dark); }

/* ---------- Topo ---------- */

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 1rem;
  padding: .5rem 16px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.topbar__brand img { display: block; height: 40px; width: auto; }
.topbar__nav { display: flex; gap: .25rem; flex: 1; overflow-x: auto; }
.topbar__nav a {
  padding: .4rem .75rem; border-radius: 999px;
  font-weight: 600; text-decoration: none; white-space: nowrap;
}
.topbar__nav a:hover { background: var(--surface); }
.topbar__user { display: flex; align-items: center; gap: .5rem; }
.topbar__name { font-weight: 600; max-width: 12ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.presence { width: 10px; height: 10px; border-radius: 50%; background: #B5C3CC; flex: none; }
.presence[data-state="on"] { background: #1F9D55; box-shadow: 0 0 0 3px rgba(31, 157, 85, .2); }
.presence[data-state="off"] { background: var(--brand-red); }

/* ---------- Layout ---------- */

.page { max-width: 720px; margin: 0 auto; padding: 16px; }
.page--wide { max-width: none; min-height: calc(100vh - 57px); }
.page--guest { display: grid; place-items: center; min-height: 100vh; }

.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}

.empty { color: var(--text-muted); font-size: .875rem; margin: .25rem 0 1rem; }
.hint { color: var(--text-muted); font-size: .8125rem; }
.back { display: inline-block; margin-bottom: .75rem; font-weight: 600; text-decoration: none; }

/* ---------- Login ---------- */

.login { width: 100%; max-width: 380px; text-align: center; }
.login__logo { width: 180px; height: auto; margin: 0 auto .5rem; display: block; }
.login .form { text-align: left; }

/* ---------- Formularios ---------- */

.form { display: grid; gap: .75rem; }
.form label { display: grid; gap: .25rem; font-size: .875rem; font-weight: 600; color: var(--text-muted); }
.form--grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); align-items: end; }
.form--inline { display: flex; flex-wrap: wrap; gap: .5rem; align-items: end; }
.form--inline label { flex: 1; min-width: 180px; }
.form--row { display: inline-flex; gap: .25rem; align-items: center; }
.form--row input { width: 9rem; }

input, select {
  font: inherit; color: var(--text);
  padding: .65rem .8rem;
  border: 1px solid #C9D9E5; border-radius: 10px;
  background: var(--white);
  min-height: 44px;
}
input:focus, select:focus { outline: 3px solid rgba(9, 134, 198, .35); border-color: var(--brand-blue); }

/* ---------- Botoes (CTA = pilula vermelha) ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  font: 600 1rem/1 var(--font-body);
  padding: .75rem 1.25rem; min-height: 44px;
  border-radius: 999px; border: 2px solid transparent;
  cursor: pointer; text-decoration: none;
  transition: filter .15s, transform .05s;
}
.btn:active { transform: scale(.98); }
.btn:hover { filter: brightness(.92); }
.btn[disabled], .btn.htmx-request { opacity: .6; pointer-events: none; }
.btn--primary { background: var(--brand-red); color: var(--white); }
.btn--secondary { background: var(--brand-blue-dark); color: var(--white); }
.btn--ghost { background: transparent; color: var(--brand-blue-dark); border-color: var(--border); }
.btn--danger-outline { background: transparent; color: var(--brand-red); border-color: var(--brand-red); }
.btn--sm { font-size: .875rem; padding: .4rem .8rem; min-height: 36px; }
.btn--xl { font-size: 1.25rem; padding: 1.1rem 1.5rem; min-height: 64px; }
.btn--block { width: 100%; }

/* ---------- Selo / badge (ecoa o selo "13Kg") ---------- */

.seal {
  flex: none; display: grid; place-items: center;
  width: 3.25rem; height: 3.25rem; border-radius: 50%;
  font: 700 .875rem/1 var(--font-display); color: var(--white);
  background: var(--st-em_aberto);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .18);
}
.seal--em_separacao { background: var(--st-em_separacao); }
.seal--a_caminho { background: var(--st-a_caminho); }
.seal--finalizada { background: var(--st-finalizada); }
.seal--cancelada { background: var(--st-cancelada); }

.badge {
  display: inline-block; padding: .2rem .7rem; border-radius: 999px;
  font-size: .8125rem; font-weight: 600; color: var(--white);
  background: var(--st-em_aberto);
}
.badge--em_separacao { background: var(--st-em_separacao); }
.badge--a_caminho { background: var(--st-a_caminho); }
.badge--finalizada { background: var(--st-finalizada); }
.badge--cancelada { background: var(--st-cancelada); }

.count {
  font: 600 .75rem/1 var(--font-body);
  padding: .25rem .5rem; border-radius: 999px;
  background: var(--border); color: var(--brand-blue-dark);
}
.count--alert { background: var(--brand-red); color: var(--white); }

/* ---------- Card de entrega ---------- */

.list { margin-bottom: 1.5rem; }

.dcard {
  display: flex; align-items: center; gap: .9rem;
  padding: .85rem 1rem; margin-bottom: .6rem;
  background: var(--white);
  border: 1px solid var(--border); border-left: 6px solid var(--st-em_aberto);
  border-radius: var(--radius);
  color: inherit; text-decoration: none;
  box-shadow: var(--shadow);
}
.dcard:hover { border-color: var(--brand-blue); }
.dcard--em_separacao { border-left-color: var(--st-em_separacao); }
.dcard--a_caminho { border-left-color: var(--st-a_caminho); }
.dcard--finalizada { border-left-color: var(--st-finalizada); opacity: .8; }
.dcard--cancelada { border-left-color: var(--st-cancelada); opacity: .6; }
.dcard--cancelada .dcard__title { text-decoration: line-through; }
.dcard__body { display: grid; min-width: 0; }
.dcard__title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dcard__meta { font-size: .8125rem; color: var(--text-muted); }
.dcard__driver { font-size: .8125rem; font-weight: 600; color: var(--brand-blue-dark); }

/* ---------- Cupom digital (R19): desenho do cupom impresso da loja ----------
 * Papel termico: preto no branco, fonte sem serifa da impressora, logo P&B,
 * data no canto, linhas duplas em volta do cabecalho dos itens. */

.receipt {
  --ink: #111;
  max-width: 30rem; margin: 0 auto 1.25rem;
  padding: 1.5rem 1.25rem 2rem;
  background: #FFFFFF;
  color: var(--ink);
  font: 400 1rem/1.35 Arial, 'Helvetica Neue', Helvetica, 'Liberation Sans', sans-serif;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .12);
  /* serrilhado do corte da bobina */
  -webkit-mask: radial-gradient(circle 6px at 50% 100%, transparent 98%, #000) 0 0 / 14px 100% repeat-x;
          mask: radial-gradient(circle 6px at 50% 100%, transparent 98%, #000) 0 0 / 14px 100% repeat-x;
}
.receipt p { margin: 0; }
.receipt__raw { margin: 0; font: 400 clamp(.625rem, 3.2vw, .9375rem)/1.45 var(--font-receipt); white-space: pre-wrap; overflow-wrap: anywhere; }

.rc-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.rc-logo { width: 46%; max-width: 150px; height: auto; display: block; }
.rc-when { text-align: right; font-size: .95rem; line-height: 1.3; }
.rc-store { font-size: 1.6rem; letter-spacing: .02em; margin: .35rem 0 .9rem !important; }

.rc-field { margin-bottom: .35rem !important; overflow-wrap: anywhere; }
.rc-field--label .rc-label,
.rc-field--all { font-weight: 700; }
.rc-sale { margin: .5rem 0 1rem !important; }

.rc-items-head {
  display: flex; justify-content: space-between; gap: 1rem;
  font-weight: 700; font-size: .95rem;
  padding: .3rem 0;
  border-top: 3px double var(--ink);
  border-bottom: 3px double var(--ink);
}
.rc-item { padding-top: .35rem; }
.rc-item__desc { font-size: 1.05rem; }
.rc-line { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; font-variant-numeric: tabular-nums; }
.rc-line span:last-child { white-space: nowrap; }
.rc-line--dashed { border-bottom: 1px dashed var(--ink); padding-bottom: .2rem; }
.rc-total { font-weight: 700; font-size: 1.1rem; padding-top: .3rem; border-top: 1px solid var(--ink); }
.rc-payment { font-size: 1.05rem; padding: .25rem 0; border-bottom: 1px solid var(--ink); }
.rc-obs { margin-top: .9rem !important; padding-bottom: .4rem; border-bottom: 1px solid var(--ink); font-size: 1.05rem; overflow-wrap: anywhere; }
.rc-text { overflow-wrap: anywhere; }

@media (max-width: 380px) {
  .receipt { padding-inline: .9rem; font-size: .92rem; }
  .rc-store { font-size: 1.35rem; }
}

.actions { display: grid; gap: .75rem; max-width: 48ch; margin: 0 auto 1.5rem; }

.timeline {
  max-width: 48ch; margin: 0 auto;
  display: grid; grid-template-columns: auto 1fr; gap: .25rem 1rem;
  font-size: .875rem;
}
.timeline dt { color: var(--text-muted); }
.timeline dd { margin: 0; font-weight: 600; }

/* ---------- Painel da loja ---------- */

.panel { display: grid; gap: 16px; grid-template-columns: 1fr; }
.board { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); align-items: start; }
.board__col {
  background: rgba(255, 255, 255, .7);
  border: 1px solid var(--border); border-top: 5px solid var(--st-em_aberto);
  border-radius: var(--radius); padding: .75rem;
  min-height: 8rem;
}
.board__col--em_separacao { border-top-color: var(--st-em_separacao); }
.board__col--a_caminho { border-top-color: var(--st-a_caminho); }
.board__col--finalizada { border-top-color: var(--st-finalizada); }
.board__col--cancelada { border-top-color: var(--st-cancelada); }
.board__col .seal { width: 2.75rem; height: 2.75rem; font-size: .75rem; }

.online {
  background: var(--brand-blue-dark); color: var(--white);
  border-radius: var(--radius); padding: 1rem;
}
.online h2 { color: var(--white); }
.online .count { background: rgba(255, 255, 255, .15); color: var(--white); }
.online ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.online__item { display: flex; align-items: center; gap: .5rem; color: #A8CFE3; }
.online__item.is-online { color: var(--white); font-weight: 600; }
.online__item .dot { width: 10px; height: 10px; border-radius: 50%; background: #5B7A8C; flex: none; }
.online__item.is-online .dot { background: #3DDC84; }
.online__load { margin-left: auto; font-size: .75rem; font-weight: 400; color: #A8CFE3; }
.online .empty { color: #A8CFE3; }

@media (min-width: 1100px) {
  .panel { grid-template-columns: 1fr 260px; }
}

/* ---------- Tabelas ---------- */

.table {
  width: 100%; border-collapse: collapse;
  background: var(--white); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); margin-bottom: .75rem;
}
.table th, .table td { padding: .65rem .75rem; text-align: left; border-bottom: 1px solid var(--border); }
.table th { font-size: .8125rem; color: var(--text-muted); background: var(--surface); }
.table .is-muted td { color: var(--text-muted); }
.table__actions { display: flex; flex-wrap: wrap; gap: .4rem; }

@media (max-width: 640px) {
  .table thead { display: none; }
  .table tr { display: grid; padding: .5rem 0; border-bottom: 1px solid var(--border); }
  .table td { border: 0; padding: .2rem .75rem; }
}

/* ---------- Mensagens ---------- */

.toast-area { position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 50; display: grid; justify-items: center; pointer-events: none; }
.toast { margin: 0 0 .75rem; padding: .7rem 1rem; border-radius: 12px; font-weight: 600; pointer-events: auto; }
.toast--error { background: var(--brand-red); color: var(--white); box-shadow: var(--shadow); }
.toast--ok { background: #E3F4EA; color: #14532D; }

@media (max-width: 480px) {
  .topbar { gap: .5rem; }
  .topbar__brand img { height: 32px; }
  .topbar__name { display: none; }
}
