/* assets/css/components.css */
/* ============================================================
   components.css — Botões, Cards, Badges, Modais, Formulários
   ============================================================ */

/* ===== BOTÕES ===== */

.btn {
  font-weight: 600;
  border-radius: 0.5rem;
  padding: 0.5rem 1rem;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border: none;
  cursor: pointer;
}

.btn:focus {
  box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

/* Botão Primary */
.btn-primary {
  background: linear-gradient(135deg, #0b3534 0%, #159a49 100%);
  color: white;
  border: none;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(11, 53, 52, 0.3);
  color: white;
}

.btn-primary:active {
  transform: translateY(0);
}

/* Botão Soft (Background suave) */
.btn-soft-primary {
  color: var(--bs-primary) !important;
  background: rgba(13, 110, 253, 0.12);
  border: 1px solid rgba(13, 110, 253, 0.25);
  font-weight: 500;
}

.btn-soft-primary:hover {
  background: rgba(13, 110, 253, 0.2);
  border-color: rgba(13, 110, 253, 0.35);
  color: var(--bs-primary) !important;
}

.btn-soft-success {
  color: #198754 !important;
  background: rgba(25, 135, 84, 0.12);
  border: 1px solid rgba(25, 135, 84, 0.25);
}

.btn-soft-success:hover {
  background: rgba(25, 135, 84, 0.2);
  border-color: rgba(25, 135, 84, 0.35);
}

.btn-soft-warning {
  color: #212529 !important;
  background: rgba(255, 193, 7, 0.25);
  border: 1px solid rgba(255, 193, 7, 0.35);
  font-weight: 500;
}

.btn-soft-danger {
  color: #212529 !important;
  background: rgba(220, 53, 69, 0.25);
  border: 1px solid rgba(220, 53, 69, 0.35);
  font-weight: 500;
}

/* Botão Ghost (Transparente) */
.btn-ghost {
  background: transparent;
  color: var(--text-color);
  border: none;
  font-weight: 500;
}

.btn-ghost:hover {
  background: var(--bg-page);
  color: var(--bs-primary);
}

/* Botão Pequeno */
.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.875rem;
}

.btn-min {
  padding: 0.35rem 0.75rem;
  font-size: 0.875rem;
}

/* ===== CARDS ===== */

.card {
  background: var(--card-bg);
  border: 1px solid var(--divider);
  border-radius: 0.75rem;
  overflow: hidden;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.card-header {
  background: transparent;
  border-bottom: 1px solid var(--divider);
  padding: 1rem;
}

.card-header-soft {
  background: transparent;
  border-bottom: 1px solid var(--divider);
}

.card-body {
  padding: 1rem;
}

.card-title {
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--text-color);
}

.card-text {
  color: var(--muted-color);
  font-size: 0.9rem;
}

.card-hover {
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

.card-hover:hover {
  border-left: 4px solid var(--cro-green) !important;
  transform: translateY(-2px);
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

/* ===== BADGES ===== */

.badge {
  font-weight: 600;
  padding: 0.35rem 0.65rem;
  border-radius: 0.35rem;
  font-size: 0.8rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.badge-primary {
  background: rgba(13, 110, 253, 0.15);
  color: var(--bs-primary);
  border: 1px solid rgba(13, 110, 253, 0.25);
}

.badge-success {
  background: rgba(25, 135, 84, 0.15);
  color: #198754;
  border: 1px solid rgba(25, 135, 84, 0.25);
}

.badge-warning {
  background: rgba(255, 193, 7, 0.2);
  color: #664d03;
  border: 1px solid rgba(255, 193, 7, 0.4);
}

.badge-danger {
  background: rgba(220, 53, 69, 0.15);
  color: #dc3545;
  border: 1px solid rgba(220, 53, 69, 0.25);
}

.badge-info {
  background: rgba(13, 202, 240, 0.15);
  color: #0dcaf0;
  border: 1px solid rgba(13, 202, 240, 0.25);
}

/* ===== MODAIS ===== */

.modal-content {
  background: var(--card-bg);
  border: 1px solid var(--divider);
  border-radius: 0.75rem;
}

.modal-header {
  background: transparent;
  border-bottom: 1px solid var(--divider);
  padding: 1.5rem;
}

/* Header CRO — substitui bg-primary nos modais de CRUD */
.modal-header-cro {
  background: linear-gradient(135deg, var(--color-floresta) 0%, var(--color-esmeralda) 100%);
  border-bottom: none;
  padding: 1.25rem 1.5rem;
}

.modal-body {
  padding: 1.5rem;
  color: var(--text-color);
}

.modal-footer {
  background: transparent;
  border-top: 1px solid var(--divider);
  padding: 1rem;
}

/* Footer de modal que se adapta ao tema (substitui bg-light hardcoded) */
.modal-footer-cro {
  background: var(--bg-page);
  border-top: 1px solid var(--divider);
  padding: 1rem 1.5rem;
}

.modal-title {
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--text-color);
}

.btn-close {
  filter: invert(0);
}

/* ===== FLOATING LABELS ===== */

/* Adapta o .form-floating ao tema */
.form-floating > .form-control,
.form-floating > .form-select {
  background: var(--card-bg);
  border-color: var(--divider);
  color: var(--text-color);
}

.form-floating > .form-control:focus,
.form-floating > .form-select:focus {
  border-color: var(--color-esmeralda);
  box-shadow: 0 0 0 0.2rem rgba(21, 154, 73, 0.15);
  background: var(--card-bg);
  color: var(--text-color);
}

.form-floating > label {
  color: var(--muted-color);
  font-size: 0.9rem;
}

.form-floating > .form-control:focus ~ label,
.form-floating > .form-control:not(:placeholder-shown) ~ label,
.form-floating > .form-select ~ label {
  color: var(--color-esmeralda);
  font-weight: 500;
}

/* ===== FORMULÁRIOS ===== */

.form-label {
  font-weight: 500;
  color: var(--text-color);
  margin-bottom: 0.5rem;
}

.form-control,
.form-select {
  background: var(--card-bg);
  border: 1px solid var(--divider);
  color: var(--text-color);
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.95rem;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.form-control:focus,
.form-select:focus {
  background: var(--card-bg);
  border-color: var(--bs-primary);
  color: var(--text-color);
  box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.15);
}

.form-control::placeholder {
  color: var(--muted-color);
}

.form-check-input {
  border: 1px solid var(--divider);
  background: var(--card-bg);
  cursor: pointer;
}

.form-check-input:checked {
  background: var(--bs-primary);
  border-color: var(--bs-primary);
}

.form-check-input:focus {
  border-color: var(--bs-primary);
  box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.15);
}

.form-check-label {
  cursor: pointer;
  color: var(--text-color);
}

/* ===== AUTENTICACAO ===== */

.auth-wrapper {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0b3534 0%, #159a49 50%, #0d3b2e 100%);
  padding: 1rem;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--card-bg);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  animation: authSlideUp 0.5s ease-out;
}

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

.auth-header {
  text-align: center;
  padding: 2.5rem 2rem 1.5rem;
}

.auth-logo {
  width: 100px;
  height: 100px;
  margin: 0 auto 1.25rem;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 12px;
}

.auth-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.auth-header h2 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-color);
}

.auth-header p {
  margin: 0.35rem 0 0;
  color: var(--muted-color);
  font-size: 0.9rem;
}

.auth-body {
  padding: 0 2rem 2rem;
}

.auth-body .form-label {
  font-weight: 500;
  color: var(--text-color);
  margin-bottom: 0.4rem;
  font-size: 0.875rem;
}

.auth-body .form-control {
  border: 1.5px solid var(--divider);
  border-radius: 10px;
  padding: 0.7rem 1rem;
  font-size: 0.95rem;
  background: var(--card-bg);
  color: var(--text-color);
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}

.auth-body .form-control:focus {
  border-color: #159a49;
  box-shadow: 0 0 0 0.2rem rgba(21, 154, 73, 0.15);
}

.auth-body .input-group .form-control {
  border-right: none;
}

.auth-body .input-group .btn-toggle-pw {
  border: 1.5px solid var(--divider);
  border-left: none;
  background: var(--card-bg);
  color: var(--muted-color);
  border-radius: 0 10px 10px 0;
  transition: color 0.15s;
}

.auth-body .input-group .btn-toggle-pw:hover {
  color: var(--text-color);
}

.auth-body .form-check-input:checked {
  background-color: #159a49;
  border-color: #159a49;
}

.btn-auth {
  background: linear-gradient(135deg, #0b3534 0%, #159a49 100%);
  border: none;
  color: #fff;
  font-weight: 600;
  padding: 0.8rem 1.5rem;
  border-radius: 10px;
  font-size: 1rem;
  transition:
    transform 0.2s,
    box-shadow 0.2s,
    opacity 0.2s;
}

.btn-auth:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(11, 53, 52, 0.35);
  color: #fff;
}

.btn-auth:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.btn-auth-outline {
  background: transparent;
  border: 1.5px solid var(--divider);
  color: var(--text-color);
  font-weight: 600;
  padding: 0.8rem 1.5rem;
  border-radius: 10px;
  font-size: 1rem;
  transition: all 0.2s;
}

.btn-auth-outline:hover {
  background: var(--divider);
  color: var(--text-color);
}

.auth-footer {
  text-align: center;
  padding: 1.25rem 2rem;
  border-top: 1px solid var(--divider);
}

.auth-footer a {
  color: #159a49;
  text-decoration: none;
  font-weight: 500;
}

.auth-footer a:hover {
  text-decoration: underline;
}

.auth-link-forgot a {
  font-size: 0.85rem;
  color: var(--muted-color);
  text-decoration: none;
}

.auth-link-forgot a:hover {
  color: #159a49;
}

.auth-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1050;
  padding: 1rem;
}

.auth-overlay .auth-card,
.auth-overlay-login .auth-card {
  animation: authModalPop 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes authModalPop {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.auth-overlay-login {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1050;
  padding: 1rem;
  /* Gradiente CRO com dot-pattern sobreposto para textura */
  background-color: var(--color-floresta);
  background-image:
    radial-gradient(rgba(255, 255, 255, 0.07) 1px, transparent 1px),
    linear-gradient(135deg, #0b3534 0%, #159a49 55%, #0d3b2e 100%);
  background-size: 22px 22px, 100% 100%;
}

@media (max-width: 576px) {
  .auth-card {
    border-radius: 12px;
  }
  .auth-header {
    padding: 2rem 1.5rem 1rem;
  }
  .auth-body {
    padding: 0 1.5rem 1.5rem;
  }
  .auth-footer {
    padding: 1rem 1.5rem;
  }
}

/* ===== ALERTAS ===== */

.alert {
  border: 1px solid var(--divider);
  border-radius: 0.75rem;
  padding: 1rem;
}

.alert-primary {
  background: rgba(13, 110, 253, 0.1);
  border-color: rgba(13, 110, 253, 0.2);
  color: var(--bs-primary);
}

.alert-success {
  background: rgba(25, 135, 84, 0.1);
  border-color: rgba(25, 135, 84, 0.2);
  color: #198754;
}

.alert-warning {
  background: rgba(255, 193, 7, 0.15);
  border-color: rgba(255, 193, 7, 0.3);
  color: #664d03;
}

.alert-danger {
  background: rgba(220, 53, 69, 0.1);
  border-color: rgba(220, 53, 69, 0.2);
  color: #dc3545;
}

/* ===== TOASTS ===== */

/* Container — fixo no canto superior direito, abaixo da navbar */
#toast-container {
  position: fixed;
  top: calc(var(--navbar-h, 56px) + 12px);
  right: 16px;
  width: min(360px, calc(100% - 32px));
  display: flex;
  flex-direction: column;
  pointer-events: none;
  z-index: 1100; /* acima de modais (1055) e navbar (1030) */
}

/*
  Acentos — modo claro: cores saturadas, legíveis sobre fundo claro.
  O dark mode sobrescreve para versões mais brilhantes em theme.css.
*/
#toast-container .toast--success { --accent: #16a34a; }
#toast-container .toast--error   { --accent: #dc2626; }
#toast-container .toast--warning { --accent: #d97706; }
#toast-container .toast--info    { --accent: #2563eb; }

/* Card — fundo do card do tema + tint sutil da cor do tipo */
#toast-container .toast {
  pointer-events: all;
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px 13px 15px;
  background: color-mix(in srgb, var(--card-bg) 92%, var(--accent, #6c757d) 8%);
  border: 1px solid color-mix(in srgb, var(--accent, #6c757d) 18%, var(--divider) 82%);
  border-left: 3px solid var(--accent, #6c757d);
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1), 0 1px 6px rgba(0, 0, 0, 0.06);
  overflow: hidden;
  margin-bottom: 10px;
  width: 100%;
  max-width: 100%;
  /* Estado inicial — fora da tela, ligeiramente reduzido */
  transform: translateX(100%) scale(0.95);
  opacity: 0;
  will-change: transform, opacity;
  /* Reset de variáveis Bootstrap que afetam background/borda */
  --bs-toast-bg: transparent;
  --bs-toast-border-color: transparent;
}

/* Estado visível — entrada com spring */
#toast-container .toast.toast--in {
  transition:
    transform 350ms cubic-bezier(0.21, 1.02, 0.73, 1),
    opacity   260ms ease;
  transform: translateX(0) scale(1);
  opacity: 1;
}

/* Ícone */
.toast__icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  color: var(--accent);
  margin-top: 1px;
}
.toast__icon svg { display: block; width: 18px; height: 18px; }

/* Conteúdo de texto — segue as variáveis semânticas do tema */
.toast__body { flex: 1; min-width: 0; }

.toast__title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-color);
  line-height: 1.35;
}

.toast__msg {
  font-size: 12px;
  color: var(--muted-color);
  line-height: 1.48;
  margin-top: 3px;
}

/* Botão fechar */
.toast__close {
  all: unset;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  color: var(--muted-color);
  transition: color 130ms, background 130ms;
  margin-top: -1px;
  margin-right: -1px;
}
.toast__close:hover {
  color: var(--text-color);
  background: var(--divider);
}
.toast__close svg { display: block; width: 12px; height: 12px; }

/* Barra de progresso */
.toast__bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
}
.toast__bar-fill {
  height: 100%;
  width: 100%;
  background: var(--accent);
}

/* Reduced motion — pula animações */
@media (prefers-reduced-motion: reduce) {
  #toast-container .toast,
  #toast-container .toast.toast--in {
    transform: none !important;
    opacity: 1 !important;
    transition: none !important;
  }
}

/* ===== TABELAS ===== */

.table {
  --bs-table-border-color: var(--divider);
  --bs-table-striped-bg: rgba(255, 255, 255, 0.04);
  color: var(--text-color);
}

.table th,
.table td {
  vertical-align: middle;
  padding: 0.75rem;
  border-color: var(--divider);
}

.table-head th {
  background: var(--bg-page);
  border-bottom: 1px solid var(--divider);
  color: var(--text-color);
  font-weight: 600;
}

/* ===== ÍCONES ===== */

.icon-xl {
  font-size: 2.25rem;
  line-height: 1;
}

.icon-lg {
  font-size: 1.75rem;
  line-height: 1;
}

.icon-md {
  font-size: 1.5rem;
  line-height: 1;
}

.icon-sm {
  font-size: 1.25rem;
  line-height: 1;
}

/* ===== AVATAR ===== */

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bs-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.user-avatar.lg {
  width: 48px;
  height: 48px;
  font-size: 1rem;
}

/* ===== RESPONSIVIDADE ===== */

@media (max-width: 768px) {
  .btn {
    padding: 0.4rem 0.8rem;
    font-size: 0.9rem;
  }

  .btn-sm {
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
  }

  .card {
    margin-bottom: 1rem;
  }

  .modal-header,
  .modal-body,
  .modal-footer {
    padding: 1rem;
  }
}
