/* ============================================================
   EDITOR CSS — Estilos del editor de carteles y preview
   ============================================================ */

/* ── Layout del editor ──────────────────────────────────── */
.editor-layout {
    display: grid;
    grid-template-columns: 420px 1fr;
    gap: 32px;
    align-items: start;
    padding: 32px 0 64px;
}

/* ── Panel izquierdo: formulario ─────────────────────────── */
.editor-panel {
    background: var(--white);
    border: 1px solid #E8ECF0;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
    position: sticky;
    top: calc(var(--header-h) + 16px);
    max-height: calc(100vh - var(--header-h) - 32px);
    display: flex;
    flex-direction: column;
}

.editor-panel-header {
    padding: 20px 24px;
    border-bottom: 1px solid #E8ECF0;
    background: var(--blue-dark);
    color: var(--white);
}
.editor-panel-header h2 { color: var(--white); font-size: 1.1rem; margin-bottom: 2px; }
.editor-panel-header p  { color: #a8c8e8; font-size: .85rem; }

.editor-panel-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.editor-panel-footer {
    padding: 16px 24px;
    border-top: 1px solid #E8ECF0;
    background: var(--gray-100);
}

/* ── Selector de formato ─────────────────────────────────── */
.formato-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 10px;
    margin-bottom: 8px;
}

.formato-option {
    position: relative;
}
.formato-option input[type=radio] {
    position: absolute;
    opacity: 0;
    width: 0; height: 0;
}
.formato-option label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 10px 6px;
    border: 2px solid var(--gray-300);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: .78rem;
    font-weight: 600;
    color: var(--gray-700);
    text-align: center;
    transition: var(--transition);
    background: var(--white);
}
.formato-option label:hover {
    border-color: var(--blue);
    color: var(--blue);
}
.formato-option input:checked + label {
    border-color: var(--blue);
    background: var(--blue-xlight);
    color: var(--blue-dark);
}

.formato-icon {
    display: block;
    background: var(--gray-300);
    border-radius: 3px;
    transition: background var(--transition);
}
.formato-option input:checked + label .formato-icon {
    background: var(--blue);
}

/* Tamaños de iconos por formato */
.formato-icon.a4v    { width: 22px; height: 31px; }
.formato-icon.a4h    { width: 31px; height: 22px; }
.formato-icon.a3v    { width: 22px; height: 31px; }
.formato-icon.a3h    { width: 31px; height: 22px; }
.formato-icon.a2v    { width: 20px; height: 28px; }
.formato-icon.ig-post  { width: 28px; height: 28px; }
.formato-icon.ig-story { width: 18px; height: 32px; }

/* ── Identidad corporativa ───────────────────────────────── */
.identidad-toggle {
    background: var(--blue-xlight);
    border: 1px solid var(--blue-light);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.identidad-toggle label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: .9rem;
    font-weight: 600;
    color: var(--blue-dark);
}
.identidad-toggle input[type=checkbox] {
    width: 18px; height: 18px;
    accent-color: var(--blue);
}

/* ── Separadores de sección ──────────────────────────────── */
.campo-section-title {
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--gray-500);
    margin: 20px 0 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid #E8ECF0;
}

/* ── Panel derecho: preview ──────────────────────────────── */
.preview-panel {
    position: sticky;
    top: calc(var(--header-h) + 16px);
}

.preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.preview-header h3 { font-size: 1rem; color: var(--gray-700); }

.preview-zoom-controls {
    display: flex;
    gap: 6px;
}
.preview-zoom-controls button {
    width: 30px; height: 30px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    background: var(--white);
    font-size: .9rem;
    color: var(--gray-700);
    display: flex; align-items: center; justify-content: center;
    transition: var(--transition);
}
.preview-zoom-controls button:hover {
    border-color: var(--blue);
    color: var(--blue);
}

.preview-wrapper {
    background: #E8ECF0;
    border-radius: var(--radius-lg);
    padding: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    overflow: hidden;
}

/* Canvas CSS del cartel — simula el diseño de la plantilla */
.poster-preview {
    background: var(--white);
    box-shadow: 0 4px 24px rgba(0,0,0,.18);
    position: relative;
    overflow: hidden;
    transform-origin: top center;
    transition: transform .2s ease;
    font-family: 'Segoe UI', sans-serif;
}

/* Zonas de la preview */
.pz-image {
    background: #C8D6E0;
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    overflow: hidden;
}
.pz-image img {
    width: 100%; height: 100%;
    object-fit: cover;
}
.pz-image .pz-placeholder {
    color: #8FA8B8;
    font-size: .75rem;
    text-align: center;
}

.pz-text {
    position: absolute;
    overflow: hidden;
    display: flex;
    align-items: flex-start;
    word-break: break-word;
    line-height: 1.25;
}

.pz-logo {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    overflow: hidden;
}
.pz-logo img {
    max-width: 100%; max-height: 100%;
    object-fit: contain;
}

.pz-watermark {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    background: var(--black);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: .6rem;
    letter-spacing: .05em;
}

/* ── Indicador de carga ──────────────────────────────────── */
.generating-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 20px;
    color: var(--white);
}
.generating-overlay.active { display: flex; }

.spinner {
    width: 48px; height: 48px;
    border: 4px solid rgba(255,255,255,.3);
    border-top-color: var(--white);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Modal de email ──────────────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 200;
    align-items: center;
    justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 40px;
    max-width: 460px;
    width: 90%;
    box-shadow: var(--shadow-lg);
    text-align: center;
}
.modal h2    { margin-bottom: 8px; }
.modal p     { margin-bottom: 24px; font-size: .95rem; }
.modal-icon  { font-size: 3rem; margin-bottom: 16px; }

/* ── Página de descarga ──────────────────────────────────── */
.download-page {
    max-width: 620px;
    margin: 60px auto;
    text-align: center;
    padding: 0 20px;
}
.download-success-icon {
    width: 80px; height: 80px;
    background: #D5F5E3;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 2.2rem;
    margin: 0 auto 24px;
}
.download-actions {
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
    margin: 32px 0;
}
.download-expiry {
    font-size: .85rem;
    color: var(--gray-500);
    background: var(--gray-100);
    border-radius: var(--radius);
    padding: 10px 20px;
    display: inline-block;
    margin-bottom: 32px;
}
.upsell-banner {
    background: linear-gradient(135deg, var(--blue-dark), var(--blue));
    color: var(--white);
    border-radius: var(--radius-lg);
    padding: 32px;
    margin-top: 40px;
}
.upsell-banner h3 { color: var(--white); margin-bottom: 8px; }
.upsell-banner p  { color: rgba(255,255,255,.85); margin-bottom: 20px; }

/* ── Selector de sector ──────────────────────────────────── */
.sector-hero {
    background: linear-gradient(135deg, var(--blue-dark) 0%, var(--blue) 100%);
    color: var(--white);
    padding: 64px 0;
    text-align: center;
}
.sector-hero h1 { color: var(--white); margin-bottom: 16px; }
.sector-hero p  { color: rgba(255,255,255,.85); font-size: 1.1rem; max-width: 520px; margin: 0 auto; }

.sector-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 24px;
    padding: 48px 0;
}
.sector-card {
    display: flex;
    flex-direction: column;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 30px;
    text-decoration: none;
    transition: transform var(--transition), box-shadow var(--transition);
    color: var(--gray-900);
}
.sector-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-4px);
    text-decoration: none;
}
.sector-card-icon { width:58px; height:58px; border-radius:var(--radius); background:var(--blue-xlight); color:var(--red); display:flex; align-items:center; justify-content:center; margin-bottom:20px; }
.sector-card h3   { margin-bottom: 8px; color:var(--black); }
.sector-card p    { font-size: .92rem; color:var(--gray-600); flex:1; }
.sector-card-link { display:inline-flex; align-items:center; gap:6px; margin-top:18px; font-weight:600; font-size:.9rem; color:var(--red); }
.sector-card-arrow { margin-top: 16px; color: var(--red); font-size: 1.2rem; }

/* ── Selector de plantilla ───────────────────────────────── */
.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 24px;
    padding: 40px 0;
}
.template-card {
    border: 2px solid #E8ECF0;
    border-radius: var(--radius-lg);
    overflow: hidden;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    color: var(--gray-900);
    display: block;
}
.template-card:hover {
    border-color: var(--blue);
    box-shadow: var(--shadow-lg);
    transform: translateY(-3px);
    text-decoration: none;
}
.template-thumb {
    aspect-ratio: 210 / 297;   /* proporción A4 vertical: la miniatura encaja sin recortes */
    background: var(--blue-xlight);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.template-thumb img { width: 100%; height: 100%; object-fit: cover; }
.template-thumb-placeholder {
    color: var(--blue-light);
    font-size: 3rem;
}
.template-info {
    padding: 16px;
}
.template-info h3 { font-size: 1rem; margin-bottom: 4px; }
.template-info p  { font-size: .82rem; color: var(--gray-500); }
.template-formats {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-top: 8px;
}

/* ── Responsive editor ───────────────────────────────────── */
@media (max-width: 900px) {
    .editor-layout {
        grid-template-columns: 1fr;
    }
    .editor-panel {
        position: static;
        max-height: none;
    }
    .preview-panel {
        position: static;
        order: -1;
    }
}

/* ============================================================
   B4 — Ajustes de marca para las vistas del editor
   ============================================================ */
.editor-hero { padding:48px 0 44px; }
.editor-hero h1 { margin:20px 0 12px; }
.editor-hero p { font-size:1.05rem; max-width:560px; }
.editor-steps-bar { padding:22px 0; }

/* Pasos sobre fondo oscuro */
.steps-onDark .step { color:rgba(255,255,255,.5); }
.steps-onDark .step.active { color:#fff; font-weight:600; }
.steps-onDark .step.done { color:rgba(255,255,255,.72); }
.steps-onDark .step.done a { color:rgba(255,255,255,.72); }
.steps-onDark .step.done a:hover { color:#fff; }
.steps-onDark .step-sep { color:rgba(255,255,255,.35); }
.steps-onDark .step.done .step-num { background:var(--success); display:inline-flex; align-items:center; justify-content:center; }
.steps-onDark .step.done .step-num svg { width:13px; height:13px; }

/* Tira de argumentos de venta */
.sell-strip { display:grid; grid-template-columns:repeat(3,1fr); gap:28px; background:var(--gray-50); border:1px solid var(--gray-200); border-radius:var(--radius-lg); padding:40px; margin-top:52px; }
.sell-item h3 { margin:14px 0 6px; color:var(--black); }
.sell-item p { font-size:.9rem; color:var(--gray-600); }

/* Página de descarga */
.download-page { max-width:620px; margin:0 auto; text-align:center; }
.download-success-icon { width:84px; height:84px; margin:0 auto 24px; border-radius:50%; background:var(--success-bg); color:var(--success); display:flex; align-items:center; justify-content:center; }
.download-lead { font-size:1.08rem; color:var(--gray-600); margin-top:8px; }
.download-expiry { display:inline-flex; align-items:center; gap:7px; margin:22px 0; padding:8px 16px; border-radius:30px; background:var(--gray-100); font-size:.9rem; color:var(--gray-700); font-weight:500; }
.download-expiry svg { color:var(--red); }
.download-actions { display:flex; gap:14px; justify-content:center; flex-wrap:wrap; margin-bottom:28px; }
.download-extra { background:var(--gray-50); border:1px solid var(--gray-200); border-radius:var(--radius-lg); padding:26px; margin-top:24px; }
.download-extra h3 { margin-bottom:16px; }
.download-extra-actions { display:flex; gap:12px; flex-wrap:wrap; justify-content:center; }

/* Banner upsell */
.upsell-banner { background:var(--black); color:#fff; border-radius:var(--radius-lg); padding:36px; margin-top:32px; text-align:center; }
.upsell-banner h3 { color:#fff; margin-bottom:10px; font-size:1.35rem; }
.upsell-banner p { color:rgba(255,255,255,.7); max-width:480px; margin:0 auto 22px; }
.upsell-btn { background:var(--red); color:#fff; border-color:var(--red); }
.upsell-btn:hover { background:var(--red-hover); border-color:var(--red-hover); color:#fff; }

@media (max-width:768px){ .sell-strip { grid-template-columns:1fr; } }

/* Pago con éxito — siguientes pasos */
.pay-next { background:var(--gray-50); border:1px solid var(--gray-200); border-radius:var(--radius-lg); padding:26px; margin:32px 0; text-align:left; }
.pay-next-title { font-weight:700; margin-bottom:14px; color:var(--black); }
.pay-next-item { display:flex; align-items:center; gap:12px; padding:10px 0; font-weight:500; color:var(--gray-800); border-bottom:1px solid var(--gray-200); }
.pay-next-item:last-child { border-bottom:none; }
.pay-next-item svg { color:var(--red); flex:none; }
.pay-next-item:hover { color:var(--red); }

/* Preview SVG real: el <svg> inyectado llena el canvas del preview */
.poster-preview > svg { width:100%; height:100%; display:block; }

/* ════════════════════════════════════════════════════════════
   OPTIMIZACIÓN MÓVIL — Editor
   Vista previa fija bajo la cabecera + barra de acción fija abajo,
   para editar y ver el resultado sin perder de vista ninguno.
   ════════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
    .editor-layout { gap: 0; padding: 8px 0 16px; }

    /* Preview anclado arriba mientras se rellena el formulario */
    .preview-panel {
        position: sticky;
        top: calc(var(--header-h) + env(safe-area-inset-top));
        z-index: 20;
        order: -1;
        background: var(--white);
        margin-bottom: 8px;
        padding-bottom: 10px;
        box-shadow: 0 12px 16px -12px rgba(13,13,13,.35);
    }
    .preview-header  { margin-bottom: 8px; }
    .preview-header h3 { font-size: .92rem; }
    .preview-wrapper {
        padding: 10px;
        min-height: 0;
        max-height: 44vh;
    }
    .preview-note { display: none; }

    /* Controles de zoom táctiles */
    .preview-zoom-controls button { width: 40px; height: 40px; font-size: 1.15rem; }

    /* Barra de acción fija con el botón "Generar cartel" siempre a mano */
    .editor-panel-footer {
        position: sticky;
        bottom: 0;
        z-index: 25;
        background: rgba(255,255,255,.97);
        -webkit-backdrop-filter: saturate(180%) blur(8px);
        backdrop-filter: saturate(180%) blur(8px);
        border-top: 1px solid var(--gray-200);
        box-shadow: 0 -10px 24px -8px rgba(13,13,13,.16);
        padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
    }
    #btn-generar { min-height: 52px; }
    .upload-area { padding: 22px; }
}

@media (max-width: 560px) {
    .editor-steps-bar { padding: 12px 0; }
    .editor-steps-bar .steps { font-size: .78rem; gap: 5px; }
    .editor-panel-body { padding: 18px 18px 8px; }
    .formato-grid { grid-template-columns: repeat(3, 1fr); }
    .preview-wrapper { max-height: 40vh; }
    .download-actions .btn,
    .download-extra-actions .btn { width: 100%; }
}

/* ════════════════════════════════════════════════════════════
   OPTIMIZACIÓN MÓVIL — Galería de plantillas (.template-grid)
   En escritorio se mantiene el auto-fill de 220px. En móvil pasa a
   2 columnas tipo galería, con menos separación y aire lateral, para
   que las plantillas no se vean a pantalla completa y pegadas al borde.
   Afecta a: ejemplos, landings de sector y de caso, selector de
   plantilla y guías.
   ════════════════════════════════════════════════════════════ */
@media (max-width: 600px) {
    .template-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
        /* margen lateral propio de la galería, ADEMÁS del del contenedor,
           para que las cards de ejemplos no se peguen a los bordes */
        padding: 20px 10px 8px;
    }
    .template-card { border-width: 1px; border-radius: var(--radius); }
    .template-info { padding: 10px 11px 12px; }
    .template-info h3 { font-size: .9rem; line-height: 1.25; }
    .template-info p  { display: none; }          /* descripción innecesaria en tarjeta pequeña */
    .template-formats { gap: 3px; margin-top: 6px; }
    .template-formats .badge { font-size: .66rem; padding: 3px 7px; }
}

/* En pantallas muy estrechas, una sola columna centrada y contenida */
@media (max-width: 340px) {
    .template-grid { grid-template-columns: 1fr; }
    .template-thumb { max-width: 260px; margin: 0 auto; width: 100%; }
}
