/* ------------------------------------------------------------------
   COMPRAS — Sistema de cotação de compras
   Copyright (c) 2026 Franciscana Representações. Todos os direitos
   reservados. Software proprietário, licenciado — não vendido. É vedada
   a cópia, distribuição, modificação ou engenharia reversa sem
   autorização expressa e por escrito da Franciscana Representações.
   ------------------------------------------------------------------
   PACOTE DE IDENTIDADE DA CASA — v1 (Compras)
   Origem: FR Avança Hub 2.0 — "Design Tokens (Sessão 6)" + estrutura
   do app logado + tela de login, copiados em 13/08/2026.
   Adaptações nesta cópia (somente estas):
     1. Fraunces nos títulos (exigência D14; o Hub usa só Inter) com
        fontes AUTO-HOSPEDADAS em /static/fonts — a CSP deste sistema
        proíbe CDN externo.
     2. Mobile entra automaticamente no tema escuro (D14) — no Hub o
        escuro é opcional por toggle.
     3. Removidos blocos exclusivos do Hub (modo demo, notificações,
        grupos hierárquicos da sidebar).
   ------------------------------------------------------------------ */

/* ============================================================
   FONTES AUTO-HOSPEDADAS (Inter corpo, Fraunces títulos — D14)
   ============================================================ */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('/static/fonts/inter-latin.woff2') format('woff2');
}
@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 500 800;
  font-display: swap;
  src: url('/static/fonts/fraunces-latin.woff2') format('woff2');
}

/* ============================================================
   DESIGN TOKENS (origem: base.css do Hub, Sessão 6)
   ============================================================ */
:root {
  /* Cores primárias — invariáveis nos dois temas */
  --azul-primario: #1A4DB3;
  --azul-escuro: #143d8f;
  --azul-claro: #2563d4;
  --amarelo: #FFDD57;
  --amarelo-escuro: #f5c842;

  /* Neutros — modo claro */
  --bg-app: #f7f9fc;
  --bg-card: #ffffff;
  --bg-input: #ffffff;
  --border: #e1e6ee;
  --border-strong: #d4dae8;
  --texto-principal: #1a2332;
  --texto-secundario: #4a5468;
  --texto-suave: #6a7488;
  --texto-muito-suave: #8a94a8;

  /* Estados */
  --sucesso: #16a34a;
  --sucesso-bg: #dcfce7;
  --aviso: #92670d;
  --aviso-bg: #fff4d4;
  --erro: #dc2626;
  --erro-bg: #fde8e8;

  /* Sombras */
  --sombra-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --sombra-md: 0 2px 8px rgba(0, 0, 0, 0.08);
  --sombra-lg: 0 8px 32px rgba(0, 0, 0, 0.08);
  --sombra-azul: 0 4px 16px rgba(26, 77, 179, 0.18);

  /* Tipografia (corpo 14-15px — D14) */
  --fonte: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --fonte-titulos: 'Fraunces', Georgia, 'Times New Roman', serif;
  --fonte-tamanho-base: 14px;
  --fonte-tamanho-sm: 12px;
  --fonte-tamanho-lg: 16px;
  --linha: 1.5;

  /* Espaçamento */
  --raio-sm: 6px;
  --raio: 8px;
  --raio-lg: 12px;
  --raio-pill: 100px;

  /* Transições */
  --transicao: 0.15s ease;

  /* Mobile header */
  --header-mobile-from: #0f1729;
  --header-mobile-to:   #1a2342;
  --header-mobile-borda: #2a3654;

  --azul-hover:  #143d8f;
  --azul-suave:  #EBF1FF;
  --fundo-hover: #f0f4f8;
  --fundo-suave: #f8fafc;
}

/* ============================================================
   TEMA ESCURO — automático no mobile (D14) e disponível via
   html[data-theme="dark"] para o futuro
   ============================================================ */
html[data-theme="dark"] {
  --bg-app:   #0d1424;
  --bg-card:  #1a2540;
  --bg-input: #1a2540;
  --border:        #2d3a52;
  --border-strong: #3d4d68;
  --texto-principal:   #f0f4f8;
  --texto-secundario:  #8b9ab8;
  --texto-suave:       #5c6a88;
  --texto-muito-suave: #3d4a68;
  --sucesso:    #34d399;
  --sucesso-bg: #064e3b;
  --aviso:      #fbbf24;
  --aviso-bg:   #451a03;
  --erro:       #f87171;
  --erro-bg:    #450a0a;
  --sombra-sm:   0 1px 3px rgba(0, 0, 0, 0.4);
  --sombra-md:   0 2px 8px rgba(0, 0, 0, 0.5);
  --sombra-lg:   0 8px 32px rgba(0, 0, 0, 0.5);
  --sombra-azul: 0 4px 16px rgba(26, 77, 179, 0.4);
  --fundo-hover: #253454;
  --fundo-suave: #1a2540;
  --azul-suave:  #1a3466;
}

@media (max-width: 900px) {
  /* Mobile = tema escuro (D14). Mesmos valores do bloco acima. */
  :root {
    --bg-app:   #0d1424;
    --bg-card:  #1a2540;
    --bg-input: #1a2540;
    --border:        #2d3a52;
    --border-strong: #3d4d68;
    --texto-principal:   #f0f4f8;
    --texto-secundario:  #8b9ab8;
    --texto-suave:       #5c6a88;
    --texto-muito-suave: #3d4a68;
    --sucesso:    #34d399;
    --sucesso-bg: #064e3b;
    --aviso:      #fbbf24;
    --aviso-bg:   #451a03;
    --erro:       #f87171;
    --erro-bg:    #450a0a;
    --sombra-sm:   0 1px 3px rgba(0, 0, 0, 0.4);
    --sombra-md:   0 2px 8px rgba(0, 0, 0, 0.5);
    --sombra-lg:   0 8px 32px rgba(0, 0, 0, 0.5);
    --sombra-azul: 0 4px 16px rgba(26, 77, 179, 0.4);
    --fundo-hover: #253454;
    --fundo-suave: #1a2540;
    --azul-suave:  #1a3466;
  }
}

/* ============================================================
   RESET
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--fonte);
  font-size: var(--fonte-tamanho-base);
  line-height: var(--linha);
  color: var(--texto-principal);
  background: var(--bg-app);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
button { font-family: inherit; cursor: pointer; border: 0; background: none; }
input, select, textarea { font-family: inherit; font-size: inherit; }
a { color: var(--azul-primario); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Títulos em Fraunces (D14) */
h1, h2, .page-titulo, .login-titulo, .login-brand h1, .card-titulo {
  font-family: var(--fonte-titulos);
}

/* ============================================================
   COMPONENTE: BOTÃO
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--raio);
  font-size: var(--fonte-tamanho-base);
  font-weight: 600;
  transition: var(--transicao);
  border: 1px solid transparent;
  white-space: nowrap;
}
.btn-primario { background: var(--azul-primario); color: #fff; }
.btn-primario:hover { background: var(--azul-escuro); }
.btn-primario:active { transform: translateY(1px); }
.btn-primario:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-secundario {
  background: var(--bg-card);
  color: var(--texto-principal);
  border-color: var(--border-strong);
}
.btn-secundario:hover { background: var(--fundo-hover); }
.btn-bloco { width: 100%; padding: 12px 18px; font-size: var(--fonte-tamanho-lg); }

/* ============================================================
   COMPONENTE: INPUT
   ============================================================ */
.input-wrapper { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.input-label {
  font-size: var(--fonte-tamanho-sm);
  font-weight: 600;
  color: var(--texto-secundario);
}
.input-field {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--raio);
  background: var(--bg-input);
  color: var(--texto-principal);
  transition: var(--transicao);
}
.input-field:focus {
  outline: none;
  border-color: var(--azul-primario);
  box-shadow: 0 0 0 3px rgba(26, 77, 179, 0.12);
}
.input-field:disabled { background: var(--bg-app); cursor: not-allowed; }
.input-field.erro {
  border-color: var(--erro);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}
.input-erro-msg { font-size: var(--fonte-tamanho-sm); color: var(--erro); margin-top: 2px; }

/* ============================================================
   COMPONENTE: ALERT
   ============================================================ */
.alerta {
  padding: 12px 14px;
  border-radius: var(--raio);
  font-size: var(--fonte-tamanho-base);
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.alerta-erro { background: var(--erro-bg); color: var(--erro); }
.alerta-aviso { background: var(--aviso-bg); color: var(--aviso); }
.alerta-sucesso { background: var(--sucesso-bg); color: var(--sucesso); }
.alerta-icone { font-weight: 700; flex-shrink: 0; }

/* ============================================================
   UTILITÁRIOS
   ============================================================ */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.itens-centro { align-items: center; }
.justifica-centro { justify-content: center; }
.justifica-entre { justify-content: space-between; }
.gap-sm { gap: 8px; }
.gap { gap: 16px; }
.gap-lg { gap: 24px; }
.texto-centro { text-align: center; }
.texto-suave { color: var(--texto-suave); }
.texto-pequeno { font-size: var(--fonte-tamanho-sm); }
.escondido { display: none !important; }

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: girar 0.8s linear infinite;
}
@keyframes girar { to { transform: rotate(360deg); } }

/* ============================================================
   ESTRUTURA DO APP LOGADO (origem: app.css do Hub)
   Desktop: sidebar branca à esquerda + conteúdo
   Mobile:  header escuro com menu hambúrguer
   ============================================================ */
.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-logo-area {
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}
.sidebar-logo-area img {
  /* Logo retangular do cliente: proporção natural, sem moldura. */
  width: 88px;
  height: auto;
  object-fit: contain;
  flex-shrink: 0;
}
.sidebar-logo-text { display: flex; flex-direction: column; line-height: 1.15; }
.sidebar-logo-text strong {
  font-size: 14px;
  color: var(--azul-primario);
  font-weight: 800;
}
.sidebar-logo-text small {
  font-size: 10px;
  color: var(--texto-muito-suave);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.sidebar-secao {
  padding: 16px 18px 6px;
  font-size: 10px;
  color: var(--texto-muito-suave);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 700;
}

.sidebar-menu { padding: 0 8px; }

.sidebar-item {
  padding: 9px 12px;
  border-radius: var(--raio);
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--texto-secundario);
  font-weight: 500;
  font-size: 13px;
  margin-bottom: 2px;
  transition: var(--transicao);
}
.sidebar-item:hover {
  background: var(--fundo-hover);
  text-decoration: none;
  color: var(--texto-principal);
}
.sidebar-item.ativo {
  background: linear-gradient(135deg, var(--azul-primario) 0%, var(--azul-claro) 100%);
  color: #fff;
  box-shadow: var(--sombra-azul);
}
.sidebar-item.ativo:hover { color: #fff; }
.sidebar-item-icone {
  width: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Itens em construção (marca da fase) */
.sidebar-stub { opacity: 0.45; cursor: not-allowed; }
.sidebar-stub:hover {
  background: none !important;
  color: var(--texto-secundario) !important;
  text-decoration: none;
}
.sidebar-stub-tag {
  font-size: 9px;
  margin-left: auto;
  color: var(--texto-muito-suave);
  font-style: italic;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.sidebar-rodape {
  margin-top: auto;
  padding: 16px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-avatar {
  width: 36px;
  height: 36px;
  background: var(--azul-primario);
  color: var(--amarelo);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 13px;
  flex-shrink: 0;
}
.sidebar-user-nome {
  font-size: 13px;
  font-weight: 600;
  color: var(--texto-principal);
  line-height: 1.3;
}
.sidebar-user-perfil { font-size: 11px; color: var(--texto-suave); }
/* Botão Sair: ícone claro de saída + rótulo — é o único botão da tela
   com consequência e precisa ser reconhecível. */
.btn-logout {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: var(--raio);
  color: var(--texto-suave);
  font-size: 12px;
  font-weight: 600;
  transition: var(--transicao);
  margin-left: auto;
}
.btn-logout:hover { background: var(--erro-bg); color: var(--erro); }

/* ============================================================
   CONTEÚDO PRINCIPAL
   ============================================================ */
.main-area {
  padding: 24px 28px;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.main-conteudo { flex: 1; }

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}
.page-titulo {
  font-size: 22px;
  font-weight: 700;
  color: var(--texto-principal);
  letter-spacing: -0.3px;
}
.page-subtitulo { font-size: 13px; color: var(--texto-suave); margin-top: 4px; }

/* ============================================================
   COMPONENTE: CARD (barra lateral colorida — D14)
   ============================================================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--raio-lg);
  padding: 20px;
  position: relative;
}
.card-borda-azul::before {
  content: "";
  position: absolute;
  left: 0; top: 0;
  width: 4px;
  height: 100%;
  background: linear-gradient(180deg, var(--azul-primario), var(--azul-claro));
  border-radius: var(--raio-lg) 0 0 var(--raio-lg);
}
.card-borda-amarela::before {
  content: "";
  position: absolute;
  left: 0; top: 0;
  width: 4px;
  height: 100%;
  background: linear-gradient(180deg, var(--amarelo), var(--amarelo-escuro));
  border-radius: var(--raio-lg) 0 0 var(--raio-lg);
}
.card-titulo {
  font-size: 14px;
  font-weight: 700;
  color: var(--texto-principal);
  margin-bottom: 12px;
}
/* Cartão "Meu acesso" do painel (a CSP proíbe estilo inline) */
.card-meu-acesso { max-width: 480px; }

/* Linhas de informação do cartão do usuário */
.info-linha {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.info-linha:last-child { border-bottom: 0; }
.info-rotulo { color: var(--texto-suave); }
.info-valor { font-weight: 600; color: var(--texto-principal); }

/* ============================================================
   RODAPÉ — assinatura da Franciscana (D14)
   ============================================================ */
.rodape-assinatura {
  margin-top: 32px;
  padding: 16px 0 4px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
}
.rodape-assinatura img {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  object-fit: contain;
  opacity: 0.85;
}

/* ============================================================
   HEADER MOBILE
   ============================================================ */
.app-header-mobile { display: none; }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 998;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
.sidebar-overlay.visivel { display: block; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100dvh;
    width: 280px;
    z-index: 999;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: none;
  }
  .sidebar.mobile-aberta {
    transform: translateX(0);
    box-shadow: 8px 0 40px rgba(0, 0, 0, 0.35);
  }

  .app-header-mobile {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    background: linear-gradient(135deg, var(--header-mobile-from) 0%, var(--header-mobile-to) 100%);
    padding: 10px 14px;
    color: #fff;
    border-bottom: 1px solid var(--header-mobile-borda);
    position: sticky;
    top: 0;
    z-index: 10;
  }
  .app-header-mobile .logo-mini {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
  }
  .app-header-mobile .logo-mini img { width: 64px; height: auto; object-fit: contain; }
  .app-header-mobile .logo-mini strong {
    font-size: 13px;
    color: var(--amarelo);
    font-weight: 800;
    letter-spacing: 0.3px;
  }

  .btn-menu-mobile, .btn-logout-mobile {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.10);
    border-radius: var(--raio);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    transition: background 0.15s;
  }
  .btn-menu-mobile:hover, .btn-logout-mobile:hover {
    background: rgba(255, 255, 255, 0.2);
  }

  .main-area { padding: 16px; min-height: auto; }
  .page-titulo { font-size: 18px; }
  .page-header { gap: 10px; }
}

/* ============================================================
   TELA DE LOGIN (origem: login.css do Hub)
   ============================================================ */
.login-container {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.login-brand {
  background:
    radial-gradient(circle at 20% 30%, rgba(255, 221, 87, 0.15) 0%, transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(255, 221, 87, 0.1) 0%, transparent 40%),
    linear-gradient(135deg, #1A4DB3 0%, #143d8f 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 32px;
  color: #fff;
  position: relative;
  overflow: hidden;
}
.login-brand::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 24px 24px;
  pointer-events: none;
}
.login-brand-conteudo {
  position: relative;
  z-index: 1;
  text-align: center;
  max-width: 420px;
}
/* Logo do cliente: retangular, solta sobre o fundo azul — sem moldura,
   sem fundo, sem arredondamento. Largura fixa, altura automática e
   object-fit: contain para a proporção original nunca esticar. */
.login-logo {
  width: 260px;
  height: auto;
  object-fit: contain;
  margin-bottom: 32px;
}
.login-brand h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 10px;
  color: #fff;
}
.login-brand p {
  font-size: 15px;
  color: rgba(255, 255, 255, 0.85);
  line-height: 1.6;
  margin-bottom: 32px;
}
/* Assinatura da Franciscana: SEMPRE só o símbolo, nunca o nome escrito.
   Discreto: pequeno, cantos levemente arredondados. O alt da imagem
   ("Franciscana Representações") preserva acessibilidade e autoria. */
.login-brand-simbolo {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  object-fit: contain;
  opacity: 0.9;
}

.login-form-area {
  background: var(--bg-card);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 48px 32px;
  position: relative;
}
.login-form-box { width: 100%; max-width: 380px; }
.login-titulo {
  font-size: 24px;
  font-weight: 700;
  color: var(--texto-principal);
  margin-bottom: 6px;
  letter-spacing: -0.3px;
}
.login-subtitulo {
  font-size: 14px;
  color: var(--texto-suave);
  margin-bottom: 28px;
}
.login-form-rodape { margin-top: 32px; text-align: center; }
.login-form-rodape img {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  object-fit: contain;
  opacity: 0.85;
}

@media (max-width: 900px) {
  .login-container { grid-template-columns: 1fr; min-height: 100vh; }
  .login-brand { padding: 32px 24px 24px; min-height: 240px; }
  .login-logo { width: 150px; margin-bottom: 16px; }
  .login-brand h1 { font-size: 20px; margin-bottom: 4px; }
  .login-brand p { font-size: 13px; margin-bottom: 12px; }
  .login-brand-tagline { font-size: 11px; padding: 6px 14px; }
  .login-form-area { padding: 32px 20px 48px; }
  .login-titulo { font-size: 20px; }
}
@media (max-width: 480px) {
  .login-form-area { padding: 28px 16px 40px; }
}
