/* ══════════════════════════════════════════════════════════════
   ClinicAI — Modal System (padrao unificado)

   Tamanhos: .modal-sm (480px) | .modal-md (640px) | .modal-lg (960px) | .modal-xl (1080px)
   Z-index:  modal 9000 | dialog 9500 | alert 10000
   ══════════════════════════════════════════════════════════════ */

/* Overlay */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  transition: opacity .2s ease;
}
.modal-overlay.open { opacity: 1; }
.modal-overlay.dialog { z-index: 9500; }
.modal-overlay.alert { z-index: 10000; }

/* Container */
.modal-box {
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 24px 80px rgba(0,0,0,.25);
  width: 100%;
  max-height: 96vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: translateY(12px);
  transition: transform .2s ease;
}
.modal-overlay.open .modal-box { transform: translateY(0); }

/* Tamanhos */
.modal-sm .modal-box { max-width: 480px; }
.modal-md .modal-box { max-width: 640px; }
.modal-lg .modal-box { max-width: 960px; }
.modal-xl .modal-box { max-width: 1080px; }

/* Header */
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid #E5E7EB;
  flex-shrink: 0;
}
.modal-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.modal-header-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.modal-title {
  font-size: 15px;
  font-weight: 700;
  color: #111;
  line-height: 1.3;
}
.modal-subtitle {
  font-size: 12px;
  color: #9CA3AF;
  margin-top: 2px;
}

/* Close button */
.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: #9CA3AF;
  border-radius: 8px;
  cursor: pointer;
  transition: background .12s, color .12s;
  flex-shrink: 0;
}
.modal-close:hover { background: #F3F4F6; color: #374151; }
.modal-close svg { width: 18px; height: 18px; }

/* Body */
.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
}

/* Footer */
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 24px;
  border-top: 1px solid #E5E7EB;
  flex-shrink: 0;
}

/* Botoes padrao */
.modal-btn {
  padding: 9px 20px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: opacity .15s, transform .1s;
}
.modal-btn:hover { opacity: .85; }
.modal-btn:active { transform: scale(.97); }

.modal-btn-primary {
  background: linear-gradient(135deg, #7C3AED, #5B21B6);
  color: #fff;
}
.modal-btn-gold {
  background: linear-gradient(135deg, #C9A96E, #D4B978);
  color: #1a1a2e;
}
.modal-btn-success {
  background: #10B981;
  color: #fff;
}
.modal-btn-danger {
  background: #EF4444;
  color: #fff;
}
.modal-btn-secondary {
  background: #F3F4F6;
  color: #374151;
}
.modal-btn-ghost {
  background: transparent;
  color: #6B7280;
  border: 1.5px solid #E5E7EB;
}

/* Grid layout (2 colunas) */
.modal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.modal-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* Section blocks dentro do modal */
.modal-section {
  padding: 14px;
  background: #F9FAFB;
  border: 1px solid #E5E7EB;
  border-radius: 10px;
  margin-bottom: 14px;
}
.modal-section-title {
  font-size: 11px;
  font-weight: 700;
  color: #6B7280;
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 10px;
}

/* Sidebar + content (para modais grandes como lead) */
.modal-with-sidebar {
  display: flex;
  height: 100%;
  overflow: hidden;
}
.modal-sidebar {
  width: 172px;
  flex-shrink: 0;
  background: #FAFAFA;
  border-right: 1px solid #F3F4F6;
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}
.modal-sidebar-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  transition: background .12s;
  background: transparent;
  color: #6B7280;
}
.modal-sidebar-btn:hover { background: #F3F4F6; }
.modal-sidebar-btn.active {
  background: #F5F3FF;
  color: #7C3AED;
  font-weight: 600;
}
.modal-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
}

/* Slide-in lateral */
@keyframes lmSlideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }

/* Mobile */
@media (max-width: 640px) {
  .modal-box { border-radius: 14px; max-height: 100vh; }
  .modal-header { padding: 14px 16px; }
  .modal-body { padding: 14px 16px; }
  .modal-footer { padding: 12px 16px; }
  .modal-grid { grid-template-columns: 1fr; }
  .modal-grid-3 { grid-template-columns: 1fr; }
  .modal-with-sidebar { flex-direction: column; }
  .modal-sidebar { width: 100%; flex-direction: row; overflow-x: auto; padding: 8px; border-right: none; border-bottom: 1px solid #F3F4F6; }
  .modal-sidebar-btn { white-space: nowrap; padding: 8px 14px; font-size: 12px; }
  .modal-content { padding: 16px; }
}
