/* ==========================================================
   EMTEL ERP v2.3 - Previsualizador URL con lupita
   Capa modular para imagenes, PDF y documentos enlazados.
   ========================================================== */
.field-label-row {
  display: inline-flex !important;
  align-items: center;
  gap: .42rem;
  flex-wrap: wrap;
  width: 100%;
}

.field-label-row .field-label-text { flex: 0 1 auto; }

.url-preview-trigger {
  margin-left: auto;
  width: 1.45rem;
  height: 1.45rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(37, 99, 235, .20);
  background: rgba(37, 99, 235, .065);
  color: #1d4ed8;
  border-radius: .45rem;
  cursor: pointer;
  transition: transform .15s ease, border-color .15s ease, background .15s ease, box-shadow .15s ease;
  flex: 0 0 auto;
}

.url-preview-trigger:hover,
.url-preview-trigger:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(37, 99, 235, .42);
  background: rgba(37, 99, 235, .12);
  box-shadow: 0 8px 18px rgba(37, 99, 235, .16);
  outline: none;
}

.url-preview-trigger .icon-svg,
.url-preview-trigger svg {
  width: .95rem;
  height: .95rem;
  stroke-width: 2.2;
}

.url-preview-modal.is-hidden { display: none; }

.url-preview-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  padding: clamp(1rem, 3vw, 2rem);
}

.url-preview-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, .52);
  backdrop-filter: blur(6px);
}

.url-preview-dialog {
  position: relative;
  width: min(1120px, 96vw);
  height: min(760px, 88vh);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border-radius: 1.25rem;
  border: 1px solid rgba(148, 163, 184, .35);
  background: #f8fafc;
  box-shadow: 0 30px 90px rgba(15, 23, 42, .30);
}

.url-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.1rem;
  border-bottom: 1px solid rgba(148, 163, 184, .28);
  background: rgba(255, 255, 255, .92);
}

.url-preview-titlewrap {
  display: inline-flex;
  align-items: center;
  gap: .75rem;
  min-width: 0;
}

.url-preview-title-icon {
  width: 2.25rem;
  height: 2.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: .75rem;
  color: #2563eb;
  background: rgba(37, 99, 235, .10);
}

.url-preview-title-icon svg { width: 1.1rem; height: 1.1rem; }

.url-preview-title {
  margin: 0;
  font-size: 1rem;
  line-height: 1.2;
  font-weight: 700;
  color: #0f172a;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: min(54vw, 620px);
}

.url-preview-subtitle {
  margin: .15rem 0 0;
  font-size: .82rem;
  color: #64748b;
}

.url-preview-actions {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.url-preview-tool,
.url-preview-close {
  min-width: 2.1rem;
  height: 2.1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: .65rem;
  border: 1px solid rgba(148, 163, 184, .42);
  background: #fff;
  color: #0f3769;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.url-preview-tool:hover,
.url-preview-close:hover {
  background: #eff6ff;
  border-color: rgba(37, 99, 235, .34);
}

.url-preview-close { color: #991b1b; }
.url-preview-tool svg,
.url-preview-close svg { width: 1rem; height: 1rem; }
.url-preview-zoom-label { min-width: 3.4rem; text-align: center; font-size: .78rem; font-weight: 700; color: #475569; }

.url-preview-body {
  position: relative;
  min-height: 0;
  overflow: auto;
  background:
    linear-gradient(90deg, rgba(148,163,184,.07) 1px, transparent 1px),
    linear-gradient(rgba(148,163,184,.07) 1px, transparent 1px),
    #eef2f7;
  background-size: 22px 22px;
}

.url-preview-stage {
  min-height: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 1.25rem;
  transform-origin: top center;
}

.url-preview-stage-content {
  transform-origin: top center;
  transition: transform .12s ease;
}

.url-preview-image-shell {
  width: max-content;
  max-width: 100%;
}

.url-preview-image {
  display: block;
  max-width: min(100%, 980px);
  max-height: calc(88vh - 150px);
  object-fit: contain;
  border-radius: .9rem;
  border: 1px solid rgba(148, 163, 184, .35);
  background: #fff;
  box-shadow: 0 18px 48px rgba(15, 23, 42, .18);
}

.url-preview-frame-shell {
  width: min(1000px, 88vw);
  height: calc(88vh - 150px);
  border-radius: .9rem;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, .35);
  background: #fff;
  box-shadow: 0 18px 48px rgba(15, 23, 42, .18);
}

.url-preview-frame {
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

.url-preview-error {
  position: absolute;
  left: 50%;
  bottom: 1.2rem;
  transform: translateX(-50%);
  display: grid;
  gap: .15rem;
  width: min(560px, calc(100% - 2rem));
  padding: .9rem 1rem;
  border-radius: .85rem;
  border: 1px solid rgba(220, 38, 38, .25);
  background: rgba(254, 242, 242, .96);
  color: #7f1d1d;
  box-shadow: 0 14px 28px rgba(127, 29, 29, .12);
}

.url-preview-error.is-hidden { display: none; }
.url-preview-error strong { color: #991b1b; }
.url-preview-error span { font-size: .86rem; }

@media (max-width: 720px) {
  .url-preview-dialog { width: 98vw; height: 92vh; border-radius: 1rem; }
  .url-preview-header { align-items: flex-start; flex-direction: column; }
  .url-preview-actions { width: 100%; justify-content: flex-start; }
  .url-preview-title { max-width: 86vw; }
  .url-preview-frame-shell { width: 88vw; height: calc(92vh - 185px); }
  .url-preview-image { max-height: calc(92vh - 185px); }
}
