:root {
  --ink: #1c2b33;
  --muted: #5a6b74;
  --paper: #f4f7f5;
  --surface: #ffffff;
  --line: #d7e0e4;
  --accent: #0e6b6d;
  --accent-2: #c46b3a;
  --shadow: 0 18px 50px rgba(28, 43, 51, 0.12);
  --radius: 18px;
  --font-display: "Fraunces", "Times New Roman", serif;
  --font-body: "Manrope", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 18%, rgba(14, 107, 109, 0.14), transparent 38%),
    radial-gradient(circle at 88% 0%, rgba(196, 107, 58, 0.16), transparent 32%),
    linear-gradient(160deg, #eef4f1 0%, #f7f3ee 48%, #e9f0f2 100%);
}

a { color: inherit; text-decoration: none; }

.shell {
  width: min(1200px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0 3rem;
}

.shell-editor {
  width: min(1920px, calc(100% - 0.5rem));
  margin: 0 auto;
  padding: 0.35rem 0.35rem 0.4rem;
  height: 100vh;
  max-height: 100vh;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  overflow: hidden;
}

.shell-editor .topbar {
  flex-shrink: 0;
  margin-bottom: 0.35rem;
}

.shell-editor .topbar h1 {
  font-size: 1.2rem;
}

.editor-page {
  height: 100%;
  overflow: hidden;
}

html:has(.editor-page) {
  height: 100%;
  overflow: hidden;
}

.editor-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
  align-items: stretch;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.editor-side {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  padding: 0.65rem;
}

/* Logo NusaCV como marca de agua solo en la zona de captura de datos */
.editor-side::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("../../Fondo.png");
  background-repeat: no-repeat;
  background-position: center;
  background-size: min(70%, 360px);
  opacity: 0.3;
  pointer-events: none;
  z-index: 0;
}

.editor-side .tabs,
.editor-side .editor-scroll {
  position: relative;
  z-index: 1;
}

.editor-side .tabs {
  flex-shrink: 0;
  margin-bottom: 0.55rem;
}

.editor-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 0.15rem 0.85rem 0;
  overscroll-behavior: contain;
}

.alias-field {
  background: color-mix(in srgb, var(--accent) 8%, white);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--line));
  border-radius: 8px;
  padding: 0.35rem 0.45rem;
  margin-bottom: 0.3rem;
}

.alias-field label {
  font-weight: 600;
  color: var(--accent);
}

.preview-pane {
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 0.45rem;
  overflow: hidden;
}

.preview-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
  flex-shrink: 0;
}

.preview-stage {
  flex: 1;
  min-height: 0;
  background: linear-gradient(180deg, #d7dde2 0%, #c5ced4 100%);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 0.4rem;
}

/* Modo "ancho completo": llena el ancho y permite scroll vertical */
.preview-stage.mode-width {
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.6rem 0.4rem;
}

.a4-sheet {
  width: 794px;   /* ~A4 at 96dpi */
  height: 1123px; /* ~A4 at 96dpi; JS ajusta si el contenido supera 1 hoja */
  background: #fff;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.22);
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

#previewFrame {
  width: 794px;
  height: 1123px;
  border: 0;
  background: white;
  display: block;
  transform-origin: top left;
}

.view-toggle {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  background: #fff;
}

.view-btn {
  appearance: none;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 0.78rem;
  padding: 0.32rem 0.7rem;
  cursor: pointer;
  color: var(--muted);
}

.view-btn.active {
  background: var(--ink);
  color: #fff;
}

.preview-hint {
  margin: 0.3rem 0 0;
  font-size: 0.72rem;
  color: var(--muted);
  flex-shrink: 0;
}

.auth-shell {
  position: relative;
  min-height: calc(100vh - 2rem);
  display: flex;
  align-items: center;
  justify-content: center;
}

.lang-switch {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  background: #fff;
  flex-shrink: 0;
}

.lang-switch--fixed {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 2000;
  box-shadow: 0 10px 28px rgba(28, 43, 51, 0.16);
}

/* En el editor el switcher va dentro de la barra (no fijo) para no tapar botones */
.editor-page .lang-switch--fixed {
  position: static;
  top: auto;
  right: auto;
  box-shadow: none;
  align-self: center;
}

.lang-switch__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.5rem;
  padding: 0.42rem 0.72rem;
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-decoration: none;
  border: 0;
  background: transparent;
  transition: background 0.15s ease, color 0.15s ease;
}

.lang-switch__btn:hover {
  color: var(--ink);
  background: rgba(14, 107, 109, 0.08);
  transform: none;
}

.lang-switch__btn.is-active {
  color: #fff;
  background: var(--accent);
}

.auth-panel {
  width: min(420px, 100%);
}

.auth-links {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1rem;
  font-size: 0.9rem;
  color: var(--accent);
}

.auth-links a:hover { text-decoration: underline; }

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.brand-lockup .brand {
  margin: 0;
}

.brand-logo {
  display: block;
  object-fit: contain;
  flex-shrink: 0;
}

.brand-logo--auth {
  height: clamp(3.2rem, 8vw, 5rem);
  width: auto;
}

.brand-logo--topbar {
  height: 2.4rem;
  width: auto;
}

.brand-logo--editor {
  height: 1.65rem;
  width: auto;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.topbar-brand h1 {
  margin: 0;
}

.brand {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 5vw, 4.2rem);
  line-height: 0.95;
  margin: 0;
  letter-spacing: -0.03em;
}

.tagline {
  color: var(--muted);
  margin: 0.6rem 0 0;
  max-width: 36ch;
}

.panel {
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
  border: 1px solid color-mix(in srgb, var(--line) 80%, white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}

.lang-hero {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 1.5rem;
  align-items: stretch;
  min-height: calc(100vh - 4rem);
}

.lang-visual {
  border-radius: var(--radius);
  background:
    linear-gradient(145deg, rgba(14, 107, 109, 0.88), rgba(28, 43, 51, 0.72)),
    repeating-linear-gradient(
      -18deg,
      transparent,
      transparent 12px,
      rgba(255, 255, 255, 0.04) 12px,
      rgba(255, 255, 255, 0.04) 13px
    );
  color: white;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  position: relative;
  overflow: hidden;
}

.lang-visual::after {
  content: "";
  position: absolute;
  inset: auto -10% -20% 40%;
  height: 70%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.22), transparent 60%);
  pointer-events: none;
}

.lang-visual p {
  position: relative;
  z-index: 1;
  font-size: 1.15rem;
  max-width: 28ch;
}

.lang-options {
  display: grid;
  gap: 0.85rem;
  margin-top: 1.5rem;
}

.lang-btn, .btn, .icon-btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 999px;
  font: inherit;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.lang-btn {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.15rem;
  background: var(--surface);
  border-color: var(--line);
}

.lang-btn:hover, .btn:hover, .icon-btn:hover { transform: translateY(-1px); }

.lang-btn strong { font-size: 1.05rem; }
.lang-btn span { color: var(--muted); font-size: 0.9rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.7rem 1.15rem;
  background: var(--accent);
  color: white;
}

.btn.secondary {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}

.btn.danger { background: #9b3b3b; }
.btn:disabled { opacity: 0.6; cursor: wait; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.topbar h1 {
  font-family: var(--font-display);
  font-size: 1.8rem;
  margin: 0;
}

.actions { display: flex; gap: 0.55rem; flex-wrap: wrap; }

.cv-list {
  display: grid;
  gap: 0.75rem;
}

.cv-card {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: 1rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}

.cv-card h3 { margin: 0 0 0.2rem; font-size: 1.05rem; }
.cv-card p { margin: 0; color: var(--muted); font-size: 0.9rem; }

.empty {
  color: var(--muted);
  padding: 1.5rem 0.5rem;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.tab {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 0.45rem 0.8rem;
  font-size: 0.84rem;
  cursor: pointer;
}

.tab.active {
  background: var(--ink);
  color: white;
  border-color: var(--ink);
}

.fields { display: grid; gap: 0.3rem; }

.field label {
  display: block;
  font-size: 0.74rem;
  color: var(--muted);
  margin-bottom: 0.1rem;
  line-height: 1.15;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.32rem 0.5rem;
  font: inherit;
  font-size: 0.9rem;
  background: #fff;
}

.field textarea { min-height: 56px; resize: vertical; }

.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
}

.repeat-card {
  border: 1px dashed color-mix(in srgb, var(--accent) 35%, var(--line));
  border-radius: 10px;
  padding: 0.4rem 0.45rem;
  background: color-mix(in srgb, var(--surface) 70%, #eef7f6);
  display: grid;
  gap: 0.28rem;
  margin-bottom: 0.3rem;
}

.repeat-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.repeat-head strong { font-size: 0.92rem; }

.chip {
  font-size: 0.75rem;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, white);
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.92rem;
}

.section-style-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.2rem 0;
}

.section-style-name {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.section-style-inputs {
  display: flex;
  gap: 0.35rem;
  flex-shrink: 0;
}

.section-style-inputs input {
  width: 4.5rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.28rem 0.4rem;
  font: inherit;
  font-size: 0.85rem;
  background: #fff;
}

.template-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.55rem;
}

.templates-subtitle {
  margin: 1.1rem 0 0.55rem;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--ink);
}

.color-theme-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.45rem;
  margin-bottom: 0.25rem;
}

.color-theme-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  border: 2px solid transparent;
  border-radius: 10px;
  padding: 0.35rem 0.2rem 0.45rem;
  background: #fff;
  cursor: pointer;
  font-size: 0.68rem;
  color: var(--muted);
  line-height: 1.15;
  text-align: center;
}

.color-theme-option.active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.color-theme-swatch {
  width: 100%;
  height: 22px;
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.template-option {
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.75rem;
  background: #fff;
  cursor: pointer;
}

.template-option.active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.template-option strong { display: block; margin-bottom: 0.2rem; }
.template-option span { color: var(--muted); font-size: 0.8rem; }

.photo-box {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.photo-box img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: #eee;
}

.crop-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(16, 24, 32, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.crop-dialog {
  width: min(560px, 100%);
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
  padding: 1rem 1.1rem 1.1rem;
}

.crop-dialog h3 {
  margin: 0 0 0.25rem;
  font-size: 1.1rem;
}

.crop-hint {
  margin: 0 0 0.75rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.crop-stage {
  width: 100%;
  height: min(52vh, 420px);
  background: #1a2228;
  border-radius: 10px;
  overflow: hidden;
}

.crop-stage img {
  display: block;
  max-width: 100%;
}

.crop-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.85rem;
}

.status {
  font-size: 0.85rem;
  color: var(--muted);
}

.status.ok { color: var(--accent); }
.status.err { color: #9b3b3b; }

.hidden { display: none !important; }

@media (max-width: 960px) {
  .lang-hero,
  .row-2 {
    grid-template-columns: 1fr;
  }
  .shell-editor {
    height: auto;
    max-height: none;
    overflow: visible;
  }
  .editor-page {
    overflow: auto;
  }
  .editor-layout {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }
  .editor-side {
    height: auto;
    max-height: min(70vh, 720px);
    overflow: hidden;
  }
  .editor-scroll {
    max-height: none;
  }
  .preview-pane {
    height: auto;
    max-height: none;
  }
  .preview-stage {
    min-height: 70vh;
  }
  .cv-card {
    flex-direction: column;
    align-items: flex-start;
  }
}
