/* Modal System - Compact Enterprise Density */

.modal-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(3px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  overflow-y: auto;
  box-sizing: border-box;
}

.modal-backdrop.show,
.modal-backdrop.active {
  display: flex;
  animation: modalFadeIn 0.15s ease-out;
}

.modal-box {
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.2);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  margin: auto;
}

/* Ensure any form inside modal-box flexes so modal-body scrolls and modal-foot remains visible! */
.modal-box > form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.modal-box-lg {
  max-width: 720px;
}

.modal-head {
  padding: 0.85rem 1.15rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  background: #ffffff;
}

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

.modal-close-btn,
.btn-modal-close {
  background: none;
  border: none;
  font-size: 1.35rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.2rem;
  border-radius: 4px;
  transition: all 0.15s ease;
}

.modal-close-btn:hover,
.btn-modal-close:hover {
  color: var(--text-main);
  background: #f1f5f9;
}

.modal-body {
  padding: 1.15rem 1.25rem;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}

.modal-foot {
  padding: 0.75rem 1.15rem;
  background: #f8fafc;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* Smooth custom scrollbars inside modal bodies */
.modal-body::-webkit-scrollbar,
.target-studio-body::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
.modal-body::-webkit-scrollbar-track,
.target-studio-body::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 4px;
}
.modal-body::-webkit-scrollbar-thumb,
.target-studio-body::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
.modal-body::-webkit-scrollbar-thumb:hover,
.target-studio-body::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

@keyframes modalFadeIn {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}
