
/* Respeta el atributo hidden aunque otros estilos usen display:grid/flex. */
.aps-wrap [hidden] {
  display: none !important;
}

.aps-wrap,
.aps-wrap * {
  box-sizing: border-box;
}

.aps-wrap {
  --aps-bg: #f3f7fb;
  --aps-panel: #ffffff;
  --aps-line: #dbe5ef;
  --aps-text: #162033;
  --aps-muted: #66758a;
  --aps-primary: #0b84d8;
  --aps-primary-2: #11b59b;
  --aps-danger: #d94b4b;
  width: min(1280px, 100%);
  margin: 0 auto;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--aps-text);
}

.aps-hero,
.aps-app,
.aps-image-pdf-box,
.aps-modal-card {
  background: var(--aps-panel);
  border: 1px solid var(--aps-line);
  border-radius: 22px;
  box-shadow: 0 14px 45px rgba(20, 42, 70, .08);
}

.aps-hero {
  padding: 24px;
  display: grid;
  grid-template-columns: 1.1fr .9fr;
  gap: 18px;
  align-items: stretch;
}

.aps-kicker {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--aps-primary);
}

.aps-hero h2,
.aps-image-pdf-box h3,
.aps-sidebar h3,
.aps-modal-card h3 {
  margin: 0 0 8px;
  line-height: 1.15;
}

.aps-hero p,
.aps-image-pdf-box p,
.aps-modal-card p {
  margin: 0;
  color: var(--aps-muted);
}

.aps-tool-cards {
  grid-column: 1 / 2;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.aps-card {
  appearance: none;
  border: 1px solid var(--aps-line);
  background: #f8fbff;
  border-radius: 18px;
  padding: 16px;
  text-align: left;
  cursor: pointer;
  transition: .15s ease;
}

.aps-card:hover,
.aps-card-primary {
  transform: translateY(-1px);
  border-color: rgba(11, 132, 216, .35);
  box-shadow: 0 10px 25px rgba(11, 132, 216, .12);
}

.aps-card span {
  display: block;
  font-weight: 800;
  font-size: 16px;
  color: var(--aps-text);
}

.aps-card small {
  display: block;
  margin-top: 6px;
  color: var(--aps-muted);
  line-height: 1.35;
}

.aps-drop {
  grid-row: 1 / span 2;
  grid-column: 2 / 3;
  min-height: 230px;
  border: 2px dashed #b7c9dc;
  background: linear-gradient(135deg, #f7fbff, #eef7ff);
  border-radius: 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  text-align: center;
}

.aps-drop.is-dragover {
  border-color: var(--aps-primary);
  background: #eaf6ff;
}

.aps-drop-icon {
  width: 70px;
  height: 70px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: #0b84d8;
  color: white;
  font-weight: 900;
  letter-spacing: .08em;
}

.aps-drop span,
.aps-help,
.aps-muted {
  color: var(--aps-muted);
  font-size: 13px;
  line-height: 1.45;
}

.aps-image-pdf-box {
  padding: 22px;
}

.aps-box-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.aps-inline-row,
.aps-button-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.aps-main-btn,
.aps-secondary-btn,
.aps-danger-btn,
.aps-link-btn,
.aps-page-controls button,
.aps-zoom-controls button {
  appearance: none;
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 800;
  cursor: pointer;
  line-height: 1;
}

.aps-main-btn {
  background: linear-gradient(135deg, var(--aps-primary), var(--aps-primary-2));
  color: white;
}

.aps-secondary-btn {
  background: #e8f1fb;
  color: #244566;
}

.aps-danger-btn {
  background: #ffecec;
  color: var(--aps-danger);
}

.aps-link-btn {
  background: transparent;
  color: var(--aps-primary);
  padding: 6px 8px;
}

.aps-app {
  overflow: hidden;
}

.aps-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  border-bottom: 1px solid var(--aps-line);
  background: #fbfdff;
  flex-wrap: wrap;
}

.aps-top-left,
.aps-page-controls,
.aps-zoom-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.aps-page-controls input {
  width: 62px;
  border: 1px solid var(--aps-line);
  border-radius: 10px;
  padding: 8px;
}

.aps-page-controls button,
.aps-zoom-controls button {
  background: #ecf4fb;
  color: #244566;
  min-width: 36px;
}

.aps-layout {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr) 260px;
  min-height: 720px;
}

.aps-sidebar {
  padding: 14px;
  background: #fbfdff;
}

.aps-tools {
  border-right: 1px solid var(--aps-line);
}

.aps-inspector {
  border-left: 1px solid var(--aps-line);
}

.aps-sidebar button,
.aps-file-mini {
  width: 100%;
  display: block;
  margin-bottom: 8px;
}

.aps-tools button {
  text-align: left;
  border: 1px solid var(--aps-line);
  background: white;
  color: #223247;
  border-radius: 12px;
  padding: 10px 12px;
  font-weight: 750;
  cursor: pointer;
}

.aps-tools button.is-active {
  color: white;
  border-color: var(--aps-primary);
  background: linear-gradient(135deg, var(--aps-primary), var(--aps-primary-2));
}

.aps-file-mini {
  border: 1px solid var(--aps-line);
  border-radius: 12px;
  padding: 10px;
  background: white;
  font-size: 13px;
  font-weight: 800;
  color: #223247;
  cursor: pointer;
}

.aps-file-mini input {
  display: block;
  width: 100%;
  margin-top: 8px;
  font-weight: 400;
}

.aps-divider {
  height: 1px;
  background: var(--aps-line);
  margin: 14px 0;
}

.aps-stage-wrap {
  background: var(--aps-bg);
  padding: 16px;
  overflow: auto;
}

.aps-stage-help {
  margin: 0 auto 12px;
  width: fit-content;
  max-width: 100%;
  background: rgba(255, 255, 255, .88);
  border: 1px solid var(--aps-line);
  border-radius: 999px;
  padding: 8px 14px;
  color: var(--aps-muted);
  font-weight: 750;
  font-size: 13px;
}

.aps-stage {
  position: relative;
  width: fit-content;
  margin: 0 auto;
  background: white;
  box-shadow: 0 18px 50px rgba(18, 38, 63, .18);
  outline: none;
}

.aps-stage canvas {
  display: block;
}

.aps-overlay {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.aps-ann {
  position: absolute;
  min-width: 14px;
  min-height: 14px;
  outline: 1px dashed transparent;
  user-select: none;
  touch-action: none;
}

.aps-ann.is-selected {
  outline-color: #ff427d;
  box-shadow: 0 0 0 2px rgba(255, 66, 125, .12);
}

.aps-ann-text {
  white-space: pre-wrap;
  overflow: hidden;
  cursor: move;
}

.aps-ann-text[contenteditable="true"] {
  user-select: text;
  cursor: text;
}

.aps-ann-image img,
.aps-ann-signature img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
}

.aps-ann-whiteout {
  background: #fff;
  border: 1px solid rgba(20, 40, 60, .08);
}

.aps-ann-highlight {
  background: rgba(255, 230, 0, .42);
}

.aps-ann-xmark {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
}

.aps-resize {
  position: absolute;
  right: -7px;
  bottom: -7px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ff427d;
  border: 2px solid white;
  cursor: nwse-resize;
  display: none;
}

.aps-ann.is-selected .aps-resize {
  display: block;
}

.aps-inspector label {
  display: block;
  margin: 10px 0 5px;
  font-weight: 800;
  font-size: 13px;
}

.aps-inspector input,
.aps-inspector textarea,
.aps-inspector select {
  width: 100%;
  border: 1px solid var(--aps-line);
  border-radius: 10px;
  padding: 9px;
  background: white;
}

.aps-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.aps-full {
  width: 100%;
  text-align: center !important;
}

.aps-modal {
  position: fixed;
  inset: 0;
  z-index: 999999;
  background: rgba(8, 18, 32, .62);
  display: grid;
  place-items: center;
  padding: 18px;
}

.aps-modal-card {
  width: min(720px, 100%);
  padding: 20px;
}

.aps-sign-canvas {
  display: block;
  width: 100%;
  max-width: 100%;
  height: 220px;
  background: white;
  border: 1px solid var(--aps-line);
  border-radius: 14px;
  touch-action: none;
}

@media (max-width: 1100px) {
  .aps-layout {
    grid-template-columns: 180px minmax(0, 1fr);
  }
  .aps-inspector {
    grid-column: 1 / -1;
    border-left: 0;
    border-top: 1px solid var(--aps-line);
  }
}

@media (max-width: 780px) {
  .aps-hero {
    grid-template-columns: 1fr;
  }
  .aps-tool-cards,
  .aps-drop {
    grid-column: auto;
    grid-row: auto;
  }
  .aps-tool-cards {
    grid-template-columns: 1fr;
  }
  .aps-layout {
    grid-template-columns: 1fr;
  }
  .aps-tools {
    border-right: 0;
    border-bottom: 1px solid var(--aps-line);
  }
  .aps-tools button {
    display: inline-block;
    width: auto;
    margin-right: 6px;
  }
}

/* v1.1.0: modo más cómodo tipo editor moderno.
   El panel de propiedades baja debajo del PDF para no robar anchura al documento. */
.aps-layout {
  grid-template-columns: 190px minmax(0, 1fr);
}

.aps-stage-wrap {
  min-width: 0;
}

.aps-inspector {
  grid-column: 1 / -1;
  border-left: 0;
  border-top: 1px solid var(--aps-line);
  background: #ffffff;
}

.aps-inspector [data-aps-selection-panel] {
  max-width: 980px;
}

.aps-inspector textarea {
  min-height: 76px;
}

.aps-zoom-controls [data-aps-fit] {
  min-width: auto;
  white-space: nowrap;
}

@media (min-width: 900px) {
  .aps-inspector [data-aps-selection-panel] .aps-button-row {
    margin-top: 10px;
  }
}

@media (max-width: 780px) {
  .aps-layout {
    grid-template-columns: 1fr;
  }
}

/* v1.2.0: edición en el propio recuadro, sin panel lateral de propiedades. */
.aps-layout {
  grid-template-columns: 190px minmax(0, 1fr) !important;
}

.aps-inspector {
  display: none !important;
}

.aps-stage-wrap {
  position: relative;
  overflow: auto;
}

.aps-ann-text {
  box-sizing: border-box;
  padding: 0;
  border: 0;
  line-height: 1.18;
}

.aps-ann-text.is-cover-on {
  background: #ffffff;
}

.aps-ann-text[contenteditable="true"] {
  caret-color: #111111;
}

.aps-ann-text[contenteditable="true"]:focus {
  outline: 2px solid rgba(0, 132, 216, .45);
  outline-offset: 2px;
}

.aps-mini-toolbar {
  position: absolute;
  z-index: 50;
  box-sizing: border-box;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 7px;
  width: min(680px, calc(100% - 16px));
  max-width: calc(100% - 16px);
  padding: 9px;
  border: 1px solid rgba(147, 164, 184, .45);
  border-radius: 14px;
  background: rgba(255, 255, 255, .98);
  box-shadow: 0 16px 40px rgba(18, 38, 63, .22);
  backdrop-filter: blur(8px);
  font-size: 12px;
  overflow: hidden;
}

.aps-mini-toolbar[hidden] {
  display: none !important;
}

.aps-mini-toolbar label {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-weight: 800;
  color: #33445c;
  margin: 0;
  min-width: 0;
}

.aps-mini-toolbar input,
.aps-mini-toolbar select,
.aps-mini-toolbar textarea {
  box-sizing: border-box;
  border: 1px solid var(--aps-line);
  border-radius: 9px;
  background: #fff;
  padding: 6px 8px;
  font-size: 12px;
  line-height: 1.2;
  max-width: 100%;
}

.aps-mini-toolbar .aps-mini-text {
  flex: 1 1 230px;
}

.aps-mini-toolbar textarea {
  width: 100%;
  min-height: 38px;
  resize: vertical;
}

.aps-mini-toolbar input[type="number"] {
  width: 66px;
}

.aps-mini-toolbar select {
  width: 112px;
}

.aps-mini-toolbar input[type="color"] {
  width: 46px;
  padding: 3px;
}

.aps-cover-option {
  flex: 0 0 auto;
  flex-direction: row !important;
  align-items: center !important;
  gap: 5px !important;
  white-space: nowrap;
  padding-bottom: 6px;
}

.aps-cover-option input {
  width: auto !important;
}

.aps-mini-btn {
  appearance: none;
  flex: 0 0 auto;
  border: 0;
  border-radius: 10px;
  padding: 8px 10px;
  background: #e8f1fb;
  color: #244566;
  font-weight: 900;
  cursor: pointer;
  line-height: 1;
  white-space: nowrap;
}

.aps-mini-btn:first-of-type {
  background: linear-gradient(135deg, var(--aps-primary), var(--aps-primary-2));
  color: #fff;
}

.aps-mini-danger {
  background: #ffecec !important;
  color: var(--aps-danger) !important;
}

.aps-tools .aps-danger-btn {
  text-align: center;
}

@media (max-width: 700px) {
  .aps-mini-toolbar {
    width: calc(100% - 16px);
    max-height: 220px;
    overflow-y: auto;
  }
  .aps-mini-toolbar .aps-mini-text {
    flex-basis: 100%;
  }
  .aps-mini-toolbar textarea {
    min-height: 34px;
  }
}

@media (max-width: 900px) {
  .aps-layout {
    grid-template-columns: 1fr !important;
  }
  .aps-tools button,
  .aps-file-mini {
    width: auto;
    display: inline-block;
    vertical-align: top;
    margin-right: 6px;
  }
  .aps-file-mini input {
    max-width: 170px;
  }
  .aps-mini-toolbar {
    left: 8px !important;
    top: 8px !important;
    width: calc(100% - 16px);
  }
}

/* Conversor independiente: imagen a PDF */
.aps-image-converter-wrap {
  max-width: 980px;
}

.aps-image-pdf-standalone {
  padding: 24px;
}

.aps-image-pdf-standalone h2 {
  margin: 0 0 8px;
  line-height: 1.15;
}

.aps-converter-drop {
  border: 2px dashed #b9cbe1;
  border-radius: 20px;
  min-height: 190px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #f8fbff;
  cursor: pointer;
  text-align: center;
  padding: 22px;
  transition: border-color .15s ease, background .15s ease, transform .15s ease;
}

.aps-converter-drop.is-dragover {
  border-color: var(--aps-primary);
  background: #eef7ff;
  transform: scale(.995);
}

.aps-converter-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(130px, 1fr)) auto auto;
  gap: 10px;
  align-items: end;
  margin: 16px 0 10px;
}

.aps-converter-controls label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  font-weight: 800;
}

.aps-converter-controls select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--aps-line);
  border-radius: 12px;
  padding: 8px 10px;
  background: white;
}

.aps-converter-status {
  color: var(--aps-muted);
  font-size: 13px;
  font-weight: 700;
  margin: 10px 0;
}

.aps-converter-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.aps-converter-item {
  border: 1px solid var(--aps-line);
  border-radius: 16px;
  background: #fff;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(20, 42, 70, .06);
}

.aps-converter-thumb {
  width: 100%;
  height: 135px;
  object-fit: contain;
  background: #f1f5fb;
  display: block;
}

.aps-converter-meta {
  padding: 10px;
}

.aps-converter-name {
  display: block;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 8px;
}

.aps-converter-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.aps-converter-actions button {
  appearance: none;
  border: 0;
  border-radius: 10px;
  background: #e8f1fb;
  color: #244566;
  font-weight: 800;
  font-size: 12px;
  padding: 7px 9px;
  cursor: pointer;
}

.aps-converter-actions button[data-action="remove"] {
  background: #ffecec;
  color: var(--aps-danger);
}

@media (max-width: 760px) {
  .aps-converter-controls {
    grid-template-columns: 1fr;
  }
}

/* v1.4.0: modo Emigrantes.eu */
.aps-emigrantes-hub {
  max-width: 1180px;
}

.aps-emigrantes-hero {
  background: linear-gradient(135deg, #ffffff, #eff7ff);
  border: 1px solid var(--aps-line);
  border-radius: 24px;
  box-shadow: 0 14px 45px rgba(20, 42, 70, .08);
  padding: 28px;
  margin-bottom: 18px;
}

.aps-emigrantes-hero h2 {
  margin: 0 0 10px;
  font-size: clamp(26px, 3.2vw, 42px);
  line-height: 1.08;
}

.aps-emigrantes-hero p {
  margin: 0;
  max-width: 820px;
  color: var(--aps-muted);
  font-size: 17px;
  line-height: 1.5;
}

.aps-trust-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.aps-trust-row span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: 1px solid #dbe8f6;
  background: #fff;
  border-radius: 999px;
  color: #243b55;
  font-weight: 800;
  font-size: 13px;
}

.aps-hub-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.aps-hub-card {
  appearance: none;
  width: 100%;
  border: 1px solid var(--aps-line);
  border-radius: 20px;
  background: #fff;
  padding: 18px;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(20, 42, 70, .06);
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}

.aps-hub-card:hover,
.aps-hub-card.is-active {
  transform: translateY(-1px);
  border-color: rgba(11, 132, 216, .38);
  box-shadow: 0 12px 30px rgba(11, 132, 216, .12);
}

.aps-hub-card strong {
  display: block;
  color: var(--aps-text);
  font-size: 17px;
  line-height: 1.15;
  margin-bottom: 8px;
}

.aps-hub-card span {
  display: block;
  color: var(--aps-muted);
  font-size: 14px;
  line-height: 1.35;
}

.aps-hub-note {
  margin: 0 0 14px;
  color: var(--aps-muted);
  font-size: 14px;
}

.aps-hub-section {
  margin-top: 12px;
}

.aps-simple-pdf-tool {
  max-width: 980px;
}

.aps-pdf-mini-icon {
  flex: 0 0 56px;
  width: 56px;
  height: 72px;
  border-radius: 10px;
  border: 1px solid #cfe0ef;
  background: linear-gradient(135deg, #f7fbff, #eaf5ff);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--aps-primary);
  font-weight: 950;
  font-size: 13px;
}

.aps-wide-control {
  min-width: min(360px, 100%);
}

.aps-wide-control input {
  width: 100%;
}

.aps-extract-controls {
  align-items: flex-end;
}

@media (max-width: 920px) {
  .aps-hub-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .aps-emigrantes-hero {
    padding: 20px;
  }
  .aps-hub-grid {
    grid-template-columns: 1fr;
  }
  .aps-trust-row span {
    width: 100%;
  }
}
