/* =============================================================================
   Portal RI · Grupo Coimex — coimex.css
   Identidade visual (Seção 3): azul institucional + neutros claros, sóbrio e
   corporativo. Complementa o Bootstrap 5.3 (carregado antes deste arquivo).
   ========================================================================== */

:root {
  /* Azul institucional Coimex */
  --coimex-blue:        #00457c;
  --coimex-blue-dark:   #002d52;
  --coimex-blue-darker: #001f3a;
  --coimex-blue-light:  #1976c4;
  --coimex-azure:       #00a0df;  /* [CONFIRMAR] acento vibrante p/ CTAs pontuais */

  /* Neutros */
  --bg:       #f5f7fa;
  --surface:  #ffffff;
  --border:   #e4e9f0;
  --text:     #1c2733;
  --text-muted: #6b7785;

  /* Semânticos */
  --success: #2e7d5b;
  --warning: #c9922e;
  --danger:  #b03a3a;

  /* Tokens de UI */
  --radius:      12px;
  --radius-sm:   8px;
  --shadow-sm:   0 1px 2px rgba(0, 31, 58, .06), 0 1px 3px rgba(0, 31, 58, .05);
  --shadow-md:   0 4px 16px rgba(0, 31, 58, .10);
  --shadow-lg:   0 12px 32px rgba(0, 31, 58, .16);
  --transition:  180ms cubic-bezier(.4, 0, .2, 1);

  /* Mapeia variáveis do Bootstrap para a paleta Coimex */
  --bs-primary: var(--coimex-blue);
  --bs-body-color: var(--text);
  --bs-body-bg: var(--bg);
  --bs-link-color: var(--coimex-blue-light);
  --bs-link-hover-color: var(--coimex-blue);
  --bs-border-color: var(--border);
}

/* ------------------------------ Base ------------------------------------- */
body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6,
.navbar-brand, .display-6 {
  font-family: 'Poppins', 'Inter', system-ui, sans-serif;
  font-weight: 600;
  color: var(--coimex-blue-dark);
  letter-spacing: -.01em;
}

a { text-decoration: none; }
a:hover { text-decoration: none; }

.text-muted { color: var(--text-muted) !important; }

/* --------------------------- Eyebrow (Seção 3.2) -------------------------- */
/* Rótulo de seção estilo Coimex: - NOME DA SEÇÃO -                          */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  font-size: .72rem;
  font-weight: 600;
  color: var(--coimex-blue-light);
  margin-bottom: .5rem;
}
.eyebrow::before,
.eyebrow::after {
  content: "";
  width: 22px;
  height: 1px;
  background: currentColor;
  opacity: .7;
}
.eyebrow--start::before { display: none; }  /* variante só com traço à direita */

/* ------------------------------ Navbar ----------------------------------- */
.navbar-coimex {
  background: var(--coimex-blue);
  box-shadow: var(--shadow-sm);
}
.navbar-coimex .navbar-brand {
  color: #fff;
  font-weight: 700;
  letter-spacing: .5px;
  display: flex;
  align-items: center;
  gap: .6rem;
}
.navbar-coimex .navbar-brand img { height: 34px; width: auto; }
.navbar-coimex .brand-fallback {
  font-size: 1.05rem;
  display: inline-flex;
  align-items: center;
  gap: .5rem;
}
.navbar-coimex .brand-fallback .brand-mark {
  width: 34px; height: 34px; border-radius: 8px;
  background: #fff; color: var(--coimex-blue);
  display: grid; place-items: center; font-weight: 800;
}
.navbar-coimex .nav-link {
  color: rgba(255, 255, 255, .85);
  font-weight: 500;
  padding: .5rem .9rem !important;
  border-radius: var(--radius-sm);
  transition: background var(--transition), color var(--transition);
}
.navbar-coimex .nav-link:hover,
.navbar-coimex .nav-link:focus { color: #fff; background: rgba(255, 255, 255, .12); }
.navbar-coimex .nav-link.active { color: #fff; background: rgba(255, 255, 255, .18); }
.navbar-coimex .navbar-toggler { border-color: rgba(255, 255, 255, .35); }
.navbar-coimex .navbar-toggler:focus { box-shadow: 0 0 0 .2rem rgba(255, 255, 255, .25); }

/* Avatar do usuário */
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--coimex-azure); color: #fff;
  display: grid; place-items: center;
  font-weight: 700; font-size: .8rem;
  font-family: 'Poppins', sans-serif;
}
.dropdown-menu { border: 1px solid var(--border); box-shadow: var(--shadow-md); border-radius: var(--radius-sm); }

/* ------------------------------ Cards ------------------------------------ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition);
}
.card-hover:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

/* Card de documento */
.doc-card { height: 100%; display: flex; flex-direction: column; }
.doc-card .doc-icon {
  width: 48px; height: 48px; border-radius: 10px;
  display: grid; place-items: center; font-size: 1.5rem;
  background: rgba(0, 69, 124, .08); color: var(--coimex-blue);
  flex-shrink: 0;
}
.doc-card .doc-title {
  font-family: 'Poppins', sans-serif; font-weight: 600; font-size: 1rem;
  color: var(--coimex-blue-dark); line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.doc-meta { font-size: .8rem; color: var(--text-muted); }

/* Atalho de categoria (dashboard) */
.category-tile {
  display: flex; align-items: center; gap: .85rem;
  padding: 1rem; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); box-shadow: var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}
.category-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--coimex-blue-light); color: var(--text); }
.category-tile .tile-icon {
  width: 44px; height: 44px; border-radius: 10px; flex-shrink: 0;
  display: grid; place-items: center; font-size: 1.3rem;
  background: linear-gradient(135deg, var(--coimex-blue), var(--coimex-blue-light)); color: #fff;
}
.category-tile .tile-count {
  margin-left: auto; font-family: 'Poppins', sans-serif; font-weight: 700;
  color: var(--coimex-blue); font-size: 1.1rem;
}

/* ------------------------------ Buttons ---------------------------------- */
.btn-primary {
  --bs-btn-bg: var(--coimex-blue);
  --bs-btn-border-color: var(--coimex-blue);
  --bs-btn-hover-bg: var(--coimex-blue-dark);
  --bs-btn-hover-border-color: var(--coimex-blue-dark);
  --bs-btn-active-bg: var(--coimex-blue-darker);
  --bs-btn-active-border-color: var(--coimex-blue-darker);
  --bs-btn-disabled-bg: var(--coimex-blue);
  --bs-btn-disabled-border-color: var(--coimex-blue);
  font-weight: 500;
}
.btn-outline-primary {
  --bs-btn-color: var(--coimex-blue);
  --bs-btn-border-color: var(--coimex-blue);
  --bs-btn-hover-bg: var(--coimex-blue);
  --bs-btn-hover-border-color: var(--coimex-blue);
  --bs-btn-active-bg: var(--coimex-blue-dark);
  font-weight: 500;
}
.btn-azure {
  --bs-btn-color: #fff; --bs-btn-bg: var(--coimex-azure); --bs-btn-border-color: var(--coimex-azure);
  --bs-btn-hover-bg: #0090c8; --bs-btn-hover-border-color: #0090c8; --bs-btn-hover-color: #fff;
  color: #fff; font-weight: 500;
}
.btn { border-radius: var(--radius-sm); }

/* --------------------------- Hero / gradiente ---------------------------- */
.hero-gradient {
  background: linear-gradient(135deg, var(--coimex-blue-darker) 0%, var(--coimex-blue) 60%, var(--coimex-blue-light) 130%);
  color: #fff; border-radius: var(--radius);
  padding: 2rem; box-shadow: var(--shadow-md);
  position: relative; overflow: hidden;
}
.hero-gradient h1, .hero-gradient .h1 { color: #fff; }
.hero-gradient::after {
  content: ""; position: absolute; right: -60px; top: -60px;
  width: 220px; height: 220px; border-radius: 50%;
  background: radial-gradient(circle, rgba(0,160,223,.35), transparent 70%);
}

/* ----------------------------- Badges ------------------------------------ */
.badge-soft { background: rgba(0, 69, 124, .08); color: var(--coimex-blue); font-weight: 600; }
.badge-status-publicado { background: rgba(46, 125, 91, .12); color: var(--success); }
.badge-status-rascunho  { background: rgba(201, 146, 46, .14); color: var(--warning); }
.badge-status-arquivado { background: rgba(107, 119, 133, .14); color: var(--text-muted); }
.badge-restrito { background: rgba(176, 58, 58, .10); color: var(--danger); font-weight: 600; }
.badge-sso { background: rgba(0, 120, 212, .10); color: #0067c0; font-weight: 600; }

/* Pré-visualização do corpo do e-mail (iframe isolado no editor de modelos) */
.tpl-preview-frame {
  width: 100%; min-height: 340px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: #fff; display: block;
}

/* --------------------------- Forms / inputs ------------------------------ */
.form-control, .form-select {
  border-radius: var(--radius-sm); border-color: var(--border);
  padding: .55rem .8rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--coimex-blue-light);
  box-shadow: 0 0 0 .2rem rgba(25, 118, 196, .15);
}
.form-label { font-weight: 500; color: var(--coimex-blue-dark); font-size: .9rem; }

/* Área de drag & drop */
.dropzone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 2.5rem 1.5rem; text-align: center; background: var(--surface);
  color: var(--text-muted); transition: border-color var(--transition), background var(--transition);
  cursor: pointer;
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--coimex-blue-light); background: rgba(25, 118, 196, .04); color: var(--coimex-blue);
}
.dropzone .dz-icon { font-size: 2.4rem; color: var(--coimex-blue-light); }

/* ------------------------------ Tables ----------------------------------- */
.table-coimex { --bs-table-hover-bg: rgba(0, 69, 124, .03); }
.table-coimex thead th {
  background: var(--coimex-blue-dark); color: #fff; font-weight: 500;
  font-size: .82rem; text-transform: uppercase; letter-spacing: .5px;
  border-bottom: none; white-space: nowrap;
}
.table-coimex td { vertical-align: middle; }

/* ------------------------------ Footer ----------------------------------- */
.footer-coimex {
  background: var(--coimex-blue-dark); color: rgba(255, 255, 255, .8);
  padding: 1.5rem 0; margin-top: auto; font-size: .88rem;
}
.footer-coimex a { color: #fff; }

/* --------------------------- Skeleton loaders ---------------------------- */
.skeleton {
  background: linear-gradient(90deg, #eef1f6 25%, #e2e8f0 37%, #eef1f6 63%);
  background-size: 400% 100%;
  animation: skeleton-loading 1.3s ease infinite;
  border-radius: var(--radius-sm);
}
@keyframes skeleton-loading { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* --------------------------- Animações de entrada ------------------------ */
.fade-in-up { animation: fadeInUp .4s ease both; }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.stagger > * { animation: fadeInUp .4s ease both; }
.stagger > *:nth-child(1) { animation-delay: .03s; }
.stagger > *:nth-child(2) { animation-delay: .06s; }
.stagger > *:nth-child(3) { animation-delay: .09s; }
.stagger > *:nth-child(4) { animation-delay: .12s; }
.stagger > *:nth-child(5) { animation-delay: .15s; }
.stagger > *:nth-child(6) { animation-delay: .18s; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ------------------------------ Empty states ----------------------------- */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.empty-state .empty-icon { font-size: 3rem; color: var(--border); }

/* --------------------------- Auth (login) -------------------------------- */
.auth-wrap {
  min-height: 100vh; display: grid; grid-template-columns: 1fr;
  background: var(--bg);
}
.auth-hero {
  display: none;
  background: linear-gradient(150deg, var(--coimex-blue-darker), var(--coimex-blue) 70%);
  color: #fff; padding: 3rem; position: relative; overflow: hidden;
}
.auth-card {
  width: 100%; max-width: 420px; margin: auto; padding: 2rem;
}
/* Div dedicada ao logo no painel institucional */
.auth-brand {
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, .16);
}
.auth-brand img {
  height: 56px;
  width: auto;
  max-width: 240px;
  display: block;
}
@media (min-width: 992px) {
  .auth-wrap { grid-template-columns: 1.1fr .9fr; }
  .auth-hero { display: flex; flex-direction: column; justify-content: center; }
}

/* Botão de SSO (Microsoft 365): neutro e sóbrio, seguindo a diretriz da marca
   Microsoft (fundo branco, texto escuro, logo à esquerda). */
.btn-sso {
  display: inline-flex; align-items: center; justify-content: center; gap: .6rem;
  background: #fff; color: #3b3b3b; font-weight: 600;
  border: 1px solid #d0d3d9;
}
.btn-sso:hover, .btn-sso:focus {
  background: #f6f7f9; color: #1a1a1a; border-color: #b9bdc6;
}
.btn-sso-logo { flex: 0 0 auto; }

/* Divisor "ou" entre o SSO e o login por senha */
.auth-divider {
  display: flex; align-items: center; gap: .75rem;
  color: var(--text-muted); font-size: .8rem; margin: .25rem 0 .75rem;
}
.auth-divider::before, .auth-divider::after {
  content: ""; flex: 1 1 auto; height: 1px; background: var(--border);
}
.btn-toggle-local { text-decoration: none; color: var(--coimex-blue); font-weight: 500; }
.btn-toggle-local:hover { text-decoration: underline; }
/* Gira o cursor visual do toggle conforme o estado do collapse */
.btn-toggle-local[aria-expanded="true"] .bi-key::before { opacity: .6; }

/* --------------------------- PDF Viewer + watermark ---------------------- */
.pdf-stage {
  position: relative; background: #33404f; border-radius: var(--radius);
  overflow: auto; min-height: 60vh; max-height: 82vh; padding: 1rem;
}
/* Cada página do PDF fica em um wrapper próprio, para receber sua marca d'água */
.pdf-page {
  position: relative; margin: 0 auto 1rem; box-shadow: var(--shadow-lg); background: #fff;
}
.pdf-page canvas { display: block; }
/* Marca d'água dinâmica sobreposta EM CADA página (Seção 6.2) — dissuasória.
   Aplicada por página (não como overlay único) para cobrir todo o documento. */
.pdf-page-wm {
  position: absolute; inset: 0; pointer-events: none; z-index: 5;
  opacity: .16; background-repeat: repeat;
}
.reader-toolbar {
  display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
  background: var(--coimex-blue-dark); color: #fff;
  padding: .5rem .75rem; border-radius: var(--radius) var(--radius) 0 0;
}
.reader-toolbar .btn { --bs-btn-color: #fff; }

/* Mobile: viewer em tela cheia */
@media (max-width: 767px) {
  .pdf-stage { max-height: none; min-height: 70vh; }
}

/* --------------------------- Toasts -------------------------------------- */
.toast-container { z-index: 1100; }

/* Utilitário: texto de destaque azul */
.text-coimex { color: var(--coimex-blue) !important; }
.bg-coimex-soft { background: rgba(0, 69, 124, .05); }
