/* O atributo hidden precisa vencer o display das classes (ex.: .sorry é grid). */
[hidden] { display: none !important; }

:root {
  --bg: #f6f7fb; --card: #fff; --text: #1d2433; --muted: #6b7385; --line: #e3e6ee;
  --primary: #2f5bea; --ok: #1a8f55; --warn: #b7791f; --bad: #c53030;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
h2 { font-size: 1rem; margin: 0 0 .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

.topbar { display: flex; justify-content: space-between; align-items: center; padding: 1rem 2rem; background: var(--card); border-bottom: 1px solid var(--line); }
.brand { font-size: 1.3rem; font-weight: 700; }
.brand span { color: var(--primary); }
.api { font-size: .85rem; padding: .25rem .6rem; border-radius: 99px; background: var(--line); }
.api.ok { background: #e3f5ec; color: var(--ok); }
.api.bad { background: #fde8e8; color: var(--bad); }

.layout { display: grid; grid-template-columns: 1fr 360px; gap: 1.5rem; padding: 1.5rem 2rem; }
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } }

.products { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; }
.product { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 1rem; display: flex; flex-direction: column; gap: .5rem; }
.product .emoji { font-size: 2.5rem; }
.product .name { font-weight: 600; }
.product .price { color: var(--muted); }

.cart { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 1rem; display: flex; flex-direction: column; gap: .75rem; align-self: start; }
.cart-items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .4rem; min-height: 2rem; }
.cart-items li { display: flex; justify-content: space-between; gap: .5rem; }
.cart-items .empty { color: var(--muted); }
.cart-total { display: flex; justify-content: space-between; border-top: 1px solid var(--line); padding-top: .75rem; }

.btn { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: .6rem .9rem; cursor: pointer; font-size: .95rem; width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.btn.danger { color: var(--bad); border-color: #f3c4c4; }
.btn.small { width: auto; padding: .3rem .6rem; font-size: .85rem; }
.link { border: 0; background: none; color: var(--primary); cursor: pointer; font-size: .8rem; text-transform: none; }

.demos { border: 1px dashed var(--line); border-radius: 8px; padding: .6rem; display: flex; flex-direction: column; gap: .5rem; }
.demos summary { cursor: pointer; font-weight: 600; }
.demos .btn { margin-top: .4rem; }
.hint { margin: .3rem 0 0; color: var(--muted); font-size: .85rem; }

.result { border-radius: 8px; padding: .75rem; background: #f1f4ff; font-size: .9rem; line-height: 1.4; }
.result.bad { background: #fde8e8; }
.steps { list-style: none; padding: 0; margin: .5rem 0 0; }
.steps li { padding: .2rem 0; color: var(--muted); }
.steps li.done { color: var(--ok); }
.steps li.now { color: var(--warn); font-weight: 600; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: .8rem; }

.log { padding: 0 2rem 1.5rem; }
.log table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; font-size: .85rem; }
.log th, .log td { text-align: left; padding: .45rem .6rem; border-bottom: 1px solid var(--line); }
.log th { color: var(--muted); font-weight: 600; background: #fafbfd; }
.s2 { color: var(--ok); font-weight: 600; }
.s4, .s5 { color: var(--bad); font-weight: 600; }

footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 0 0 1.5rem; }

/* Página de ambiente desligado */
.sorry { min-height: 70vh; display: grid; place-items: center; padding: 2rem; }
.sorry-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 2.5rem 2rem; max-width: 480px; text-align: center; box-shadow: 0 6px 24px rgba(20, 30, 60, .06); }
.sorry-icon { font-size: 3rem; }
.sorry-card h1 { font-size: 1.4rem; margin: .75rem 0 .5rem; }
.sorry-card p { color: var(--muted); margin: 0 0 1.5rem; }
.sorry-card .btn { width: auto; }

.good { color: var(--ok); }
.bad-text { color: var(--bad); }

/* Tabela de chamadas: linha principal enxuta, detalhe (chave, pedido, request, response) no clique. */
.log table { table-layout: fixed; }
.log .c-time { width: 8rem; }
.log .c-status { width: 6rem; }
.log .c-ms { width: 5rem; }
.log td.call { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log tr.entry { cursor: pointer; }
.log tr.entry:hover { background: #f6f8ff; }
.log tr.detail > td { background: #fafbfd; padding: .75rem 1rem 1rem; }
.log .ids { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin-bottom: .75rem; }
.log .payloads { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
@media (max-width: 900px) { .log .ids, .log .payloads { grid-template-columns: 1fr; } }
.log .label { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: .25rem; }
.log .value { word-break: break-all; font-weight: 600; }
.log pre { margin: 0; padding: .6rem; background: #fff; border: 1px solid var(--line); border-radius: 8px; max-height: 260px; overflow: auto; font-size: .78rem; white-space: pre-wrap; word-break: break-word; }
.log h2 .hint { text-transform: none; letter-spacing: 0; font-weight: 400; }

.log h2 { display: inline-block; }
.log-actions { float: right; display: flex; gap: .5rem; margin-bottom: .5rem; }
.log-actions .btn { width: auto; }

/* Arquitetura */
.top-actions { display: flex; align-items: center; gap: .75rem; }
.top-actions .btn { width: auto; }
.architecture { width: min(1100px, 94vw); max-height: 90vh; border: 1px solid var(--line); border-radius: 16px; padding: 0; color: var(--text); }
.architecture::backdrop { background: rgba(20, 30, 60, .45); }
.arch-header { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.5rem; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--card); }
.arch-header h1 { margin: 0; font-size: 1.2rem; }
.arch-header .btn { width: auto; }
.arch-body { display: grid; grid-template-columns: 1.3fr 1fr; gap: 1.5rem; padding: 1.25rem 1.5rem 1.5rem; }
@media (max-width: 900px) { .arch-body { grid-template-columns: 1fr; } }
.flow { list-style: none; counter-reset: step; margin: 0; padding: 0; }
.flow li { counter-increment: step; position: relative; background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--primary); border-radius: 10px; padding: .55rem .8rem .55rem 2.6rem; margin-bottom: 1.4rem; }
.flow li::before { content: counter(step); position: absolute; left: .7rem; top: .55rem; width: 1.4rem; height: 1.4rem; border-radius: 50%; background: var(--primary); color: #fff; font-size: .75rem; font-weight: 700; display: grid; place-items: center; }
.flow li:not(:last-child)::after { content: "↓"; position: absolute; left: 50%; bottom: -1.35rem; color: var(--muted); font-size: 1rem; }
.flow li strong, .side li strong { display: block; }
.flow li span, .side li span { color: var(--muted); font-size: .85rem; }
.side { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .6rem; }
.side li { border: 1px solid var(--line); border-left: 4px solid var(--ok); border-radius: 10px; padding: .55rem .8rem; }
code { font-family: ui-monospace, Consolas, monospace; font-size: .8em; background: #eef1f8; padding: 0 .25rem; border-radius: 4px; }
