/*
  PDFTools — capa visual segura
  Esta hoja solo modifica presentación. No cambia IDs, formularios ni lógica de las herramientas.
*/

:root {
  --pro-accent: #7b8cff;
  --pro-accent-strong: #9584ff;
  --pro-cyan: #52d8c9;
  --pro-success: #4fd7a4;
  --pro-danger: #ff7d93;
  --pro-surface: rgba(10, 24, 43, 0.82);
  --pro-surface-strong: rgba(12, 29, 51, 0.96);
  --pro-border: rgba(154, 177, 214, 0.19);
  --pro-radius: 18px;
  --pro-shadow: 0 18px 55px rgba(0, 6, 18, 0.28);
}

/* 1) Cabecera y navegación más limpias */
.header {
  position: relative;
  z-index: 50;
}

.nav-toggle {
  display: none;
  width: 100%;
  min-height: 42px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  padding: 9px 12px;
  color: #eaf0fb;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 750;
  border: 1px solid var(--pro-border);
  border-radius: 12px;
  background: rgba(7, 19, 35, 0.78);
  cursor: pointer;
}

.nav-toggle__icon {
  width: 21px;
  height: 14px;
  position: relative;
  display: inline-block;
  border-top: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
}

.nav-toggle__icon::before {
  content: "";
  position: absolute;
  top: 50%;
  right: 0;
  left: 0;
  border-top: 2px solid currentColor;
  transform: translateY(-50%);
}

.nav-toggle[aria-expanded="true"] .nav-toggle__icon {
  border-color: transparent;
}

.nav-toggle[aria-expanded="true"] .nav-toggle__icon::before {
  transform: translateY(-50%) rotate(45deg);
}

.nav-toggle[aria-expanded="true"] .nav-toggle__icon::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 0;
  left: 0;
  border-top: 2px solid currentColor;
  transform: translateY(-50%) rotate(-45deg);
}

/* 2) Cabecera visual de cada herramienta */
.tools-grid--single .tool-card,
.a4-tool-card {
  overflow: visible;
  border-color: rgba(151, 174, 214, 0.22);
  background:
    radial-gradient(circle at 92% 0%, rgba(123, 140, 255, 0.12), transparent 34%),
    linear-gradient(145deg, rgba(13, 31, 54, 0.98), rgba(8, 21, 38, 0.97));
  box-shadow: var(--pro-shadow);
}

.tools-grid--single .tool-card > h2,
.a4-tool-card + * h2 {
  letter-spacing: -0.025em;
}

.tools-grid--single .tool-card > h2 {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 9px 12px;
}

.tools-grid--single .tool-card > h2::after {
  content: "Procesamiento local";
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 4px 9px;
  color: #9fe9df;
  font-size: 0.67rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  border: 1px solid rgba(82, 216, 201, 0.26);
  border-radius: 999px;
  background: rgba(82, 216, 201, 0.08);
}

html[lang="en"] .tools-grid--single .tool-card > h2::after {
  content: "Local processing";
}

.tools-grid--single .tool-card > p {
  max-width: 760px;
}

.hero {
  box-shadow: var(--pro-shadow);
}

/* 3) Selectores de archivo unificados y clicables en toda su superficie */
.file-label,
.pdf-dropzone {
  position: relative;
  isolation: isolate;
  width: 100%;
  min-height: 150px;
  padding: 28px 22px;
  overflow: hidden;
  border: 1.5px dashed rgba(123, 140, 255, 0.58);
  border-radius: 20px;
  background:
    radial-gradient(circle at 50% 5%, rgba(123, 140, 255, 0.15), transparent 52%),
    rgba(6, 18, 34, 0.72);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
  cursor: pointer;
  transform: translateZ(0);
  transition:
    transform 0.2s ease,
    border-color 0.2s ease,
    background-color 0.2s ease,
    box-shadow 0.2s ease;
}

.file-label::before,
.pdf-dropzone__icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  color: #f0f3ff;
  font-size: 1.45rem;
  font-weight: 700;
  border: 1px solid rgba(150, 163, 255, 0.38);
  border-radius: 15px;
  background: linear-gradient(145deg, rgba(123, 140, 255, 0.25), rgba(128, 91, 226, 0.14));
  box-shadow: 0 12px 30px rgba(75, 88, 207, 0.17);
  transition: transform 0.2s ease, background-color 0.2s ease;
}

.file-label > span,
.pdf-dropzone__text,
.pdf-dropzone__icon {
  position: relative;
  z-index: 2;
  pointer-events: none;
}

.file-label > span,
.pdf-dropzone__text {
  color: #f0f4ff;
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.35;
}

.file-label > span::after,
.pdf-dropzone__text::after {
  content: "Haz clic o arrastra el archivo aquí";
  display: block;
  margin-top: 7px;
  color: #91a3ba;
  font-size: 0.74rem;
  font-weight: 550;
  letter-spacing: 0;
}

html[lang="en"] .file-label > span::after,
html[lang="en"] .pdf-dropzone__text::after {
  content: "Click or drag the file here";
}

/* El input real cubre toda la zona. Esto evita que un estilo rompa el botón de carga. */
.file-label input[type="file"],
.pdf-dropzone__input {
  display: block !important;
  position: absolute !important;
  inset: 0 !important;
  z-index: 6 !important;
  width: 100% !important;
  height: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
  opacity: 0 !important;
  overflow: visible !important;
  clip: auto !important;
  clip-path: none !important;
  white-space: normal !important;
  border: 0 !important;
  cursor: pointer !important;
  pointer-events: auto !important;
}

.file-label:hover,
.pdf-dropzone:hover {
  transform: translateY(-2px);
  border-color: rgba(82, 216, 201, 0.72);
  background:
    radial-gradient(circle at 50% 5%, rgba(82, 216, 201, 0.14), transparent 54%),
    rgba(7, 22, 39, 0.9);
  box-shadow: 0 16px 40px rgba(0, 7, 19, 0.25);
}

.file-label:hover::before,
.pdf-dropzone:hover .pdf-dropzone__icon {
  transform: translateY(-3px);
}

.file-label:focus-within,
.pdf-dropzone:focus-within {
  border-color: #91a0ff;
  box-shadow: 0 0 0 4px rgba(123, 140, 255, 0.15), 0 16px 40px rgba(0, 7, 19, 0.24);
}

/* Estado seleccionado sin tocar JavaScript: se detecta la lista que ya crea cada herramienta. */
form:has(.file-list-item) .file-label,
.a4-field:has(.a4-file-info:not(:empty)) .pdf-dropzone {
  border-style: solid;
  border-color: rgba(79, 215, 164, 0.62);
  background:
    radial-gradient(circle at 50% 5%, rgba(79, 215, 164, 0.12), transparent 54%),
    rgba(7, 29, 36, 0.82);
}

form:has(.file-list-item) .file-label::before {
  content: "✓";
  color: #baf5dc;
  border-color: rgba(79, 215, 164, 0.38);
  background: rgba(79, 215, 164, 0.13);
}

.a4-field:has(.a4-file-info:not(:empty)) .pdf-dropzone__icon {
  color: #baf5dc;
  border-color: rgba(79, 215, 164, 0.38);
  background: rgba(79, 215, 164, 0.13);
}

.file-list-wrapper {
  border-color: rgba(151, 174, 214, 0.16);
  background: rgba(4, 15, 28, 0.5);
}

.file-list:empty::before {
  content: "Aún no seleccionaste archivos";
  display: block;
  padding: 7px 2px 3px;
  color: #6f8199;
  font-size: 0.76rem;
}

html[lang="en"] .file-list:empty::before {
  content: "No files selected yet";
}

.file-list-item {
  min-width: 0;
  padding: 10px 11px;
  border: 1px solid rgba(151, 174, 214, 0.13);
  border-radius: 11px;
  background: rgba(15, 34, 57, 0.62);
  word-break: break-word;
}

/* 4) Botones consistentes */
.btn.primary,
.a4-button-primary {
  min-height: 50px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  background: linear-gradient(135deg, #687cff, #8e67ef);
  box-shadow: 0 13px 30px rgba(87, 93, 231, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.18);
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease, opacity 0.18s ease;
}

.btn.primary:hover:not(:disabled),
.a4-button-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  filter: brightness(1.06);
  box-shadow: 0 17px 38px rgba(87, 93, 231, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.btn.primary:active:not(:disabled),
.a4-button-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn.secondary {
  border-color: rgba(151, 174, 214, 0.22);
  background: rgba(18, 39, 65, 0.72);
}

.btn:disabled,
.a4-button-primary:disabled {
  opacity: 0.5;
  filter: saturate(0.6);
  box-shadow: none;
  cursor: not-allowed;
}

/* 5) Estados de carga, éxito y error con aspecto de aviso profesional */
.status,
.a4-status {
  width: 100%;
  min-height: 0;
  margin-top: 14px;
  padding: 0;
  border: 0;
  border-radius: 13px;
  background: transparent;
  line-height: 1.45;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.status:empty,
.a4-status:empty {
  display: none;
}

.status:not(:empty),
.a4-status:not(:empty) {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid rgba(151, 174, 214, 0.18);
  background: rgba(9, 23, 40, 0.9);
  box-shadow: 0 12px 28px rgba(0, 6, 18, 0.2);
  animation: pro-status-in 0.22s ease both;
}

.status:not(:empty)::before,
.a4-status:not(:empty)::before {
  content: "•";
  flex: 0 0 auto;
  width: 23px;
  height: 23px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(123, 140, 255, 0.14);
}

.status--info:not(:empty)::before,
.a4-status--info:not(:empty)::before {
  content: "";
  width: 19px;
  height: 19px;
  border: 2px solid rgba(127, 218, 240, 0.22);
  border-top-color: #7fdaf0;
  background: transparent;
  animation: pro-spin 0.75s linear infinite;
}

.status--success:not(:empty),
.a4-status--success:not(:empty) {
  color: #aef0d2;
  border-color: rgba(79, 215, 164, 0.26);
  background: rgba(12, 46, 39, 0.82);
}

.status--success:not(:empty)::before,
.a4-status--success:not(:empty)::before {
  content: "✓";
  color: #baf5dc;
  background: rgba(79, 215, 164, 0.14);
}

.status--error:not(:empty),
.a4-status--error:not(:empty) {
  color: #ffc3cd;
  border-color: rgba(255, 125, 147, 0.28);
  background: rgba(58, 24, 35, 0.84);
}

.status--error:not(:empty)::before,
.a4-status--error:not(:empty)::before {
  content: "!";
  color: #ffc3cd;
  background: rgba(255, 125, 147, 0.14);
}

@keyframes pro-spin {
  to { transform: rotate(360deg); }
}

@keyframes pro-status-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 6) Tarjetas del inicio con jerarquía, etiquetas y flecha */
.container > .tools-grid:not(.tools-grid--single):not(.shop-grid) .tool-card {
  position: relative;
  min-height: 240px;
  padding-top: 26px;
  border-color: rgba(151, 174, 214, 0.18);
}

.container > .tools-grid:not(.tools-grid--single):not(.shop-grid) .tool-card .btn {
  position: relative;
  overflow: hidden;
  padding-right: 45px;
}

.container > .tools-grid:not(.tools-grid--single):not(.shop-grid) .tool-card .btn::after {
  content: "→";
  position: absolute;
  right: 17px;
  top: 50%;
  font-size: 1rem;
  transform: translateY(-50%);
  transition: transform 0.18s ease;
}

.container > .tools-grid:not(.tools-grid--single):not(.shop-grid) .tool-card:hover .btn::after {
  transform: translate(3px, -50%);
}

.container > .tools-grid:not(.tools-grid--single):not(.shop-grid) .tool-card:nth-child(1) h2::after,
.container > .tools-grid:not(.tools-grid--single):not(.shop-grid) .tool-card:nth-child(4) h2::after,
.container > .tools-grid:not(.tools-grid--single):not(.shop-grid) .tool-card:nth-child(5) h2::after {
  position: absolute;
  top: 15px;
  right: 15px;
  padding: 4px 8px;
  color: #dce3ff;
  font-size: 0.61rem;
  font-weight: 850;
  letter-spacing: 0.06em;
  border: 1px solid rgba(123, 140, 255, 0.28);
  border-radius: 999px;
  background: rgba(123, 140, 255, 0.11);
}

.container > .tools-grid:not(.tools-grid--single):not(.shop-grid) .tool-card:nth-child(1) h2::after,
.container > .tools-grid:not(.tools-grid--single):not(.shop-grid) .tool-card:nth-child(4) h2::after {
  content: "POPULAR";
}

.container > .tools-grid:not(.tools-grid--single):not(.shop-grid) .tool-card:nth-child(5) h2::after {
  content: "NUEVO";
  color: #aef0d2;
  border-color: rgba(79, 215, 164, 0.26);
  background: rgba(79, 215, 164, 0.09);
}

html[lang="en"] .container > .tools-grid:not(.tools-grid--single):not(.shop-grid) .tool-card:nth-child(5) h2::after {
  content: "NEW";
}

/* 7) Microanimaciones discretas */
.container > .tools-grid:not(.tools-grid--single):not(.shop-grid) .tool-card,
.promo-banner__content,
.guide-section,
.reviews-section,
.content-section {
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.container > .tools-grid:not(.tools-grid--single):not(.shop-grid) .tool-card:hover {
  transform: translateY(-5px);
  border-color: rgba(123, 140, 255, 0.45);
  box-shadow: 0 20px 50px rgba(0, 6, 18, 0.3);
}

/* El contador queda legible y no flota sobre controles en móvil. */
#visitBadge {
  max-width: min(320px, calc(100vw - 28px));
  white-space: nowrap;
}

/* 8) Tablet y móvil */
@media (max-width: 900px) {
  .tools-grid--single .tool-card,
  .a4-tool-card {
    padding: 24px;
  }

  .container > .tools-grid:not(.tools-grid--single):not(.shop-grid) .tool-card {
    min-height: 220px;
  }
}

@media (max-width: 680px) {
  .header {
    padding-bottom: 10px;
  }

  .nav-toggle {
    display: flex;
  }

  .nav {
    display: none;
    width: 100%;
    max-height: min(58vh, 430px);
    margin: 8px 0 0;
    padding: 7px;
    overflow: auto;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    border-radius: 13px;
  }

  .nav.nav--open {
    display: flex;
    animation: pro-nav-in 0.18s ease both;
  }

  .nav__link {
    width: 100%;
    min-height: 40px;
    justify-content: flex-start;
    padding: 10px 12px;
    font-size: 0.82rem;
  }

  @keyframes pro-nav-in {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
  }

  .container {
    padding-inline: 14px;
  }

  .tools-grid--single .tool-card,
  .a4-tool-card {
    padding: 19px;
    border-radius: 19px;
  }

  .tools-grid--single .tool-card > h2 {
    align-items: flex-start;
    flex-direction: column;
    font-size: clamp(1.35rem, 7vw, 1.65rem);
  }

  .file-label,
  .pdf-dropzone {
    min-height: 132px;
    padding: 22px 16px;
    border-radius: 17px;
  }

  .file-label::before,
  .pdf-dropzone__icon {
    width: 44px;
    height: 44px;
    border-radius: 13px;
  }

  .file-label > span,
  .pdf-dropzone__text {
    font-size: 0.94rem;
  }

  .file-label > span::after,
  .pdf-dropzone__text::after {
    font-size: 0.7rem;
  }

  .file-list-wrapper,
  .split-mode,
  .compress-quality,
  .signature-pad {
    padding: 12px;
    border-radius: 13px;
  }

  .btn,
  .a4-button-primary,
  input,
  select,
  textarea {
    font-size: 16px;
  }

  .tools-grid--single form > .btn.primary,
  .sign-actions .btn,
  .ocr-actions .btn,
  .a4-button-primary {
    width: 100%;
  }

  .container > .tools-grid:not(.tools-grid--single):not(.shop-grid) .tool-card {
    min-height: 0;
  }

  .container > .tools-grid:not(.tools-grid--single):not(.shop-grid) .tool-card:nth-child(1) h2::after,
  .container > .tools-grid:not(.tools-grid--single):not(.shop-grid) .tool-card:nth-child(4) h2::after,
  .container > .tools-grid:not(.tools-grid--single):not(.shop-grid) .tool-card:nth-child(5) h2::after {
    top: 13px;
    right: 13px;
  }

  #visitBadge {
    position: static !important;
    inset: auto !important;
    width: fit-content !important;
    height: auto !important;
    min-height: 34px !important;
    margin: 10px auto 0 !important;
    padding: 7px 10px !important;
    gap: 5px !important;
    border-radius: 10px !important;
  }

  #visitBadge .visit-badge__label,
  #visitBadge .visit-badge__value {
    display: inline !important;
    white-space: nowrap !important;
  }
}

@media (max-width: 390px) {
  .container {
    padding-inline: 11px;
  }

  .tools-grid--single .tool-card,
  .a4-tool-card {
    padding: 16px;
  }

  .file-label,
  .pdf-dropzone {
    min-height: 124px;
    padding-inline: 12px;
  }

  .container > .tools-grid:not(.tools-grid--single):not(.shop-grid) .tool-card:nth-child(1) h2::after,
  .container > .tools-grid:not(.tools-grid--single):not(.shop-grid) .tool-card:nth-child(4) h2::after,
  .container > .tools-grid:not(.tools-grid--single):not(.shop-grid) .tool-card:nth-child(5) h2::after {
    position: static;
    display: inline-flex;
    margin-left: 8px;
    vertical-align: middle;
  }
}

@media (hover: none) {
  .file-label:hover,
  .pdf-dropzone:hover,
  .container > .tools-grid:not(.tools-grid--single):not(.shop-grid) .tool-card:hover,
  .btn.primary:hover:not(:disabled) {
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

.nav-toggle__label--en { display: none; }
html[lang="en"] .nav-toggle__label--es { display: none; }
html[lang="en"] .nav-toggle__label--en { display: inline; }
