/* ============================================================
   SISTEMA RH — custom.css
   Estilos customizados que complementam o Tailwind.
   Este arquivo NÃO usa @apply — apenas CSS puro.
   Carregado após o output.css do Tailwind.
   ============================================================ */


/* ------------------------------------------------------------
   LOGO — utilitários de apresentação
   ------------------------------------------------------------ */

/* Inverte logo escuro para branco puro (uso em fundos coloridos/escuros) */
.logo-white {
  filter: brightness(0) invert(1);
}


/* ------------------------------------------------------------
   ANIMAÇÕES GLOBAIS
   ------------------------------------------------------------ */

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInRight {
  from { opacity: 0; transform: translateX(12px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes pulse-soft {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.6; }
}

@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}

@keyframes loading-bar {
  0%   { width: 0%; opacity: 1; }
  70%  { width: 80%; opacity: 1; }
  100% { width: 100%; opacity: 0; }
}

/* Classes de animação reutilizáveis */
.animate-fade-in       { animation: fadeIn 0.2s ease-out both; }
.animate-fade-in-right { animation: fadeInRight 0.2s ease-out both; }
.animate-slide-down    { animation: slideDown 0.18s ease-out both; }
.animate-slide-up      { animation: slideUp 0.18s ease-out both; }
.animate-scale-in      { animation: scaleIn 0.15s ease-out both; }
.animate-pulse-soft    { animation: pulse-soft 2s ease-in-out infinite; }

/* Delay helpers */
.delay-75  { animation-delay: 75ms; }
.delay-100 { animation-delay: 100ms; }
.delay-150 { animation-delay: 150ms; }
.delay-200 { animation-delay: 200ms; }
.delay-300 { animation-delay: 300ms; }


/* ------------------------------------------------------------
   SKELETON LOADING (shimmer animado)
   ------------------------------------------------------------ */

.skeleton-shimmer {
  background: linear-gradient(
    90deg,
    #f1f5f9 25%,
    #e2e8f0 50%,
    #f1f5f9 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: 0.5rem;
}


/* ------------------------------------------------------------
   LOADING BAR — barra de progresso HTMX no topo da página
   ------------------------------------------------------------ */

#htmx-indicator {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 2px;
  z-index: 9999;
  background: linear-gradient(90deg, #38bdf8, #818cf8);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s ease, opacity 0.3s ease;
  opacity: 0;
}

#htmx-indicator.htmx-request  { transform: scaleX(0.7); opacity: 1; }
.htmx-settling #htmx-indicator { transform: scaleX(1); }
.htmx-swapping #htmx-indicator { opacity: 0; }


/* ------------------------------------------------------------
   HTMX — estados de requisição
   ------------------------------------------------------------ */

/* Elemento sendo substituído via HTMX */
.htmx-swapping {
  opacity: 0;
  transition: opacity 0.15s ease-out;
}

/* Elemento recém inserido via HTMX */
.htmx-added {
  animation: fadeIn 0.2s ease-out both;
}

/* Botão com hx-indicator durante carregamento */
.htmx-request .htmx-indicator {
  display: inline-flex;
}

.htmx-indicator {
  display: none;
}

/* Ocultar ícone estático durante request (par do htmx-indicator) */
button.htmx-request .htmx-static-icon { display: none; }

/* Desabilitar botão durante request */
.htmx-request[disabled],
button.htmx-request {
  opacity: 0.7;
  pointer-events: none;
  cursor: not-allowed;
}


/* ------------------------------------------------------------
   NAVEGAÇÃO LATERAL — nav-link, nav-section, nav-group-btn
   ------------------------------------------------------------ */

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.375rem 0.625rem;
  border-radius: 0.375rem;
  font-size: 0.8125rem;
  font-weight: 500;
  text-decoration: none;
  color: #94a3b8;
  transition: background 0.12s, color 0.12s;
  line-height: 1.3;
}
.nav-link:hover { background: rgba(255,255,255,0.05); color: #e2e8f0; }
.nav-link.active {
  background: rgba(56,189,248,0.12);
  color: #38bdf8;
  font-weight: 600;
  box-shadow: inset 2px 0 0 0 #38bdf8;
}
.nav-link svg { flex-shrink: 0; width: 0.9375rem; height: 0.9375rem; opacity: 0.8; }
.nav-link.active svg { opacity: 1; }
.nav-link.disabled { opacity: 0.35; cursor: not-allowed; pointer-events: none; }
.nav-link:focus-visible,
.nav-group-btn:focus-visible {
  outline: none;
  background: rgba(255,255,255,0.07);
  box-shadow: 0 0 0 2px rgba(56,189,248,0.55);
}

.nav-section {
  padding: 0.5rem 0.625rem 0.25rem;
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #475569;
  margin-top: 0.75rem;
}
.nav-section:first-child { margin-top: 0; }

.nav-group-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.375rem 0.625rem;
  border-radius: 0.375rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: #94a3b8;
  background: none;
  border: none;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.nav-group-btn:hover { background: rgba(255,255,255,0.05); color: #e2e8f0; }
.nav-group-btn .btn-inner { display: flex; align-items: center; gap: 0.625rem; }
.nav-group-btn svg.icon    { width: 0.9375rem; height: 0.9375rem; opacity: 0.8; flex-shrink: 0; }
.nav-group-btn svg.chevron { width: 0.625rem; height: 0.625rem; transition: transform 0.2s; opacity: 0.7; }
.nav-group-btn.nav-group-active { color: #cbd5e1; }
.nav-group-btn.nav-group-active svg.icon { opacity: 1; color: #7dd3fc; }


/* ------------------------------------------------------------
   ACESSIBILIDADE — foco visível por teclado
   O reset global remove o outline; aqui garantimos um indicador
   de foco consistente para navegação por teclado em qualquer
   elemento interativo que não tenha um estilo de foco próprio.
   ------------------------------------------------------------ */
a:focus-visible,
button:focus-visible,
[role="button"]:focus-visible,
summary:focus-visible {
  outline: 2px solid #0ea5e9;
  outline-offset: 2px;
  border-radius: 0.375rem;
}


/* ------------------------------------------------------------
   SIDEBAR — detalhes e scrollbar interna
   ------------------------------------------------------------ */

aside nav::-webkit-scrollbar {
  width: 3px;
}

aside nav::-webkit-scrollbar-track {
  background: transparent;
}

aside nav::-webkit-scrollbar-thumb {
  background: #334155;
  border-radius: 9999px;
}

aside nav::-webkit-scrollbar-thumb:hover {
  background: #475569;
}


/* ------------------------------------------------------------
   FORMULÁRIOS — estados e transições visuais
   ------------------------------------------------------------ */

/* Foco com brilho suave */
.input-field:focus {
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15);
}

.input-field.error:focus {
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

/* Select — garantir estilo customizado em todos os navegadores */
select.input-field {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.625rem center;
  background-size: 1rem;
  padding-right: 2.5rem;
}

/* File input */
input[type="file"].input-field {
  padding: 0.375rem 0.75rem;
  cursor: pointer;
}

input[type="file"].input-field::file-selector-button {
  margin-right: 0.75rem;
  padding: 0.25rem 0.75rem;
  border-radius: 0.375rem;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #475569;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

input[type="file"].input-field::file-selector-button:hover {
  background: #f1f5f9;
}

/* Checkbox e Radio customizados */
input[type="checkbox"],
input[type="radio"] {
  width: 1rem;
  height: 1rem;
  border: 1.5px solid #cbd5e1;
  border-radius: 0.25rem;
  accent-color: #0284c7;
  cursor: pointer;
  flex-shrink: 0;
}

input[type="radio"] {
  border-radius: 50%;
}

input[type="checkbox"]:focus,
input[type="radio"]:focus {
  outline: 2px solid rgba(14, 165, 233, 0.4);
  outline-offset: 2px;
}


/* ------------------------------------------------------------
   TABELAS — efeito zebra opcional e células fixas
   ------------------------------------------------------------ */

/* Cabeçalho fixo em tabelas longas */
.table-sticky-head thead {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
}

/* Zebra striping opcional — adicione .table-striped na tag table */
.table-striped tbody tr:nth-child(even) {
  background-color: #f8fafc;
}

/* Coluna de ações fixada à direita em tabelas com scroll horizontal */
.table-sticky-actions td:last-child,
.table-sticky-actions th:last-child {
  position: sticky;
  right: 0;
  background: inherit;
}

/* Linha selecionada */
.table tbody tr.selected {
  background-color: #f0f9ff;
  border-left: 2px solid #0284c7;
}

/* Linha de totais / rodapé de tabela */
.table tfoot tr {
  background: #f8fafc;
  border-top: 2px solid #e2e8f0;
  font-weight: 600;
}


/* ------------------------------------------------------------
   CARDS — variantes e efeitos
   ------------------------------------------------------------ */

/* Card com borda colorida no lado esquerdo */
.card-accent-blue   { border-left: 3px solid #38bdf8; }
.card-accent-green  { border-left: 3px solid #34d399; }
.card-accent-amber  { border-left: 3px solid #fbbf24; }
.card-accent-red    { border-left: 3px solid #f87171; }
.card-accent-purple { border-left: 3px solid #a78bfa; }

/* Card clicável com elevação no hover */
.card-hover:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
}

/* Card de destaque / selecionado */
.card-selected {
  border-color: #0284c7;
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.12);
}


/* ------------------------------------------------------------
   MODAL — entrada e saída
   ------------------------------------------------------------ */

.modal-enter {
  animation: scaleIn 0.2s ease-out both;
}

.modal-backdrop-enter {
  animation: fadeIn 0.2s ease-out both;
}


/* ------------------------------------------------------------
   BADGES — dot pulsante para status crítico
   ------------------------------------------------------------ */

.badge-pulse::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  margin-right: 5px;
  animation: pulse-soft 1.5s ease-in-out infinite;
}


/* ------------------------------------------------------------
   NOTIFICAÇÕES / TOAST (posicionamento)
   ------------------------------------------------------------ */

.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9998;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 360px;
  width: calc(100vw - 2rem);
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border-radius: 0.75rem;
  border: 1px solid transparent;
  background: white;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  animation: slideUp 0.25s ease-out both;
  font-size: 0.875rem;
}

.toast-success { border-color: #a7f3d0; background: #f0fdf4; color: #065f46; }
.toast-error   { border-color: #fecaca; background: #fef2f2; color: #7f1d1d; }
.toast-warning { border-color: #fde68a; background: #fffbeb; color: #78350f; }
.toast-info    { border-color: #bae6fd; background: #f0f9ff; color: #0c4a6e; }


/* ------------------------------------------------------------
   IMPRESSÃO — holerites e relatórios
   ------------------------------------------------------------ */

@media print {
  /* Ocultar elementos de navegação e interação */
  aside,
  header,
  .no-print,
  .btn,
  .page-actions,
  nav {
    display: none !important;
  }

  /* Resetar layout para impressão */
  body {
    background: white !important;
    color: #0f172a !important;
    font-size: 11pt;
    line-height: 1.5;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  main {
    padding: 0 !important;
  }

  .print-only {
    display: block !important;
  }

  /* Cards sem sombra */
  .card {
    border: 1px solid #e2e8f0 !important;
    box-shadow: none !important;
    break-inside: avoid;
  }

  /* Tabelas */
  table { break-inside: auto; }
  tr    { break-inside: avoid; page-break-inside: avoid; }
  thead { display: table-header-group; }
  tfoot { display: table-footer-group; }

  /* Utilitários de quebra de página */
  .page-break-before { page-break-before: always; }
  .page-break-after  { page-break-after: always; }

  /* Links */
  a { text-decoration: none !important; color: inherit !important; }
}

/* Ocultar elementos apenas para impressão na tela */
.print-only {
  display: none;
}


/* ------------------------------------------------------------
   MOBILE — ajustes específicos
   ------------------------------------------------------------ */

@media (max-width: 640px) {
  /* Botões ocupam largura total em mobile quando necessário */
  .btn-mobile-full {
    width: 100%;
    justify-content: center;
  }

  /* Modal em mobile ocupa a tela toda na parte inferior */
  .modal {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    max-height: 90vh;
    overflow-y: auto;
  }

  /* Tabelas com scroll horizontal em mobile */
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Fontes ligeiramente menores em mobile para densidade */
  .table th,
  .table td {
    font-size: 0.8125rem;
    padding-left: 0.875rem;
    padding-right: 0.875rem;
  }

  /* Toast ocupa quase toda a largura */
  .toast-container {
    left: 1rem;
    right: 1rem;
    max-width: 100%;
    width: auto;
  }
}


/* ------------------------------------------------------------
   ACESSIBILIDADE
   ------------------------------------------------------------ */

/* Modo de alto contraste (Windows / preferência do SO) */
@media (prefers-contrast: high) {
  .card       { border-color: #64748b; }
  .input-field { border-color: #1e293b; }
  .btn-primary { background: #0369a1; }
}

/* Respeitar preferência de movimento reduzido */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Navegação por teclado — foco visível garantido */
:focus-visible {
  outline: 2px solid #0284c7;
  outline-offset: 2px;
}

/* Remover outline apenas quando mouse é usado */
:focus:not(:focus-visible) {
  outline: none;
}


/* ------------------------------------------------------------
   UTILITÁRIOS VISUAIS EXTRAS
   ------------------------------------------------------------ */

/* Truncar texto com tooltip nativo */
.truncate-tooltip {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: default;
}

/* Número monetário — alinhamento e fonte */
.money {
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  font-weight: 600;
}

.money-positive { color: #059669; }
.money-negative { color: #dc2626; }
.money-neutral  { color: #475569; }

/* Separador com texto no meio */
.divider-text {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: #94a3b8;
  font-size: 0.75rem;
}

.divider-text::before,
.divider-text::after {
  content: '';
  flex: 1;
  border-top: 1px solid #e2e8f0;
}

/* Indicador de campo obrigatório */
.required::after {
  content: ' *';
  color: #ef4444;
  font-weight: 600;
}

/* Código inline */
code {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.8125rem;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 0.25rem;
  padding: 0.125rem 0.375rem;
  color: #0f172a;
}