/*
 * attachment-preview-modal.css — Modal universal preview de anexos.
 * Define familia .portal-modal* compartilhada com _ValidationAttachmentPreviewModal
 * (legacy). Tokens via base.css; mobile-first (<640 full-screen).
 */

.portal-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.portal-modal:not([hidden]),
.portal-modal.is-open,
.portal-modal.active {
  display: flex;
}

.portal-modal[hidden] {
  display: none !important;
}

.portal-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  cursor: pointer;
}

.portal-modal-dialog,
.portal-modal-content {
  position: relative;
  background: var(--color-surface);
  color: var(--color-text);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  margin: 16px;
}

.portal-modal-dialog--md,
.portal-modal-medium { max-width: 640px; }

.portal-modal-dialog--lg,
.portal-modal-large { max-width: 800px; }

.portal-modal-dialog--xl { max-width: 1024px; }

.portal-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--color-border);
}

.portal-modal-title {
  margin: 0;
  font-size: var(--fs-lg, 1.125rem);
  font-weight: var(--fw-semibold, 600);
  color: var(--color-text);
  line-height: 1.3;
}

.portal-modal-close {
  border: 0;
  background: transparent;
  font-size: 28px;
  line-height: 1;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  flex-shrink: 0;
}

.portal-modal-close:hover {
  background: var(--color-surface-hover);
  color: var(--color-text);
}

.portal-modal-close:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.portal-modal-body {
  padding: 20px 24px;
  overflow: auto;
  flex: 1 1 auto;
  min-height: 80px;
}

.portal-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid var(--color-border);
  background: var(--color-surface-muted);
  flex-wrap: wrap;
}

/* Imagem inline obedece tamanho do dialog */
.portal-modal-image {
  display: block;
  max-width: 100%;
  max-height: 60vh;
  height: auto;
  margin: 0 auto;
  object-fit: contain;
  background: var(--color-surface-muted);
}

/* Iframe PDF preview (responsive). */
.portal-modal-pdf-frame {
  width: 100%;
  height: 60vh;
  min-height: 360px;
  border: 0;
  background: var(--color-surface-muted);
}

.portal-modal-loading,
.portal-modal-fallback {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  color: var(--color-text-muted);
  text-align: center;
}

.portal-modal-error {
  padding: 12px 16px;
  border-radius: 8px;
  background: var(--color-error-bg);
  color: var(--color-error-text);
  border: 1px solid var(--color-error-border);
  margin-bottom: 12px;
}

/* JSON read-only fields container */
.portal-modal-json-fields {
  display: grid;
  gap: 12px;
}

/* Mobile-first: viewport <640px → full-screen, sem cantos. */
@media (max-width: 639.98px) {
  .portal-modal-dialog,
  .portal-modal-content {
    margin: 0;
    border-radius: 0;
    max-width: 100%;
    max-height: 100vh;
    height: 100vh;
  }

  .portal-modal-pdf-frame { height: calc(100vh - 220px); }
  .portal-modal-image { max-height: calc(100vh - 240px); }

  .portal-modal-footer {
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .portal-modal-footer .btn-canonical { width: 100%; }
}
