/* src/frontend/styles/index.css */
:root {
  --azul: #004f9f;
  --marinho: #203b7b;
  --cinza: #4a5b72;
  --celeste: #59c3f1;
  --azul-claro: #c4e4f9;
  --laranja: #ee7203;
  --laranja-fundo: #fff1e3;
  --laranja-texto: #8f4200;
  --color-bg: #fff;
  --color-text: #1f2a3c;
  --color-border: #d5dce6;
  --color-surface: #f3f6fa;
  --radius: 14px;
  --space-sm: .5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --buncss-light: initial;
  --buncss-dark: ;
  color-scheme: light;
}

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

html[data-letra="1"] {
  font-size: 18px;
}

html[data-letra="2"] {
  font-size: 20px;
}

html[data-letra="3"] {
  font-size: 22px;
}

*, *:before, *:after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  margin: 0;
  padding: 0;
}

html, body {
  min-height: 100%;
}

body {
  color: var(--color-text);
  max-width: 560px;
  min-height: 100vh;
  background: var(--color-bg);
  overflow-wrap: break-word;
  min-height: 100dvh;
  margin: 0 auto;
  font-family: Gotham, Helvetica Neue, Arial, sans-serif;
  line-height: 1.45;
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

button, a, summary {
  touch-action: manipulation;
  font-family: inherit;
}

:focus-visible {
  outline: 3px solid var(--celeste);
  outline-offset: 2px;
}

.screen {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  flex: 1;
  min-height: 100dvh;
}

.header {
  background: var(--azul);
  color: #fff;
  padding: .5rem var(--space-md);
  display: flex;
  align-items:  center;
  gap: .25rem var(--space-md);
  position: sticky;
  z-index: 10;
  flex-wrap: wrap;
  min-height: 3.25rem;
  top: 0;
}

.header h1 {
  font-size: 1.15rem;
  font-weight: 700;
}

.content {
  padding: var(--space-md);
  padding-left: max(var(--space-md), env(safe-area-inset-left, 0px));
  padding-right: max(var(--space-md), env(safe-area-inset-right, 0px));
  display: flex;
  gap: var(--space-md);
  flex-direction: column;
  flex: 1;
}

.content-centered {
  justify-content: center;
}

.back-btn {
  color: #fff;
  display: inline-flex;
  cursor: pointer;
  background: #ffffff29;
  border: none;
  border-radius: 999px;
  flex-shrink: 0;
  align-items:  center;
  gap: .3rem;
  min-height: 2.75rem;
  padding: 0 1rem 0 .7rem;
  font-size: 1rem;
  font-weight: 600;
}

.back-btn:active {
  background: #ffffff4d;
}

.btn-primary, .btn-secundario {
  display: flex;
  border-radius: var(--radius);
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  border: 2px solid var(--azul);
  justify-content: center;
  align-items:  center;
  gap: .55rem;
  width: 100%;
  min-height: 3.1rem;
  padding: .65rem 1rem;
  transition: transform 80ms, background .15s;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.25;
}

.btn-primary:active, .btn-secundario:active {
  transform: scale(.98);
}

.btn-primary {
  background: var(--azul);
  color: #fff;
}

.btn-primary:active {
  background: var(--marinho);
  border-color: var(--marinho);
}

.btn-secundario {
  color: var(--azul);
  background: #fff;
}

.btn-secundario:active {
  background: var(--azul-claro);
}

.btn-lg {
  min-height: 4.5rem;
  font-size: 1.1rem;
}

.btn-icone svg {
  flex-shrink: 0;
}

.ctl-letra {
  display: flex;
  align-items:  center;
  gap: var(--space-sm);
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: .35rem;
}

.ctl-btn {
  border: 2px solid var(--azul);
  color: var(--azul);
  cursor: pointer;
  background: #fff;
  border-radius: 12px;
  flex-shrink: 0;
  width: 3rem;
  height: 3rem;
  font-size: 1.05rem;
  font-weight: 700;
}

.ctl-btn:active:not(:disabled) {
  background: var(--azul-claro);
}

.ctl-btn:disabled {
  opacity: .35;
  cursor: default;
}

.ctl-texto {
  display: flex;
  text-align: center;
  flex-direction: column;
  flex: 1;
  align-items:  center;
  min-width: 0;
  line-height: 1.25;
}

.ctl-titulo {
  color: var(--cinza);
  font-size: .8rem;
}

.letra-nivel {
  color: var(--marinho);
  font-weight: 700;
}

.lista {
  display: flex;
  gap: var(--space-md);
  flex-direction: column;
}

.lista-topo {
  display: flex;
  flex-direction: column;
  gap: .15rem;
}

.lista-paciente {
  color: var(--marinho);
  font-size: 1.2rem;
  font-weight: 700;
}

.dica {
  color: var(--cinza);
}

.pedido {
  border: 2px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: .3rem;
  scroll-margin-top: 4rem;
}

.chip-recente {
  background: var(--azul-claro);
  color: var(--marinho);
  border-radius: 999px;
  align-self:  flex-start;
  padding: .1rem .6rem;
  font-size: .75rem;
  font-weight: 700;
}

.pedido-data {
  color: var(--marinho);
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.25;
}

.pedido-qtd {
  color: var(--azul);
  font-weight: 700;
}

.pedido-exames {
  color: var(--color-text);
}

.pedido-botoes {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  margin-top: .6rem;
}

.ano {
  border: 2px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
}

.ano summary {
  display: flex;
  justify-content: space-between;
  align-items:  center;
  gap: var(--space-md);
  padding: 0 var(--space-md);
  cursor: pointer;
  list-style: none;
  background: var(--color-surface);
  min-height: 3.25rem;
}

.ano summary::-webkit-details-marker {
  display: none;
}

.ano summary:after {
  content: "+";
  color: var(--azul);
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
}

.ano[open] summary:after {
  content: "−";
}

.ano-titulo {
  color: var(--marinho);
  margin-right: auto;
  font-size: 1.2rem;
  font-weight: 700;
}

.ano-qtd {
  color: var(--cinza);
  font-size: .9rem;
}

.ano-lista {
  display: flex;
  gap: var(--space-md);
  padding: var(--space-md);
  flex-direction: column;
}

.intro {
  display: flex;
  flex-direction: column;
  gap: .15rem;
}

.intro-paciente {
  color: var(--cinza);
  font-size: .9rem;
}

.intro-titulo {
  color: var(--marinho);
  font-size: 1.4rem;
  line-height: 1.2;
}

.intro-qtd {
  color: var(--cinza);
}

.exame {
  border: 2px solid var(--color-border);
  border-left: 8px solid var(--azul);
  border-radius: var(--radius);
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: .65rem;
}

.exame-topo {
  display: flex;
  flex-wrap: wrap;
  align-items:  center;
  gap: .5rem;
}

.exame-nome {
  color: var(--marinho);
  font-size: 1.2rem;
  line-height: 1.25;
}

.sigla {
  background: var(--azul-claro);
  color: var(--marinho);
  border-radius: 999px;
  padding: .1rem .6rem;
  font-size: .75rem;
  font-weight: 700;
}

.exame-status {
  display: flex;
  color: var(--cinza);
  align-items:  center;
  gap: .4rem;
  font-size: .9rem;
}

.exame-pronto {
  color: var(--azul);
  font-weight: 700;
}

.valor-bloco {
  background: var(--color-surface);
  padding: .75rem var(--space-md);
  display: flex;
  border-radius: 12px;
  flex-direction: column;
  gap: .25rem;
}

.valor-alterado {
  background: var(--laranja-fundo);
}

.valor-rotulo {
  color: var(--cinza);
  font-size: .85rem;
}

.valor-grande {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .2rem .5rem;
}

.valor-numero {
  color: var(--marinho);
  overflow-wrap: anywhere;
  font-size: 1.9rem;
  font-weight: 700;
  line-height: 1.15;
}

.valor-unidade {
  color: var(--cinza);
  font-size: 1rem;
}

.valor-ref {
  color: var(--cinza);
  font-size: .9rem;
}

.tag-alerta {
  display: inline-flex;
  background: var(--laranja-fundo);
  color: var(--laranja-texto);
  border: 2px solid var(--laranja);
  border-radius: 999px;
  align-self:  flex-start;
  align-items:  center;
  gap: .4rem;
  padding: .15rem .8rem .15rem .55rem;
  font-size: .9rem;
  font-weight: 700;
  line-height: 1.3;
}

.tag-alerta svg {
  color: var(--laranja);
  flex-shrink: 0;
}

.resumo-ok, .sem-valores {
  color: var(--cinza);
}

.valores {
  margin-top: .5rem;
}

.valores summary {
  display: flex;
  justify-content: space-between;
  align-items:  center;
  gap: var(--space-sm);
  cursor: pointer;
  list-style: none;
  color: var(--azul);
  border: 2px solid var(--azul);
  padding: .3rem var(--space-md);
  border-radius: 12px;
  min-height: 3rem;
  font-weight: 700;
}

.valores summary:active {
  background: var(--azul-claro);
}

.valores summary::-webkit-details-marker {
  display: none;
}

.valores summary:after {
  content: "+";
  font-size: 1.5rem;
  line-height: 1;
}

.valores[open] summary:after {
  content: "−";
}

.linha {
  display: flex;
  justify-content: space-between;
  gap: var(--space-md);
  border-bottom: 1px solid var(--color-border);
  padding: .7rem .25rem;
}

.linha:last-child {
  border-bottom: none;
}

.linha-alterada {
  background: var(--laranja-fundo);
  border-left: 4px solid var(--laranja);
  padding-left: .6rem;
}

.linha-nome {
  min-width: 0;
}

.linha-ref {
  color: var(--cinza);
  font-size: .875rem;
}

.linha-valor {
  text-align: right;
  color: var(--marinho);
  overflow-wrap: anywhere;
  flex-shrink: 0;
  max-width: 50%;
  font-weight: 700;
}

.aviso {
  color: var(--cinza);
  margin-bottom: .5rem;
  font-size: .9rem;
}

.barra-pdf {
  position: sticky;
  padding: .7rem var(--space-md) calc(.7rem + env(safe-area-inset-bottom, 0px));
  background: #fff;
  bottom: 0;
  box-shadow: 0 -4px 12px #203b7b1f;
}

.vazio, .erro {
  display: flex;
  text-align: center;
  align-items:  center;
  gap: var(--space-sm);
  color: var(--cinza);
  flex-direction: column;
  margin-top: 2rem;
}

.vazio-titulo, .erro-titulo {
  color: var(--marinho);
  font-size: 1.2rem;
  font-weight: 700;
}

.erro .btn-primary {
  margin-top: var(--space-md);
}

.esqueleto {
  gap: .7rem;
}

.esq-linha, .esq-botao {
  animation: 1.4s ease-in-out infinite brilho;
  background: linear-gradient(90deg, #e8edf3 25%, #f6f8fb 50%, #e8edf3 75%) 0 0 / 200% 100%;
  border-radius: 8px;
}

.esq-titulo {
  width: 65%;
  height: 1.4rem;
}

.esq-meio {
  width: 40%;
  height: 1rem;
}

.esq-botao {
  border-radius: var(--radius);
  height: 3.1rem;
}

@keyframes brilho {
  to {
    background-position: -200% 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .esq-linha, .esq-botao {
    animation: none;
  }

  .btn-primary, .btn-secundario {
    transition: none;
  }
}

@media (max-width: 340px) {
  .back-btn span {
    display: none;
  }

  .back-btn {
    padding: 0 .7rem;
  }

  .valor-numero {
    font-size: 1.6rem;
  }
}
