@font-face {
  font-family: "Roboto";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/roboto-latin-400-normal.woff2") format("woff2");
}

@font-face {
  font-family: "Roboto";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("fonts/roboto-latin-500-normal.woff2") format("woff2");
}

@font-face {
  font-family: "Roboto";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/roboto-latin-700-normal.woff2") format("woff2");
}

:root {
  --google-blue: #1a73e8;
  --google-blue-dark: #185abc;
  --google-blue-soft: #e8f0fe;
  --page-background: #f8f9fa;
  --surface: #ffffff;
  --drop-background: #f1f3f4;
  --text-primary: #202124;
  --text-secondary: #5f6368;
  --border: #dadce0;
  --header-background: rgba(255, 255, 255, 0.94);
  --card-border: #edf0f2;
  --chip-text: #3c4043;
  --control-hover-border: #a8c7fa;
  --success-background: #f4fbf5;
  --success-border: #b7dfc0;
  --shadow-card: 0 1px 2px rgba(60, 64, 67, 0.12), 0 1px 3px 1px rgba(60, 64, 67, 0.08);
  --shadow-raised: 0 8px 18px rgba(60, 64, 67, 0.14), 0 2px 5px rgba(60, 64, 67, 0.1);
}

body.dark-mode {
  --google-blue-soft: #193b69;
  --page-background: #202124;
  --surface: #292a2d;
  --drop-background: #303134;
  --text-primary: #e8eaed;
  --text-secondary: #bdc1c6;
  --border: #5f6368;
  --header-background: rgba(32, 33, 36, 0.94);
  --card-border: #45474b;
  --chip-text: #e8eaed;
  --control-hover-border: #8ab4f8;
  --success-background: #243b2b;
  --success-border: #4f7d5a;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.32), 0 2px 6px rgba(0, 0, 0, 0.24);
  --shadow-raised: 0 10px 24px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  overflow-x: hidden;
  background: var(--page-background);
  color: var(--text-primary);
  font-family: "Roboto", Arial, sans-serif;
  line-height: 1.5;
  transition: background-color 180ms ease, color 180ms ease;
}

a,
button,
input,
label {
  -webkit-tap-highlight-color: transparent;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
label:focus-visible {
  outline: 3px solid rgba(26, 115, 232, 0.45);
  outline-offset: 3px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

[data-ui-view][hidden] {
  display: none !important;
}

[hidden] {
  display: none !important;
}

.site-header {
  position: sticky;
  z-index: 10;
  top: 0;
  border-bottom: 1px solid var(--border);
  background: var(--header-background);
  backdrop-filter: blur(12px);
}

.navbar,
.hero,
.tools-section,
.footer-content {
  width: min(1120px, calc(100% - 48px));
  margin: 0 auto;
}

.navbar {
  display: flex;
  min-height: 72px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.theme-toggle {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text-primary);
  cursor: pointer;
  font: inherit;
  transition: background-color 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.theme-toggle:hover {
  border-color: var(--control-hover-border);
  background: var(--google-blue-soft);
  transform: translateY(-1px);
}

.theme-icon {
  font-size: 1.15rem;
}

.theme-icon-moon,
body.dark-mode .theme-icon-sun {
  display: none;
}

body.dark-mode .theme-icon-moon {
  display: inline;
}

.brand {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  gap: 10px;
  color: var(--text-primary);
  font-size: 1.22rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.brand-icon {
  width: 36px;
  height: 36px;
  color: var(--google-blue);
}

.nav-links,
.site-footer ul {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav-links a {
  display: block;
  padding: 9px 12px;
  border-radius: 20px;
  color: var(--text-secondary);
  font-size: 0.92rem;
  font-weight: 500;
  text-decoration: none;
  transition: background-color 160ms ease, color 160ms ease;
}

.nav-links a:hover {
  background: var(--google-blue-soft);
  color: var(--google-blue-dark);
}

main > section {
  scroll-margin-top: 96px;
}

.hero {
  padding: clamp(64px, 8vw, 100px) 0 72px;
  text-align: center;
}

.hero-content {
  max-width: 820px;
  margin: 0 auto 38px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--google-blue);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.11em;
}

.hero h1 {
  max-width: 780px;
  margin: 0 auto;
  font-size: clamp(2.35rem, 5vw, 4.1rem);
  font-weight: 700;
  letter-spacing: -0.045em;
  line-height: 1.1;
}

.hero-description {
  margin: 20px auto 0;
  color: var(--text-secondary);
  font-size: clamp(1rem, 2vw, 1.18rem);
}

.upload-form {
  max-width: 850px;
  margin: 0 auto;
}

.drop-zone {
  position: relative;
  display: flex;
  min-height: clamp(310px, 38vw, 380px);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  border: 2px dashed var(--google-blue);
  border-radius: 16px;
  background: var(--drop-background);
  color: var(--text-primary);
  transition: border-color 180ms ease, background-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.drop-zone:hover,
.drop-zone:focus-within,
.drop-zone.drag-over {
  border-color: var(--google-blue-dark);
  background: var(--google-blue-soft);
  box-shadow: 0 0 0 4px rgba(26, 115, 232, 0.13);
}

.drop-zone.drag-over {
  transform: scale(1.01);
}

.upload-icon {
  width: clamp(64px, 9vw, 84px);
  height: clamp(64px, 9vw, 84px);
  margin-bottom: 16px;
  color: var(--google-blue);
}

.drop-zone h2 {
  margin: 0;
  font-size: clamp(1.3rem, 2.8vw, 1.7rem);
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.drop-zone > p {
  margin: 8px 0 22px;
  color: var(--text-secondary);
}

.primary-button {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  padding: 0 22px;
  border: 0;
  border-radius: 7px;
  background: var(--google-blue);
  box-shadow: 0 2px 6px rgba(26, 115, 232, 0.3);
  color: #ffffff;
  cursor: pointer;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  text-decoration: none;
  transition: background-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.primary-button:hover {
  background: var(--google-blue-dark);
  box-shadow: 0 2px 5px rgba(26, 115, 232, 0.32);
  transform: translateY(-1px);
}

.primary-button:active {
  transform: translateY(1px);
}

.drop-zone small {
  margin-top: 16px;
  color: var(--text-secondary);
  font-size: 0.78rem;
}

.file-error {
  margin: 14px 0 0 !important;
  color: #b3261e !important;
  font-size: 0.9rem;
  font-weight: 500;
}

.options-view {
  max-width: 850px;
  margin: 0 auto;
  padding: clamp(24px, 5vw, 42px);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-card);
  text-align: left;
}

.options-heading {
  margin-bottom: 24px;
}

.options-heading h2 {
  margin: 0;
  font-size: clamp(1.5rem, 3vw, 2rem);
  letter-spacing: -0.025em;
  line-height: 1.2;
}

.file-details {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 26px;
}

.file-details div {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--drop-background);
}

.file-details dt {
  margin-bottom: 4px;
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.file-details dd {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--text-primary);
  font-size: 0.92rem;
  font-weight: 500;
}

.tool-selector {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  border: 0;
}

.tool-selector legend {
  width: 100%;
  margin-bottom: 12px;
  color: var(--text-primary);
  font-weight: 700;
}

.option-card {
  position: relative;
  cursor: pointer;
}

.option-card input {
  position: absolute;
  opacity: 0;
}

.option-card > span {
  display: grid;
  min-height: 122px;
  grid-template-columns: auto 1fr;
  column-gap: 12px;
  align-content: center;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--page-background);
  transition: border-color 160ms ease, background-color 160ms ease, box-shadow 160ms ease;
}

.option-card input:checked + span {
  border-color: var(--google-blue);
  background: var(--google-blue-soft);
  box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.16);
}

.option-card input:focus-visible + span {
  outline: 3px solid rgba(26, 115, 232, 0.45);
  outline-offset: 2px;
}

.option-card b {
  grid-row: span 2;
  font-size: 1.55rem;
}

.option-card strong,
.option-card small {
  display: block;
}

.option-card strong {
  color: var(--text-primary);
  font-size: 1rem;
}

.option-card small {
  margin-top: 4px;
  color: var(--text-secondary);
  font-size: 0.81rem;
  line-height: 1.35;
}

.tool-settings {
  display: grid;
  gap: 8px;
  margin-top: 20px;
  padding: 18px;
  border-radius: 10px;
  background: var(--drop-background);
  color: var(--text-secondary);
}

.tool-settings label {
  color: var(--text-primary);
  font-weight: 700;
}

.tool-settings input,
.tool-settings select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text-primary);
  font: inherit;
}

.tool-settings p {
  margin: 0;
}

.option-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 26px;
}

.image-downloads {
  display: grid;
  width: min(100%, 560px);
  gap: 8px;
  margin-top: 18px;
}

.image-download-link {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--google-blue);
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
}

.image-download-link:hover {
  border-color: var(--control-hover-border);
  background: var(--google-blue-soft);
}

.status-panel {
  display: flex;
  min-height: clamp(310px, 38vw, 380px);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.status-panel h2 {
  margin: 20px 0 8px;
  font-size: clamp(1.35rem, 2.8vw, 1.7rem);
  line-height: 1.25;
}

.status-panel > p {
  margin: 0;
  color: var(--text-secondary);
}

.loading-spinner {
  width: 58px;
  height: 58px;
  border: 6px solid var(--google-blue-soft);
  border-top-color: var(--google-blue);
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
}

.success-panel {
  border-color: var(--success-border);
  background: var(--success-background);
}

.success-icon {
  display: grid;
  width: 68px;
  height: 68px;
  place-items: center;
  border-radius: 50%;
  background: #1e8e3e;
  color: #ffffff;
  font-size: 2.6rem;
  font-weight: 700;
  line-height: 1;
}

.success-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 26px;
}

.secondary-button {
  min-height: 46px;
  padding: 0 20px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--google-blue);
  cursor: pointer;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  transition: background-color 160ms ease, border-color 160ms ease;
}

.secondary-button:hover {
  border-color: var(--control-hover-border);
  background: var(--google-blue-soft);
}

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

.quick-tools {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 24px;
}

.quick-tools a {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  gap: 7px;
  padding: 0 15px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 1px 1px rgba(60, 64, 67, 0.06);
  color: var(--chip-text);
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  transition: border-color 160ms ease, background-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.quick-tools a:hover {
  border-color: var(--control-hover-border);
  background: var(--google-blue-soft);
  box-shadow: 0 2px 5px rgba(60, 64, 67, 0.12);
  color: var(--google-blue-dark);
  transform: translateY(-1px);
}

.tools-section {
  padding: 72px 0 112px;
}

.legal-page {
  max-width: 860px;
  padding-top: 64px;
}

.legal-page .section-heading h1 {
  margin: 0;
  font-size: clamp(1.9rem, 4vw, 2.65rem);
  letter-spacing: -0.03em;
  line-height: 1.18;
}

.legal-content {
  padding: clamp(24px, 5vw, 44px);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.legal-content h2 {
  margin: 32px 0 10px;
  font-size: 1.2rem;
  line-height: 1.3;
}

.legal-content h2:first-of-type {
  margin-top: 28px;
}

.legal-content p {
  margin: 0 0 14px;
  color: var(--text-secondary);
}

.legal-content .back-link {
  color: var(--google-blue);
  font-weight: 700;
  text-decoration: none;
}

.legal-content .back-link:hover {
  color: var(--google-blue-dark);
  text-decoration: underline;
}

.section-heading {
  max-width: 600px;
  margin-bottom: 30px;
}

.section-heading h2 {
  margin: 0;
  font-size: clamp(1.7rem, 3vw, 2.35rem);
  letter-spacing: -0.03em;
  line-height: 1.18;
}

.section-heading > p:last-child {
  margin: 10px 0 0;
  color: var(--text-secondary);
}

.tools-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 20px;
}

.tool-card {
  display: flex;
  min-height: 240px;
  flex-direction: column;
  padding: 26px;
  border: 1px solid var(--card-border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-card);
  transition: box-shadow 180ms ease, transform 180ms ease;
}

.tool-card:hover {
  box-shadow: var(--shadow-raised);
  transform: translateY(-4px);
}

.tool-icon {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  margin-bottom: 18px;
  border-radius: 12px;
  background: var(--google-blue-soft);
  font-size: 1.4rem;
}

.tool-card h3 {
  margin: 0;
  font-size: 1.18rem;
  line-height: 1.3;
}

.tool-card p {
  margin: 9px 0 22px;
  color: var(--text-secondary);
  font-size: 0.93rem;
}

.tool-card a {
  margin-top: auto;
  color: var(--google-blue);
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
}

.tool-card a:hover {
  color: var(--google-blue-dark);
  text-decoration: underline;
}

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.footer-content {
  display: flex;
  min-height: 96px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  color: var(--text-secondary);
  font-size: 0.88rem;
}

.footer-content p {
  margin: 0;
}

.site-footer a {
  display: inline-block;
  padding: 8px;
  border-radius: 5px;
  color: var(--text-secondary);
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--google-blue-dark);
  text-decoration: underline;
}

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

@media (max-width: 600px) {
  .navbar,
  .hero,
  .tools-section,
  .footer-content {
    width: min(100% - 32px, 1120px);
  }

  .navbar {
    min-height: 64px;
    gap: 10px;
  }

  .nav-actions {
    gap: 4px;
  }

  .theme-toggle {
    width: 36px;
    height: 36px;
  }

  .brand {
    font-size: 1.05rem;
  }

  .brand-icon {
    width: 32px;
    height: 32px;
  }

  .nav-links {
    gap: 0;
  }

  .nav-links a {
    padding: 8px;
    font-size: 0.79rem;
  }

  .hero {
    padding: 54px 0 56px;
  }

  .hero-content {
    margin-bottom: 30px;
  }

  .drop-zone {
    min-height: 320px;
    padding: 36px 18px;
  }

  .status-panel {
    min-height: 320px;
    padding: 36px 18px;
  }

  .options-view {
    padding: 22px 16px;
  }

  .file-details,
  .tool-selector {
    grid-template-columns: 1fr;
  }

  .option-actions {
    flex-direction: column;
  }

  .option-actions > * {
    width: 100%;
  }

  .drop-zone h2 {
    max-width: 280px;
  }

  .drop-zone > p {
    max-width: 270px;
    margin-bottom: 20px;
  }

  .quick-tools {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .quick-tools a {
    justify-content: center;
    padding: 0 10px;
    font-size: 0.84rem;
  }

  .success-actions {
    width: 100%;
    flex-direction: column;
  }

  .success-actions > * {
    width: 100%;
  }

  .tools-section {
    padding: 56px 0 72px;
  }

  .tools-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .tool-card {
    min-height: 0;
    padding: 22px;
  }

  .footer-content {
    min-height: 0;
    flex-direction: column;
    align-items: flex-start;
    padding: 28px 0;
  }

  .site-footer ul {
    flex-wrap: wrap;
  }
}

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

/* Selector de archivo (segundo PDF para unir) */
.tool-settings input[type="file"] {
  padding: 8px;
  border: 1.5px dashed var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.9rem;
  transition: border-color 160ms ease, background-color 160ms ease;
}

.tool-settings input[type="file"]:hover {
  border-color: var(--google-blue);
  background: var(--google-blue-soft);
}

.tool-settings input[type="file"]::file-selector-button {
  margin-right: 14px;
  padding: 9px 18px;
  border: 0;
  border-radius: 7px;
  background: var(--google-blue);
  color: #ffffff;
  cursor: pointer;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  transition: background-color 160ms ease;
}

.tool-settings input[type="file"]::file-selector-button:hover {
  background: var(--google-blue-dark);
}

/* ---------- Selector de idiomas (i18n) ---------- */
.lang-switcher { position: relative; }

.lang-button {
  display: inline-flex;
  height: 40px;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  color: var(--text-primary);
  cursor: pointer;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 500;
  transition: background-color 160ms ease, border-color 160ms ease;
}

.lang-button:hover,
.lang-switcher.open .lang-button {
  border-color: var(--control-hover-border);
  background: var(--google-blue-soft);
}

.lang-button svg { width: 20px; height: 20px; flex-shrink: 0; }
.lang-button .lang-chevron { width: 16px; height: 16px; transition: transform 160ms ease; }
.lang-switcher.open .lang-chevron { transform: rotate(180deg); }

.lang-menu {
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 30;
  display: none;
  min-width: 170px;
  margin: 6px 0 0;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-raised);
  list-style: none;
}

/* Puente invisible para que el menú no se cierre al mover el cursor */
.lang-menu::before { position: absolute; top: -8px; right: 0; left: 0; height: 8px; content: ""; }

.lang-switcher.open .lang-menu { display: block; }

@media (hover: hover) {
  .lang-switcher:hover .lang-menu { display: block; }
}

.lang-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--text-primary);
  cursor: pointer;
  font-size: 0.92rem;
}

.lang-option:hover,
.lang-option:focus-visible {
  background: var(--google-blue-soft);
  outline: none;
}

.lang-option[aria-selected="true"] { color: var(--google-blue); font-weight: 500; }
.lang-option[aria-selected="true"]::after { content: "\2713"; }

@media (max-width: 600px) {
  .lang-label, .lang-button .lang-chevron { display: none; }
  .lang-button { width: 40px; justify-content: center; padding: 0; border-radius: 50%; }
}
