/* Shared page styles (packages/shared/browser/base.css, served at /shared/base.css)
   for DocParser's apps; no CSS framework. Structure after the MicroCódigo NFS-e
   app: a header strip, tabs for the pages, a panel with the content. Each app's
   own styles.css follows it. */
:root {
  /* Matched to the MicroCódigo SmartClient skins (#22): brand blue #007caf
     (light skin's accent, both skins' buttons) and cyan #00a6c3 (dark skin's
     highlight). theme.js sets data-theme="light" | "dark" on <html>. */
  color-scheme: light;
  --azul: #007caf; /* buttons, active tab, header line */
  --azul-hover: #0091cd;
  --azul-claro: #85c1ea; /* inactive tabs */
  --aba-texto: #fff;
  --link: #007caf;
  --destaque: #007caf; /* app name, login title */
  --fundo: #fff;
  --cinza-fundo: #f2f4f7; /* header strip */
  --borda: #d8dee5;
  --texto: #333;
  --apagado: #555;
  --erro: #b3261e;
  --ok: #1e7d32;
  --botao-texto: #fff;
  --snackbar: #323232;
}

/* Dark: the MicroCodigoDark skin's pitch black, with cyan accents */
:root[data-theme="dark"] {
  color-scheme: dark;
  --azul-claro: #1d3a47;
  --aba-texto: #b3e3ee;
  --link: #33c1d9;
  --destaque: #33c1d9;
  --fundo: #000;
  --cinza-fundo: #121416;
  --borda: #3a3d40;
  --texto: #e6e6e6;
  --apagado: #a0a4a8;
  --erro: #ff6b5e;
  --ok: #5cc26b;
  --snackbar: #2a2c2e;
}

/* Logos: the dark version on the dark theme */
.logo-escuro { display: none; }
:root[data-theme="dark"] .logo-claro { display: none; }
:root[data-theme="dark"] .logo-escuro { display: inline; }

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  font: 13px/1.4 Roboto, "Segoe UI", Arial, sans-serif;
  color: var(--texto);
  background: var(--fundo);
}

a { color: var(--link); }

button {
  font: inherit;
  padding: 0.3rem 0.8rem;
  border: 1px solid var(--azul);
  border-radius: 2px;
  background: var(--azul);
  color: var(--botao-texto);
  cursor: pointer;
}

button:hover:not(:disabled) { background: var(--azul-hover); border-color: var(--azul-hover); }
button.secondary { background: var(--fundo); color: var(--link); border-color: var(--azul); }
button.secondary:hover:not(:disabled) { background: var(--cinza-fundo); }

/* Theme switch (theme.js): a small icon button in the header */
.topo .tema { min-width: 2.2rem; padding: 0.3rem 0.5rem; font-size: 15px; line-height: 1; }
button:disabled { opacity: 0.5; cursor: default; }

/* Header strip: app name on the left, user and Sair on the right */
.topo {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.4rem 1rem;
  background: var(--cinza-fundo);
  border-bottom: 3px solid var(--azul);
}

.topo .marca {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 16px;
  font-weight: 600;
  color: var(--destaque);
  text-decoration: none;
}

/* The small µ mark replaces the full logo on narrow screens */
.topo .logo-mu { display: none; }

@media (max-width: 600px) {
  .topo .logo { display: none !important; } /* beats the dark theme's .logo-escuro */
  .topo .logo-mu { display: inline; }
}

.topo .usuario { margin-left: auto; }

/* Tabs: one per page */
.abas {
  display: flex;
  gap: 4px;
  padding: 1.5rem 1.5rem 0;
}

.abas a {
  padding: 0.45rem 1.5rem;
  border-radius: 3px 3px 0 0;
  background: var(--azul-claro);
  color: var(--aba-texto);
  text-decoration: none;
  font-size: 0.85rem;
}

.abas a[aria-current="page"] { background: var(--azul); color: var(--botao-texto); }

/* The panel under the tabs; on the Notas page it fills the window and the grid
   takes what the rows above it leave. */
.painel {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  min-height: 0;
  margin: 0 1.5rem;
  padding: 0.8rem 1rem;
  border: 1px solid var(--borda);
}

.painel h2 { font-size: 1.05rem; margin: 0.5rem 0 0.3rem; }


#table {
  flex: 1 1 0;
  min-height: 320px;
  position: relative;
  overflow: hidden;
}

.legal {
  padding: 0.4rem;
  text-align: center;
  color: var(--apagado);
}

.error { color: var(--erro); }

/* Login */
.login {
  max-width: 28rem;
  margin: 15vh auto 0;
  padding: 1.5rem;
  border: 1px solid var(--borda);
  border-top: 3px solid var(--azul);
}

.login h1 {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 0;
  font-size: 18px;
  color: var(--destaque);
}

.login #google-gis {
  /* Google's iframe paints an opaque white box under a dark color-scheme */
  color-scheme: light;
  display: flex;
  justify-content: center;
  min-height: 44px;
}

/* Snackbars (snackbar.js): bottom right, full width on phones */
.snackbars {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 1000000000; /* above SmartClient's canvases and menus */
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  max-width: calc(100vw - 32px);
  pointer-events: none;
}

.snackbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  max-width: 28rem;
  padding: 0.35rem 0.35rem 0.35rem 1rem;
  border-radius: 4px;
  background: var(--snackbar);
  color: #fff;
  box-shadow: 0 3px 10px rgb(0 0 0 / 0.25);
  pointer-events: auto;
  animation: snackbar-entra 0.15s ease-out;
}

.snackbar.success { border-left: 4px solid #4caf50; }
.snackbar.error { background: var(--erro); }
.snackbar-texto { flex: 1; }

.snackbar button {
  min-width: 44px;
  min-height: 36px;
  border: 0;
  background: transparent;
  color: #fff;
}

.snackbar .snackbar-acao { font-weight: 600; text-transform: uppercase; color: var(--azul-claro); }
.snackbar.error .snackbar-acao { color: #fff; text-decoration: underline; }
.snackbar-fechar { font-size: 18px; line-height: 1; opacity: 0.8; }
.snackbar button:hover, .snackbar button:focus-visible { background: rgb(255 255 255 / 0.15); }

@keyframes snackbar-entra {
  from { opacity: 0; transform: translateY(8px); }
}

@media (prefers-reduced-motion: reduce) {
  .snackbar { animation: none; }
}

@media (max-width: 600px) {
  .snackbars { left: 16px; right: 16px; align-items: stretch; }
  .snackbar { max-width: none; }
}

/* Mobile (#21). Phones: tighter margins, the user's email shortened, and a
   grid in #table gets a fixed height while the page scrolls. */
.so-toque { display: none; }

@media (max-width: 600px) {
  body { height: auto; min-height: 100%; }
  .topo { gap: 0.5rem; padding: 0.4rem 0.5rem; }
  .topo .usuario {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: right;
  }
  .abas { padding: 0.75rem 0.5rem 0; }
  .abas a { flex: 1 1 0; padding: 0.45rem 0.6rem; text-align: center; }
  .painel { margin: 0 0.5rem; padding: 0.5rem; }
  #table { flex: none; height: 75vh; }
  .login { margin: 8vh 0.5rem 0; }
}

/* Touch screens: 44 px targets */
@media (pointer: coarse) {
  .so-mouse { display: none; }
  .so-toque { display: inline; }
  button, .topo .marca { min-height: 44px; }
  .abas a { display: flex; align-items: center; justify-content: center; min-height: 44px; }
  .legal a { display: inline-block; padding: 15px 4px; }
  input[type="checkbox"] { width: 20px; height: 20px; margin: 0; }
  label:has(> input[type="checkbox"]) {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-height: 44px;
  }
}
