/* ==========================================================================
   QR.RBTO20.COM — DESIGN SYSTEM MASTER STYLESHEET
   Diretrizes oficiais: AI_AGENT_GUIDELINES.md
   Estética: Minimalismo Técnico, Dark Clean (#0b0e14), Teal Cirúrgico (#009688)
   Regra Absoluta: 100% Livre de Emojis em todo o código e interface.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. DEFINIÇÃO TIPOGRÁFICA (JetBrains Mono Local + Fallback Web)
   -------------------------------------------------------------------------- */
@font-face {
  font-family: 'JetBrains Mono';
  src: url('assets/JetBrainsMono-VariableFont_wght.ttf') format('truetype-variations'),
       url('assets/JetBrainsMono-VariableFont_wght.ttf') format('truetype');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:ital,wght@0,100..800;1,100..800&display=swap');

/* --------------------------------------------------------------------------
   2. DESIGN TOKENS & VARIÁVEIS OFICIAIS (:root)
   -------------------------------------------------------------------------- */
:root {
  /* Fundo & Superfícies */
  --bg-color: #0b0e14;                    /* Fundo global escuro profundo (nunca preto puro #000) */
  --card-bg: rgba(255, 255, 255, 0.015);  /* Fundo sutil de cartões e itens */
  --card-bg-hover: rgba(255, 255, 255, 0.03); /* Hover em superfícies neutras */

  /* Caixas de Entrada & Código */
  --code-bg: #080a0f;                     /* Fundo escuro de inputs, textareas e blocos <pre> */
  --code-header-bg: #0f131a;              /* Cabeçalho de caixas de código ou cartões */

  /* Destaque (Accent) — Teal Cirúrgico */
  --ds-teal-500: #009688;                 /* Teal primário oficial (links, botão accent, foco) */
  --ds-teal-400: #26a69a;                 /* Teal secundário / foco acessível */
  --ds-teal-subtle: rgba(0, 150, 136, 0.1);   /* Fundo suave em hover de botões/cartões */
  --ds-teal-border: rgba(0, 150, 136, 0.35);  /* Contorno destacado ativo */

  /* Textos & Contrastes */
  --text-primary: #ededed;               /* Texto primário de alto contraste (títulos, valores) */
  --text-secondary: #9aa4b2;             /* Texto de leitura, labels de formulários, descrições */
  --text-muted: #555e6d;                 /* Metadados, timestamps, rodapé, links de canto */

  /* Bordas & Divisores */
  --border-color: #21262d;               /* Borda universal de caixas, inputs e divisores */
  --border-hover: #30363d;               /* Borda durante estados interativos neutros */

  /* Status Tokens */
  --status-up: #009688;                   /* Operacional / Sucesso */
  --status-up-subtle: rgba(0, 150, 136, 0.12);
  --status-up-border: rgba(0, 150, 136, 0.35);

  --status-degraded: #d29922;             /* Instável / Alerta */
  --status-degraded-subtle: rgba(210, 153, 34, 0.12);
  --status-degraded-border: rgba(210, 153, 34, 0.35);

  --status-down: #f85149;                 /* Erro / Falha / Fora do Ar */
  --status-down-subtle: rgba(248, 81, 73, 0.12);
  --status-down-border: rgba(248, 81, 73, 0.35);

  --status-empty: #161b22;                /* Ausência de dados / Não monitorado */

  /* Tipografia Monospaçada */
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

/* --------------------------------------------------------------------------
   3. RESET UNIVERSAL & ESTILOS BASE
   -------------------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 15px;
  background-color: var(--bg-color);
  color: var(--text-primary);
  font-family: var(--font-mono);
  line-height: 1.6;
  scroll-behavior: smooth;
  min-height: 100%;
}

body {
  background-color: var(--bg-color);
  color: var(--text-primary);
  font-family: var(--font-mono);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection {
  background-color: var(--ds-teal-500);
  color: #ffffff;
}

/* --------------------------------------------------------------------------
   4. ESTRUTURAS DE LAYOUT
   -------------------------------------------------------------------------- */
.site-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 1.5rem clamp(1.25rem, 5vw, 2.5rem);
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  box-sizing: border-box;
  position: relative;
}

.site-wrapper.privacy-wrapper,
.site-wrapper.centered-wrapper {
  justify-content: center;
}

/* Subpáginas Institucionais (480px) */
.subpage-frame,
.privacy-page-frame {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin: auto 0;
}

/* Aplicação / Ferramenta */
.app-frame {
  width: 100%;
  max-width: 680px;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-bottom: 4.5rem;
  transition: max-width 0.2s ease;
}

/* Layout Responsivo de 2 Colunas no Desktop */
.app-body-layout {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  width: 100%;
}

.layout-column-main {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  width: 100%;
}

.layout-column-side {
  display: flex;
  flex-direction: column;
  width: 100%;
}

@media (min-width: 820px) {
  .app-frame {
    max-width: 840px;
  }

  .app-body-layout {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 2rem;
    align-items: start;
  }

  .qr-preview-section {
    position: sticky;
    top: 1.5rem;
    margin-top: 0;
    padding-top: 0;
    border-top: none !important;
  }
}

/* Modo Rápido (Acesso direto via URL: qr.rbto20.com/[conteúdo]) */
body.is-quick-mode .layout-column-main {
  display: none !important;
}

body.is-quick-mode .app-frame {
  max-width: 360px !important;
  margin: auto 0;
}

body.is-quick-mode .app-body-layout {
  display: flex !important;
  flex-direction: column !important;
}

body.is-quick-mode .qr-preview-section {
  position: static !important;
  margin-top: 0 !important;
  padding-top: 0 !important;
  border-top: none !important;
}

body.is-quick-mode .quick-mode-actions {
  display: block !important;
}

/* --------------------------------------------------------------------------
   5. CABEÇALHO PADRÃO DE APLICAÇÃO & RETORNO
   -------------------------------------------------------------------------- */
.privacy-header,
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--border-color);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.header-brand-link {
  text-decoration: none;
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  transition: color 0.15s ease;
}

.header-brand-link:hover .header-name {
  color: var(--ds-teal-500);
}

.header-name {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  transition: color 0.15s ease;
}

.publ-nav-actions,
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Botão Início / Voltar: Texto padrão em branco com transição para Teal no hover */
.btn-exit {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  font-family: var(--font-mono);
  font-weight: 500;
  color: #ffffff;
  text-decoration: none;
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}

.btn-exit:hover,
.btn-exit:focus-visible {
  border-color: var(--ds-teal-500);
  color: var(--ds-teal-500);
  background: var(--ds-teal-subtle);
  outline: none;
}

.btn-exit-icon {
  font-size: 0.85rem;
}

/* --------------------------------------------------------------------------
   6. SELETOR DE MODOS (ABAS / TABS)
   -------------------------------------------------------------------------- */
.mode-tabs {
  display: flex;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.5rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0.75rem;
  font-size: 0.80rem;
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.tab-btn:hover {
  color: var(--text-primary);
  background: var(--card-bg-hover);
  border-color: var(--border-hover);
}

.tab-btn.is-active {
  color: var(--ds-teal-500);
  border-color: var(--ds-teal-border);
  background: var(--ds-teal-subtle);
}

.tab-btn:focus-visible {
  outline: none;
  border-color: var(--ds-teal-500);
}

/* --------------------------------------------------------------------------
   7. FORMULÁRIOS, INPUTS & TEXTAREAS
   -------------------------------------------------------------------------- */
.setup-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-section {
  display: none;
  flex-direction: column;
  gap: 0.85rem;
}

.form-section.is-active {
  display: flex;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  width: 100%;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

@media (max-width: 540px) {
  .form-row {
    grid-template-columns: 1fr;
  }
}

.form-label {
  font-size: 0.80rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.input-field,
.textarea-field,
.select-field {
  width: 100%;
  font-size: 0.82rem;
  font-family: var(--font-mono);
  color: var(--text-primary);
  background: var(--code-bg);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 0.45rem 0.65rem;
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
  height: 34px;
}

.textarea-field {
  height: auto;
  min-height: 100px;
  resize: vertical;
  line-height: 1.5;
}

.select-field {
  cursor: pointer;
  background-color: var(--code-bg);
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239aa4b2' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.65rem center;
  padding-right: 1.8rem;
}

.select-field option {
  background-color: #0d1117;
  color: var(--text-primary);
}

.input-field:focus,
.textarea-field:focus,
.select-field:focus {
  outline: none;
  border-color: var(--ds-teal-500);
  background: var(--code-bg);
}

.input-field.input-error,
.textarea-field.input-error {
  border-color: var(--status-down) !important;
  background-color: var(--status-down-subtle) !important;
}

/* Color Pickers em Configurações */
.color-picker-wrapper {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.color-input {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  width: 34px;
  height: 34px;
  background: var(--code-bg);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  cursor: pointer;
  padding: 3px;
  flex-shrink: 0;
  transition: border-color 0.15s ease;
}

.color-input:focus-visible {
  outline: none;
  border-color: var(--ds-teal-500);
}

.color-input::-webkit-color-swatch-wrapper {
  padding: 0;
}

.color-input::-webkit-color-swatch {
  border: none;
  border-radius: 2px;
}

.color-input::-moz-color-swatch {
  border: none;
  border-radius: 2px;
}

.hex-text-input {
  flex: 1;
  text-transform: uppercase;
}

/* Checkbox Customizado com Indicador ✓ */
.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.checkbox-input {
  appearance: none;
  -webkit-appearance: none;
  width: 15px;
  height: 15px;
  background: var(--code-bg);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  cursor: pointer;
  display: grid;
  place-content: center;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.checkbox-input:checked {
  background: var(--ds-teal-500);
  border-color: var(--ds-teal-500);
}

.checkbox-input:checked::before {
  content: "✓";
  color: #ffffff;
  font-size: 10px;
  font-weight: bold;
}

/* --------------------------------------------------------------------------
   8. ACCORDION EXPANSÍVEL (Seta ▶ que gira 90°)
   -------------------------------------------------------------------------- */
.accordion-wrapper {
  margin-top: 0.25rem;
}

.accordion-details {
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--card-bg);
  transition: border-color 0.15s ease;
}

.accordion-details[open] {
  border-color: var(--border-hover);
}

.accordion-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  list-style: none;
}

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

.accordion-summary:hover {
  color: var(--text-primary);
}

.accordion-icon {
  font-size: 0.70rem;
  color: var(--text-muted);
  transition: transform 0.2s ease;
  display: inline-block;
}

.accordion-details[open] .accordion-icon {
  transform: rotate(90deg);
  color: var(--ds-teal-500);
}

.accordion-content {
  padding: 0.75rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background: rgba(0, 0, 0, 0.15);
}

/* --------------------------------------------------------------------------
   9. SEÇÃO DE PREVIEW DO QR CODE
   -------------------------------------------------------------------------- */
.qr-preview-section {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-top: 0.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

.qr-card {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
}

.qr-canvas-container {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  max-width: 300px;
  width: 100%;
  aspect-ratio: 1 / 1;
  position: relative;
}

#qr-canvas {
  width: 100%;
  height: 100%;
  max-width: 280px;
  max-height: 280px;
  display: block;
}

.qr-empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 0.75rem;
  color: #555e6d;
  padding: 1rem;
  height: 100%;
}

/* --------------------------------------------------------------------------
   10. BOTÕES & BARRA DE EXPORTAÇÃO
   -------------------------------------------------------------------------- */
.export-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
  width: 100%;
}

/* Bloco Unificado de Download (Select de Formato + Botão Baixar integrados) */
.download-group {
  display: inline-flex;
  align-items: stretch;
  flex: 1;
}

.download-group .format-select {
  width: 78px;
  height: 34px;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  border-right: none;
  z-index: 1;
}

.download-group .format-select:focus {
  z-index: 2;
}

.download-group .btn-download-action {
  height: 34px;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  flex: 1;
  z-index: 1;
}

.download-group .btn-download-action:hover,
.download-group .btn-download-action:focus-visible {
  z-index: 2;
}

/* Botão Neutro Padrão */
.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  height: 34px;
  padding: 0 0.75rem;
  font-size: 0.78rem;
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
  text-decoration: none;
  white-space: nowrap;
}

.action-btn:hover {
  border-color: var(--border-hover);
  background: var(--card-bg-hover);
  color: var(--text-primary);
}

.action-btn:focus-visible {
  outline: none;
  border-color: var(--ds-teal-500);
}

/* Botão Accent Único (Copiar Imagem) */
.action-btn.btn-accent {
  color: var(--ds-teal-500);
  border-color: var(--ds-teal-border);
  background: var(--ds-teal-subtle);
  flex: 1;
}

.action-btn.btn-accent:hover {
  border-color: var(--ds-teal-500);
  background: rgba(0, 150, 136, 0.2);
  color: #ffffff;
}

/* --------------------------------------------------------------------------
   11. SUBPÁGINA DE PRIVACIDADE
   -------------------------------------------------------------------------- */
.privacy-body {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.65;
}

.privacy-body strong {
  color: var(--text-primary);
  font-weight: 600;
}

.privacy-links-group {
  margin-top: 0.5rem;
}

.text-link {
  color: var(--ds-teal-500);
  text-decoration: none;
  font-size: 0.80rem;
  transition: color 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.text-link:hover {
  color: var(--ds-teal-400);
  text-decoration: underline;
}

/* --------------------------------------------------------------------------
   12. RODAPÉ FIXO (.corner-privacy) — SEM CAIXA ENVOLVENTE
   -------------------------------------------------------------------------- */
.corner-privacy {
  position: fixed;
  bottom: max(1.5rem, env(safe-area-inset-bottom, 1.5rem));
  right: max(1.75rem, env(safe-area-inset-right, 1.75rem));
  display: flex;
  align-items: center;
  gap: 0.85rem;
  font-size: 0.72rem;
  z-index: 50;
  background: transparent;
  border: none;
  padding: 0;
}

.privacy-link {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s ease;
}

.privacy-link:hover {
  color: var(--text-primary);
}

/* --------------------------------------------------------------------------
   13. TOAST DE NOTIFICAÇÃO FLUTUANTE
   -------------------------------------------------------------------------- */
.toast-notice {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(1rem);
  background: #0d1117;
  color: var(--text-primary);
  border: 1px solid var(--ds-teal-500);
  border-radius: 4px;
  padding: 0.45rem 0.9rem;
  font-size: 0.78rem;
  font-family: var(--font-mono);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
  z-index: 100;
  white-space: nowrap;
}

.toast-notice.is-active {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}
