/* ═════════════════════════════════════════════════════════════════════════
   ModalForm · Componente padrão Solution Makers
   Substitui os "popups pretos" por modais com formulário, header e footer.
   Para incluir em qualquer HTML:
     <link rel="stylesheet" href="/components/modal-form.css">
     <script src="/components/modal-form.js"></script>
   ═════════════════════════════════════════════════════════════════════════ */

.smk-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9000;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: smk-fade-in .12s ease-out;
}
.smk-modal-overlay.smk-open { display: flex; }
@keyframes smk-fade-in { from { opacity: 0 } to { opacity: 1 } }

.smk-modal-card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
  width: 96%;
  max-width: 720px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: smk-slide-up .15s ease-out;
}
@keyframes smk-slide-up { from { transform: translateY(8px); opacity: .85 } to { transform: translateY(0); opacity: 1 } }

.smk-modal-card.smk-size-sm { max-width: 480px; }
.smk-modal-card.smk-size-md { max-width: 720px; }
.smk-modal-card.smk-size-lg { max-width: 980px; }
.smk-modal-card.smk-size-xl { max-width: 1180px; }

/* ─────── HEADER ─────── */
.smk-modal-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 22px;
  border-bottom: 1px solid #e2e8f0;
  flex-shrink: 0;
}
.smk-modal-header .smk-modal-icon {
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
}
/* Wrapper do título ocupa todo espaço disponível, empurrando o X para o canto direito */
.smk-modal-header .smk-modal-title-wrap {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.smk-modal-header .smk-modal-title {
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: -.2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.smk-modal-header .smk-modal-subtitle {
  font-size: 12px;
  font-weight: 400;
  color: #64748b;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.smk-modal-header .smk-modal-close {
  flex-shrink: 0;
  margin-left: auto;
}
.smk-modal-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 20px;
  color: #94a3b8;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .12s;
}
.smk-modal-close:hover { background: #f1f5f9; color: #1e293b; }

/* ─────── BODY (formulário) ─────── */
.smk-modal-body {
  padding: 18px 22px;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  min-height: 0;
  font-size: 13px;
  color: #1e293b;
}

/* Campos padrão dentro do body */
.smk-modal-body .smk-field { margin-bottom: 14px; }
.smk-modal-body .smk-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}
.smk-modal-body .smk-field-row.smk-3col { grid-template-columns: repeat(3, 1fr); }
.smk-modal-body .smk-field-row.smk-4col { grid-template-columns: repeat(4, 1fr); }

.smk-modal-body .smk-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: #475569;
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: .3px;
}
.smk-modal-body .smk-label .smk-req { color: #dc2626; margin-left: 2px; }

.smk-modal-body .smk-input,
.smk-modal-body .smk-select,
.smk-modal-body .smk-textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  color: #0f172a;
  transition: border-color .12s, box-shadow .12s;
}
.smk-modal-body .smk-input:focus,
.smk-modal-body .smk-select:focus,
.smk-modal-body .smk-textarea:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
.smk-modal-body .smk-textarea { min-height: 70px; resize: vertical; }
.smk-modal-body .smk-input.smk-error,
.smk-modal-body .smk-select.smk-error,
.smk-modal-body .smk-textarea.smk-error { border-color: #dc2626; }

.smk-modal-body .smk-help {
  font-size: 11px;
  color: #64748b;
  margin-top: 4px;
  line-height: 1.4;
}
.smk-modal-body .smk-error-msg {
  font-size: 11px;
  color: #dc2626;
  margin-top: 4px;
  font-weight: 500;
}

/* Seção dentro do body (separar grupos) */
.smk-modal-body .smk-section {
  margin: 18px 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px dashed #e2e8f0;
}
.smk-modal-body .smk-section:first-child { margin-top: 0; }
.smk-modal-body .smk-section-title {
  font-size: 12px;
  font-weight: 700;
  color: #1e40af;
  text-transform: uppercase;
  letter-spacing: .4px;
  margin-bottom: 10px;
}

/* Banner informativo dentro do modal (opcional) */
.smk-modal-body .smk-banner {
  background: #eff6ff;
  border-left: 3px solid #2563eb;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 12px;
  color: #1e3a8a;
  margin-bottom: 14px;
  line-height: 1.5;
}
.smk-modal-body .smk-banner.smk-warn { background: #fffbeb; border-color: #d97706; color: #78350f; }
.smk-modal-body .smk-banner.smk-error { background: #fef2f2; border-color: #dc2626; color: #7f1d1d; }
.smk-modal-body .smk-banner.smk-success { background: #ecfdf5; border-color: #15803d; color: #14532d; }

/* ─────── FOOTER ─────── */
.smk-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 22px;
  border-top: 1px solid #e2e8f0;
  background: #f8fafc;
  flex-shrink: 0;
  flex-wrap: wrap;
}
.smk-modal-footer .smk-footer-left { margin-right: auto; display: flex; gap: 8px; align-items: center; }

.smk-btn {
  padding: 8px 14px;
  border: 1px solid #cbd5e1;
  background: #fff;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: #334155;
  transition: background .12s, border-color .12s;
  font-family: inherit;
}
.smk-btn:hover { background: #f1f5f9; }
.smk-btn:disabled { opacity: .5; cursor: not-allowed; }

.smk-btn.smk-btn-primary {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}
.smk-btn.smk-btn-primary:hover { background: #1d4ed8; }

.smk-btn.smk-btn-success {
  background: #15803d;
  color: #fff;
  border-color: #15803d;
}
.smk-btn.smk-btn-success:hover { background: #166534; }

.smk-btn.smk-btn-danger {
  background: #dc2626;
  color: #fff;
  border-color: #dc2626;
}
.smk-btn.smk-btn-danger:hover { background: #b91c1c; }

.smk-btn.smk-btn-warn {
  background: #d97706;
  color: #fff;
  border-color: #d97706;
}
.smk-btn.smk-btn-warn:hover { background: #b45309; }

/* Ícone à esquerda do texto do botão */
.smk-btn .smk-btn-icon { margin-right: 4px; }

/* Mobile */
@media (max-width: 640px) {
  .smk-modal-card { width: 100%; max-height: 100vh; border-radius: 0; }
  .smk-modal-body .smk-field-row,
  .smk-modal-body .smk-field-row.smk-3col,
  .smk-modal-body .smk-field-row.smk-4col { grid-template-columns: 1fr; }
}
