/* ============================================================
   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.
   ============================================================ */


/* ------------------------------------------------------------
   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 — indicador de progresso HTMX no topo
   ------------------------------------------------------------ */

#htmx-loading {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  background: linear-gradient(90deg, #0284c7, #38bdf8, #0284c7);
  background-size: 200% 100%;
  animation: shimmer 1s linear infinite;
  z-index: 9999;
  transition: opacity 0.3s;
}

#htmx-loading.hidden {
  opacity: 0;
  pointer-events: none;
}


/* ------------------------------------------------------------
   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;
}

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


/* ------------------------------------------------------------
   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 */
  aside,
  header,
  .no-print,
  .btn,
  .page-actions,
  nav {
    display: none !important;
  }

  /* Resetar layout para impressão */
  body {
    background: white !important;
    color: black !important;
    font-size: 11pt;
    line-height: 1.5;
  }

  main {
    padding: 0 !important;
  }

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

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

  /* Tabelas sem quebra de linha no meio */
  table { break-inside: auto; }
  tr    { break-inside: avoid; page-break-inside: avoid; }
  thead { display: table-header-group; }
  tfoot { display: table-footer-group; }

  /* Cabeçalho do holerite */
  .payslip-header {
    border-bottom: 2px solid #1e293b;
    padding-bottom: 1rem;
    margin-bottom: 1.5rem;
  }

  /* Forçar quebra de página antes de nova seção */
  .page-break-before { page-break-before: always; }
  .page-break-after  { page-break-after: always; }

  /* Remover links sublinhados */
  a { text-decoration: none !important; color: inherit !important; }

  /* Rodapé de impressão */
  .print-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    font-size: 8pt;
    color: #94a3b8;
    text-align: center;
    border-top: 1px solid #e2e8f0;
    padding-top: 0.5rem;
  }
}

/* Ocultar elementos apenas para impressão no ecrã */
.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;
}