/*
 * Janelas da plataforma no visual novo: SweetAlert2 (avisos e confirmações),
 * modais do Bootstrap/Metronic e o painel lateral de perfil.
 * Mesmo desenho dos diálogos .app-dialog das listas: ícone pequeno à esquerda,
 * título e texto alinhados à esquerda, ações à direita separadas por uma linha.
 * Autossuficiente (valores de reserva nos var()) porque também é carregado nas
 * telas públicas (login, redefinir senha), que não carregam app-layout.css.
 */

/* ---------- Fundo escurecido (todas as janelas) ---------- */

.swal2-container.swal2-backdrop-show,
.swal2-container.swal2-noanimation {
  background: rgba(15, 23, 42, .45) !important;
}

.modal-backdrop.show {
  background: #0F172A;
  opacity: .45;
}

/* ---------- SweetAlert2 ---------- */

.swal2-popup {
  width: min(440px, calc(100vw - 32px)) !important;
  padding: 24px 24px 0 !important;
  border-radius: 12px !important;
  box-shadow: 0 24px 60px rgba(15, 23, 42, .25) !important;
  color: var(--app-text, #0F172A);
  font-family: inherit !important;
  text-align: left !important;
}

.swal2-popup .swal2-header {
  align-items: flex-start !important;
  padding: 0 !important;
}

/* Ícone: 40px (a biblioteca dimensiona tudo em em a partir do font-size) */
.swal2-popup .swal2-icon {
  margin: 0 0 12px !important;
  font-size: 8px !important;
  border-width: .3em !important;
}

.swal2-popup .swal2-icon .swal2-icon-content {
  font-size: 4em !important;
  font-weight: 700;
}

.swal2-popup .swal2-icon.swal2-success {
  border-color: #A7F3D0 !important;
  color: #16A34A !important;
}

.swal2-popup .swal2-icon.swal2-success [class^="swal2-success-line"] {
  background-color: #16A34A !important;
}

.swal2-popup .swal2-icon.swal2-success .swal2-success-ring {
  border-color: rgba(22, 163, 74, .25) !important;
}

.swal2-popup .swal2-icon.swal2-success [class^="swal2-success-circular-line"],
.swal2-popup .swal2-icon.swal2-success .swal2-success-fix {
  background-color: transparent !important;
}

.swal2-popup .swal2-icon.swal2-error {
  border-color: #FECACA !important;
  color: #DC2626 !important;
}

.swal2-popup .swal2-icon.swal2-error [class^="swal2-x-mark-line"] {
  background-color: #DC2626 !important;
}

.swal2-popup .swal2-icon.swal2-warning {
  border-color: #FDE68A !important;
  color: #D97706 !important;
}

.swal2-popup .swal2-icon.swal2-info {
  border-color: color-mix(in srgb, var(--brand-primary, #0144E4) 30%, #fff) !important;
  color: var(--brand-text, #0144E4) !important;
}

.swal2-popup .swal2-icon.swal2-question {
  border-color: #CBD5E1 !important;
  color: #475569 !important;
}

.swal2-popup .swal2-title {
  margin: 0 0 6px !important;
  padding: 0 !important;
  color: var(--app-text, #0F172A) !important;
  font-size: 16px !important;
  font-weight: 600 !important;
  line-height: 1.35 !important;
  text-align: left !important;
}

.swal2-popup .swal2-content,
.swal2-popup .swal2-html-container {
  margin: 0 !important;
  padding: 0 !important;
  color: #334155 !important;
  font-size: 14px !important;
  font-weight: 400 !important;
  line-height: 1.5 !important;
  text-align: left !important;
}

.swal2-popup .swal2-actions {
  width: auto !important;
  justify-content: flex-end !important;
  gap: 8px;
  margin: 20px -24px 0 !important;
  padding: 16px 24px !important;
  border-top: 1px solid var(--app-border-soft, #F1F5F9);
}

.swal2-popup .swal2-styled {
  margin: 0 !important;
  padding: 9px 16px !important;
  border-radius: 8px !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  line-height: 1.2 !important;
  box-shadow: none !important;
}

.swal2-popup .swal2-styled:focus {
  box-shadow: 0 0 0 3px var(--brand-primary-light, rgba(1, 68, 228, .12)) !important;
}

/* Confirmar à direita, cancelar antes dele */
.swal2-popup .swal2-cancel { order: 1; }
.swal2-popup .swal2-deny { order: 2; }
.swal2-popup .swal2-confirm { order: 3; }

.swal2-popup .swal2-styled.swal2-confirm {
  border: 1px solid var(--brand-primary, #0144E4) !important;
  background: var(--brand-primary, #0144E4) !important;
  color: var(--brand-on-primary, #fff) !important;
}

.swal2-popup .swal2-styled.swal2-confirm:hover {
  border-color: var(--brand-primary-hover, #0136b6) !important;
  background: var(--brand-primary-hover, #0136b6) !important;
}

/* Confirmação destrutiva (customClass: { confirmButton: 'app-swal-danger' }) */
.swal2-popup .swal2-styled.swal2-confirm.app-swal-danger {
  border-color: #DC2626 !important;
  background: #DC2626 !important;
  color: #fff !important;
}

.swal2-popup .swal2-styled.swal2-confirm.app-swal-danger:hover {
  border-color: #B91C1C !important;
  background: #B91C1C !important;
}

.swal2-popup .swal2-styled.swal2-cancel,
.swal2-popup .swal2-styled.swal2-deny {
  border: 1px solid var(--app-border, #E2E8F0) !important;
  background: #fff !important;
  color: #334155 !important;
}

.swal2-popup .swal2-styled.swal2-cancel:hover,
.swal2-popup .swal2-styled.swal2-deny:hover {
  border-color: #CBD5E1 !important;
  background: #F8FAFC !important;
}

/* Janela só com o aviso (sem botões, ex.: timer): sem a faixa de ações vazia */
.swal2-popup .swal2-actions:not(:has(.swal2-styled:not([style*="display: none"]))) {
  display: none !important;
}

.swal2-popup:has(.swal2-actions[style*="display: none"]) {
  padding-bottom: 24px !important;
}

.swal2-popup .swal2-close {
  top: 12px !important;
  right: 12px !important;
  width: 32px !important;
  height: 32px !important;
  border-radius: 8px;
  color: #94A3B8 !important;
  font-size: 24px !important;
}

.swal2-popup .swal2-close:hover {
  background: #F1F5F9;
  color: #0F172A !important;
}

.swal2-popup .swal2-input,
.swal2-popup .swal2-textarea,
.swal2-popup .swal2-select {
  width: 100%;
  margin: 12px 0 0 !important;
  border: 1px solid var(--app-border, #E2E8F0) !important;
  border-radius: 8px !important;
  box-shadow: none !important;
  font-size: 14px !important;
}

.swal2-popup .swal2-input:focus,
.swal2-popup .swal2-textarea:focus {
  border-color: var(--brand-primary, #0144E4) !important;
  box-shadow: 0 0 0 3px var(--brand-primary-light, rgba(1, 68, 228, .12)) !important;
}

.swal2-popup .swal2-validation-message {
  margin: 12px 0 0 !important;
  border-radius: 8px;
  background: #FEF2F2 !important;
  color: #B91C1C !important;
  font-size: 13px !important;
  justify-content: flex-start !important;
}

.swal2-popup .swal2-timer-progress-bar {
  background: var(--brand-primary, #0144E4) !important;
  opacity: .5;
}

/* ---------- Modais do Bootstrap/Metronic ---------- */

.modal .modal-dialog {
  margin-right: auto;
  margin-left: auto;
  padding: 0 16px;
}

.modal .modal-content {
  overflow: hidden;
  border: 0 !important;
  border-radius: 12px !important;
  box-shadow: 0 24px 60px rgba(15, 23, 42, .25) !important;
}

.modal .modal-header {
  align-items: center;
  padding: 20px 24px !important;
  border-bottom: 1px solid var(--app-border-soft, #F1F5F9) !important;
}

.modal .modal-title {
  color: var(--app-text, #0F172A) !important;
  font-size: 16px !important;
  font-weight: 600 !important;
}

.modal .modal-header .close {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  margin: -6px -8px -6px auto !important;
  padding: 0 !important;
  border-radius: 8px;
  color: #94A3B8;
  opacity: 1;
  text-shadow: none;
}

.modal .modal-header .close:hover {
  background: #F1F5F9;
  color: #0F172A;
}

.modal .modal-header .close i,
.modal .modal-header .close span {
  font-size: 14px !important;
  color: inherit !important;
}

.modal .modal-body {
  padding: 24px !important;
  color: #334155;
  font-size: 14px;
}

/* Textos auxiliares dentro de modais seguem a escala (12px), como nas telas */
.modal small,
.modal .small,
.modal .form-text {
  font-size: 12px !important;
}

.modal .modal-footer {
  gap: 8px;
  padding: 16px 24px !important;
  border-top: 1px solid var(--app-border-soft, #F1F5F9) !important;
}

.modal .modal-footer > * {
  margin: 0 !important;
}

/* Botões dentro das janelas seguem os botões novos */
.modal .modal-footer .btn {
  padding: 9px 16px !important;
  border-radius: 8px !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  box-shadow: none !important;
}

.modal .modal-footer .btn-default,
.modal .modal-footer .btn-secondary,
.modal .modal-footer .btn-light,
.modal .modal-footer .btn-light-primary,
.modal .modal-footer .btn-mapfre-reverse,
.modal .modal-footer [data-dismiss="modal"]:not(.btn-primary):not(.btn-mapfre):not(.btn-danger) {
  border: 1px solid var(--app-border, #E2E8F0) !important;
  background: #fff !important;
  color: #334155 !important;
}

.modal .modal-footer .btn-default:hover,
.modal .modal-footer .btn-secondary:hover,
.modal .modal-footer .btn-light:hover,
.modal .modal-footer [data-dismiss="modal"]:not(.btn-primary):not(.btn-mapfre):not(.btn-danger):hover {
  background: #F8FAFC !important;
  color: #0F172A !important;
}

.modal .modal-footer .btn-primary,
.modal .modal-footer .btn-mapfre {
  border: 1px solid var(--brand-primary, #0144E4) !important;
  background: var(--brand-primary, #0144E4) !important;
  color: var(--brand-on-primary, #fff) !important;
}

.modal .modal-footer .btn-primary:hover,
.modal .modal-footer .btn-mapfre:hover {
  border-color: var(--brand-primary-hover, #0136b6) !important;
  background: var(--brand-primary-hover, #0136b6) !important;
}

.modal .modal-footer .btn-danger,
.modal .modal-footer .btn-mapfre-black.btn-excluir,
.modal .modal-footer .btn-hover-danger {
  border: 1px solid #DC2626 !important;
  background: #DC2626 !important;
  color: #fff !important;
}

/* ---------- Painel lateral de perfil (includes/quickUser.php) ---------- */

.offcanvas-overlay {
  background: rgba(15, 23, 42, .45) !important;
}

.offcanvas.app-profile-panel {
  width: min(360px, 100vw) !important;
  padding: 0 !important;
  box-shadow: -12px 0 40px rgba(15, 23, 42, .15) !important;
}

.app-profile-panel .offcanvas-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px !important;
  border-bottom: 1px solid var(--app-border-soft, #F1F5F9);
}

.app-profile-panel__title {
  margin: 0;
  color: var(--app-text, #0F172A);
  font-size: 16px !important;
  font-weight: 600;
}

.app-profile-panel__close {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: none;
  color: #94A3B8;
  cursor: pointer;
}

.app-profile-panel__close:hover {
  background: #F1F5F9;
  color: #0F172A;
}

.app-profile-panel .offcanvas-content {
  padding: 20px !important;
}

.app-profile-panel__who {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--app-border-soft, #F1F5F9);
}

.app-profile-panel__avatar {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #0F172A;
  color: #fff;
  font-size: 16px;
  font-weight: 600;
}

.app-profile-panel__name {
  display: block;
  color: var(--app-text, #0F172A);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
}

.app-profile-panel__meta {
  display: block;
  color: #64748B;
  font-size: 12px;
}

.app-profile-panel__nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 12px -8px;
}

.app-profile-panel__nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 8px;
  border-radius: 8px;
  color: var(--app-text, #0F172A);
  text-decoration: none;
}

.app-profile-panel__nav a:hover {
  background: #F1F5F9;
  text-decoration: none;
}

.app-profile-panel__icon {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border: 1px solid var(--app-border, #E2E8F0);
  border-radius: 8px;
  background: #fff;
  color: #475569;
  font-size: 14px;
}

.app-profile-panel__icon i {
  color: inherit !important;
  font-size: 14px !important;
  padding: 0 !important;
}

.app-profile-panel__nav strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
}

.app-profile-panel__nav small {
  display: block;
  color: #64748B;
  font-size: 12px;
}

.app-profile-panel__logout {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
  padding: 9px 16px;
  border: 1px solid var(--app-border, #E2E8F0);
  border-radius: 8px;
  background: #fff;
  color: #334155;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
}

.app-profile-panel__logout:hover {
  border-color: #FECACA;
  background: #FEF2F2;
  color: #B91C1C;
  text-decoration: none;
}

@media (prefers-reduced-motion: reduce) {
  .swal2-popup,
  .modal.fade .modal-dialog {
    animation: none !important;
    transition: none !important;
  }
}

/* ---------- Avisos dentro de janelas e telas (alert-custom do Metronic) ---------- */

.alert.alert-custom {
  align-items: flex-start;
  padding: 12px 16px !important;
  border: 1px solid;
  border-radius: 8px !important;
  font-size: 13px;
}

.alert.alert-custom .alert-icon {
  padding: 2px 12px 0 0 !important;
}

.alert.alert-custom .alert-icon i {
  color: inherit !important;
  font-size: 18px !important;
}

.alert.alert-custom .alert-text,
.alert.alert-custom .alert-text * {
  color: inherit;
}

.alert.alert-custom .alert-text h3 {
  font-size: 14px !important;
  font-weight: 600;
}

.alert.alert-custom .alert-close .close,
.alert.alert-custom .alert-close i {
  color: inherit !important;
  opacity: .6;
}

.alert.alert-custom.alert-outline-warning {
  border-color: #FDE68A !important;
  background: #FFFBEB !important;
  color: #92400E !important;
}

.alert.alert-custom.alert-outline-primary,
.alert.alert-custom.alert-mapfre {
  border-color: color-mix(in srgb, var(--brand-primary, #0144E4) 25%, #fff) !important;
  background: var(--brand-primary-light, #EEF3FE) !important;
  color: #1E293B !important;
}

.alert.alert-custom.alert-outline-primary .alert-icon i,
.alert.alert-custom.alert-mapfre .alert-icon i {
  color: var(--brand-text, #0144E4) !important;
}

/* ---------- Dicas (tooltips) do Bootstrap/Metronic: mesmo balão das dicas novas ---------- */

.tooltip .tooltip-inner {
  max-width: 240px;
  padding: 6px 8px;
  border-radius: 6px;
  background: #0F172A;
  color: #fff;
  font-size: 12px !important;
  font-weight: 400;
  line-height: 1.4;
  text-align: left;
}

.tooltip.bs-tooltip-top .arrow::before,
.tooltip.bs-tooltip-auto[x-placement^="top"] .arrow::before {
  border-top-color: #0F172A;
}

.tooltip.bs-tooltip-bottom .arrow::before,
.tooltip.bs-tooltip-auto[x-placement^="bottom"] .arrow::before {
  border-bottom-color: #0F172A;
}

.tooltip.bs-tooltip-right .arrow::before,
.tooltip.bs-tooltip-auto[x-placement^="right"] .arrow::before {
  border-right-color: #0F172A;
}

.tooltip.bs-tooltip-left .arrow::before,
.tooltip.bs-tooltip-auto[x-placement^="left"] .arrow::before {
  border-left-color: #0F172A;
}
