/* ==========================================================================
   Modern modal (frontend, light theme)
   Same look and feel as the HTML5 editor text modal (EditorV2.css), in light.
   Load after Bootstrap 5. Activate with class="modal modern-modal".
   ========================================================================== */

.modern-modal {
  --mm-bg: #ffffff;
  --mm-panel-2: #f6f7f9;
  --mm-panel-3: #eceef2;
  --mm-line: rgba(15, 18, 23, 0.10);
  --mm-text: #1f2329;
  --mm-muted: #6b7280;
  --mm-primary: #2F80ED;
  --mm-primary-hover: #1F6FDC;
  --mm-primary-soft: rgba(47, 128, 237, 0.14);
  --mm-danger: #E5484D;
  --mm-danger-hover: #D13A3F;
  --mm-ease: cubic-bezier(0.2, 0.7, 0.3, 1);
  --mm-radius: 14px;

  /* Aliases kept for components already using the previous variable names */
  --mm-soft: var(--mm-panel-2);
  --mm-border: var(--mm-line);

  color: var(--mm-text);
}

/* Backdrop (only while a modern-modal is open) */
body:has(.modern-modal.show) .modal-backdrop.show {
  opacity: 1;
  background: rgba(15, 18, 23, 0.35);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.modern-modal .modal-dialog {
  transition: transform 0.28s var(--mm-ease), opacity 0.28s var(--mm-ease);
}
.modern-modal.fade .modal-dialog { transform: translateY(12px) scale(0.98); }
.modern-modal.show .modal-dialog { transform: none; }

.modern-modal .modal-content {
  border: 1px solid var(--mm-line);
  border-radius: var(--mm-radius);
  background: var(--mm-bg);
  color: var(--mm-text);
  box-shadow: 0 24px 64px rgba(15, 18, 23, 0.18), 0 2px 6px rgba(15, 18, 23, 0.08);
  overflow: hidden;
}

/* Header */
.modern-modal .modal-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--mm-line);
  background: linear-gradient(180deg, var(--mm-panel-2), var(--mm-bg));
}
.modern-modal .modal-symbol {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--mm-primary-soft);
  color: var(--mm-primary);
  font-size: 18px;
}
.modern-modal .modal-symbol .material-symbols-outlined { font-size: 20px; }
.modern-modal.modal-danger .modal-symbol {
  background: rgba(229, 72, 77, 0.12);
  color: var(--mm-danger);
}
.modern-modal .modal-heading {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1 1 auto;
}
.modern-modal .modal-eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--mm-muted);
}
.modern-modal .modal-title {
  margin: 2px 0 0;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--mm-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.modern-modal .modal-subtitle {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--mm-muted);
}
.modern-modal .modal-close {
  display: grid;
  place-items: center;
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  margin-left: auto;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--mm-muted);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.modern-modal .modal-close:hover {
  background: var(--mm-panel-3);
  color: var(--mm-text);
}

/* Body */
.modern-modal .modal-body {
  padding: 22px 20px 8px;
  background: var(--mm-bg);
}
.modern-modal .modal-body > :last-child { margin-bottom: 14px; }

.modern-modal .form-label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--mm-muted);
}
.modern-modal .form-control,
.modern-modal .form-select {
  height: auto;
  border: 1px solid var(--mm-line);
  border-radius: 8px;
  background-color: var(--mm-panel-2);
  color: var(--mm-text);
  padding: 10px 12px;
  font-size: 14px;
  transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
}
.modern-modal .form-control::placeholder { color: var(--mm-muted); opacity: 1; }
.modern-modal .form-control:focus,
.modern-modal .form-select:focus {
  border-color: var(--mm-primary);
  background-color: var(--mm-bg);
  box-shadow: 0 0 0 3px var(--mm-primary-soft);
  color: var(--mm-text);
  outline: none;
}
.modern-modal textarea.form-control {
  min-height: 140px;
  line-height: 1.5;
  resize: vertical;
}
.modern-modal .input-group-text {
  border: 1px solid var(--mm-line);
  background: var(--mm-panel-3);
  color: var(--mm-muted);
  font-size: 13px;
}
.modern-modal .form-control.is-invalid,
.modern-modal .was-validated .form-control:invalid {
  border-color: var(--mm-danger);
  box-shadow: 0 0 0 3px rgba(229, 72, 77, 0.2);
}
.modern-modal .invalid-feedback { color: var(--mm-danger); }
.modern-modal .form-text { color: var(--mm-muted); }

.modern-modal .modal-summary {
  padding: 14px 16px;
  background: var(--mm-panel-2);
  border: 1px solid var(--mm-line);
  border-radius: 10px;
}
.modern-modal .modal-summary small { display: block; margin-top: 4px; color: var(--mm-muted); }

/* Footer */
.modern-modal .modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 14px 20px;
  border-top: 1px solid var(--mm-line);
  background: var(--mm-panel-2);
}
.modern-modal .modal-footer > * { margin: 0; }
.modern-modal .modal-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}
.modern-modal .modal-hint {
  margin-right: auto;
  font-size: 12px;
  color: var(--mm-muted);
}
.modern-modal .modal-hint kbd {
  padding: 2px 6px;
  border: 1px solid var(--mm-line);
  border-radius: 4px;
  background: var(--mm-bg);
  color: var(--mm-text);
  font-size: 11px;
  font-family: inherit;
  box-shadow: none;
}

/* Buttons */
.modern-modal .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  transition: background-color 0.15s, border-color 0.15s, box-shadow 0.15s, color 0.15s;
}
.modern-modal .btn-primary {
  color: #fff;
  background: var(--mm-primary);
  border-color: var(--mm-primary);
}
.modern-modal .btn-primary:hover,
.modern-modal .btn-primary:active {
  color: #fff;
  background: var(--mm-primary-hover);
  border-color: var(--mm-primary-hover);
}
.modern-modal .btn-danger {
  color: #fff;
  background: var(--mm-danger);
  border-color: var(--mm-danger);
}
.modern-modal .btn-danger:hover,
.modern-modal .btn-danger:active {
  color: #fff;
  background: var(--mm-danger-hover);
  border-color: var(--mm-danger-hover);
}
.modern-modal .btn-soft,
.modern-modal .btn-ghost {
  color: var(--mm-text);
  background: transparent;
  border: 1px solid var(--mm-line);
}
.modern-modal .btn-soft:hover,
.modern-modal .btn-soft:active,
.modern-modal .btn-ghost:hover,
.modern-modal .btn-ghost:active { background: var(--mm-panel-3); }
.modern-modal .btn:disabled { opacity: .6; cursor: not-allowed; }
.modern-modal .btn:focus-visible,
.modern-modal .modal-close:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--mm-primary-soft);
}

/* Loading skeleton */
.modern-modal .modal-skeleton {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-bottom: 16px;
}
.modern-modal .modal-skeleton span {
  display: block;
  height: 40px;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--mm-panel-2) 0%, var(--mm-panel-3) 50%, var(--mm-panel-2) 100%);
  background-size: 200% 100%;
  animation: mm-shimmer 1.2s linear infinite;
}
.modern-modal .modal-skeleton span:first-child { width: 35%; height: 14px; }
.modern-modal .modal-skeleton span:last-child { height: 120px; }

@keyframes mm-shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

@media (max-width: 575.98px) {
  .modern-modal .modal-header { padding: 16px; }
  .modern-modal .modal-body { padding: 18px 16px 6px; }
  .modern-modal .modal-footer { padding: 12px 16px; }
  .modern-modal .modal-footer .btn { flex: 1 1 auto; }
}

@media (prefers-reduced-motion: reduce) {
  .modern-modal .modal-dialog,
  .modern-modal .btn,
  .modern-modal .modal-skeleton span {
    transition: none;
    animation: none;
  }
  .modern-modal.fade .modal-dialog { transform: none; }
}
