﻿/* Carta de Renuncia — Generator UI */
:root {
    --cru-primary: #002868;
    --cru-secondary: #00aaff;
    --cru-text: #1a1a1a;
    --cru-bg: #ffffff;
    --cru-border: #d8e1ea;
    --cru-muted: #5d6b78;
    --cru-success: #2e7d32;
    --cru-radius: 10px;
    --cru-shadow: 0 6px 24px rgba(0, 40, 104, 0.10);
}

.cru-generator {
    --cru-primary: #002868;
    --cru-secondary: #00aaff;
    font-family: 'Poppins', system-ui, -apple-system, sans-serif;
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1rem;
    color: var(--cru-text);
}

.cru-gen-grid {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: 1fr;
}
@media (min-width: 900px) {
    .cru-gen-grid { grid-template-columns: 1fr 1fr; }
}

.cru-panel {
    background: #fff;
    border: 1px solid var(--cru-border);
    border-radius: var(--cru-radius);
    box-shadow: var(--cru-shadow);
    padding: 1.5rem;
}

.cru-panel h2 {
    margin: 0 0 1rem;
    font-size: 1.25rem;
    color: var(--cru-primary);
}

.cru-form-row {
    margin-bottom: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.cru-form-row label {
    font-weight: 500;
    font-size: 0.92rem;
}
.cru-form-row input,
.cru-form-row select,
.cru-form-row textarea {
    border: 1px solid var(--cru-border);
    border-radius: 6px;
    padding: 0.55rem 0.7rem;
    font: inherit;
    font-size: 0.95rem;
    width: 100%;
    box-sizing: border-box;
    background: #fff;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.cru-form-row input:focus,
.cru-form-row select:focus,
.cru-form-row textarea:focus {
    outline: none;
    border-color: var(--cru-secondary);
    box-shadow: 0 0 0 3px rgba(0, 170, 255, 0.18);
}
.cru-form-row textarea { min-height: 80px; resize: vertical; }

.cru-form-row.cru-optional { display: none; }
.cru-form-row.cru-optional.cru-on { display: flex; }
.cru-form-row.cru-optional .cru-helper { font-size: 0.82rem; color: var(--cru-muted); }

.cru-toggle-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin: 0.5rem 0 1rem;
}
.cru-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: #f3f7fb;
    border: 1px solid var(--cru-border);
    padding: 0.4rem 0.8rem;
    border-radius: 999px;
    cursor: pointer;
    font-size: 0.88rem;
    user-select: none;
}
.cru-toggle input { accent-color: var(--cru-secondary); margin: 0; }
.cru-toggle.cru-on { background: #e6f4ff; border-color: var(--cru-secondary); color: var(--cru-primary); }

.cru-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-top: 1rem;
}
.cru-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1.1rem;
    border-radius: 6px;
    border: 1px solid transparent;
    background: var(--cru-primary);
    color: #fff;
    font-weight: 600;
    font-size: 0.92rem;
    cursor: pointer;
    text-decoration: none;
    line-height: 1.2;
    transition: opacity 0.15s, transform 0.05s;
}
.cru-btn:hover { opacity: 0.92; }
.cru-btn:active { transform: translateY(1px); }
.cru-btn-secondary { background: #fff; color: var(--cru-primary); border-color: var(--cru-primary); }
.cru-btn-pdf       { background: #b71c1c; }
.cru-btn-ghost     { background: transparent; color: var(--cru-muted); border-color: var(--cru-border); }

.cru-template-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.4rem;
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--cru-border);
    border-radius: 8px;
    padding: 0.5rem;
    background: #fafcff;
}
.cru-template-item {
    padding: 0.55rem 0.7rem;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
    font-size: 0.92rem;
    background: #fff;
}
.cru-template-item:hover { background: #f0f6ff; }
.cru-template-item.cru-selected { background: #e6f4ff; border-color: var(--cru-secondary); color: var(--cru-primary); }
.cru-template-meta { font-size: 0.78rem; color: var(--cru-muted); }

.cru-privacy {
    background: #f1f8f4;
    border: 1px solid #c9e7d0;
    color: #2e5e36;
    padding: 0.7rem 0.9rem;
    border-radius: 8px;
    margin: 0.75rem 0;
    font-size: 0.88rem;
    line-height: 1.5;
}
.cru-privacy strong { color: var(--cru-success); }
.cru-privacy.cru-broken { background: #fff4e5; border-color: #f5c98a; color: #8a4d00; }

.cru-preview {
    background: #ffffff;
    border: 1px solid var(--cru-border);
    border-radius: var(--cru-radius);
    padding: 20mm 25mm;
    font-family: 'Times New Roman', 'Rubik', 'Georgia', serif;
    color: #111;
    width: 100%;
    max-width: 210mm;
    min-height: 297mm;
    margin: 0 auto;
    box-shadow: 0 6px 30px rgba(0, 40, 104, 0.12);
    line-height: 1.65;
    font-size: 12pt;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-x: auto;
    text-align: justify;
    position: relative;
    box-sizing: border-box;
}
.cru-preview::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: linear-gradient(90deg, #00aaff 0%, #00aaff 70%, transparent 70%);
}
.cru-preview .cru-letter-title {
    display: block;
    text-align: center;
    font-weight: 700;
    font-size: 14pt;
    text-decoration: underline;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 1.2rem;
}
.cru-preview .cru-letter-date {
    display: block;
    text-align: right;
    margin: 0 0 1.2rem;
}
.cru-preview .cru-letter-body { display: block; text-align: justify; }
.cru-preview .cru-letter-sign-start {
    display: block;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    text-align: center;
    font-style: italic;
}
.cru-preview .cru-letter-sign-line {
    display: block;
    margin: 0.8rem 0 0;
    text-align: center;
    color: #111;
    letter-spacing: 1px;
    font-weight: 400;
    border-top: none;
}
.cru-preview .cru-letter-sign-name {
    display: block;
    margin: 0;
    padding: 0.1rem 0;
    text-align: center;
    font-weight: 700;
    font-size: 1.02em;
}

.cru-preview .cru-letter-sign {'
    display: block;
    text-align: center;
    margin-top: 1.5rem;
}
.cru-preview .cru-letter-sign .cru-sign-name {
    display: inline-block;
    border-top: 1px solid #111;
    padding-top: 0.25rem;
    min-width: 240px;
}
.cru-preview .cru-letter-sign .cru-sign-id {
    display: block;
    font-size: 0.92em;
    margin-top: 0.1rem;
}
@media (max-width: 480px) { .cru-preview { padding: 1.4rem; font-size: 0.94rem; } }
@media (max-width: 720px) {
    .cru-preview { padding: 1.5rem 1.2rem; min-height: 480px; }
}

.cru-toast {
    position: fixed;
    left: 50%;
    bottom: 30px;
    transform: translateX(-50%);
    background: #222;
    color: #fff;
    padding: 0.75rem 1.2rem;
    border-radius: 8px;
    font-size: 0.92rem;
    z-index: 99999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}
.cru-toast.cru-show { opacity: 1; }

.cru-field-error {
    border-color: #c62828 !important;
    background: #fff5f5 !important;
}

.cru-lang-switch {
    display: inline-flex;
    border: 1px solid var(--cru-border);
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 1rem;
}
.cru-lang-switch button {
    background: #fff;
    border: 0;
    padding: 0.4rem 0.9rem;
    font-size: 0.88rem;
    cursor: pointer;
    color: var(--cru-primary);
}
.cru-lang-switch button.cru-active { background: var(--cru-primary); color: #fff; }

/* Modo impresión del navegador — vista limpia para "Guardar como PDF" (A4) */
@page {
    size: A4;
    margin: 0;
}
@media print {
    html, body { background: #fff !important; margin: 0 !important; padding: 0 !important; }

    /* Ocultar TODO el chrome del theme y el contenido editorial de la página */
    body > header,
    body > footer,
    body > nav,
    body > .site-header,
    body > .site-footer,
    body > .content-footer,
    body > .widget-content-footer,
    body > .widget-area,
    body > .footer-breadcrumb,
    body > .go-top,
    body > .breadcrumb-trail,
    header.site-header,
    footer,
    .site-header,
    .site-header-content,
    .site-logo,
    .logo-footer,
    .content-footer,
    .widget-content-footer,
    .widget-area,
    .footer-breadcrumb,
    .breadcrumb-trail,
    .go-top,
    nav#menu,
    nav,
    .cru-consent,
    #cru-consent,
    #adminbar,
    #wpadminbar,
    article > .entry-header,
    article > .entry-content > *:not(.carta-generator) { display: none !important; visibility: hidden !important; }

    /* Mantener visible SOLO el generador, con el preview a tamaño A4 */
    .carta-generator > .cru-gen-grid {
        display: block !important;
        grid-template-columns: 1fr !important;
        gap: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    /* Ocultar SOLO el panel del formulario (no el preview) */
    .cru-panel.cru-gen-form-panel { display: none !important; }
    /* El panel del preview se mantiene y limpia */
    .cru-panel {
        border: none !important;
        box-shadow: none !important;
        border-radius: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    .cru-preview {
        border: none !important;
        box-shadow: none !important;
        border-radius: 0 !important;
        padding: 20mm 25mm !important;
        width: 210mm !important;
        max-width: 210mm !important;
        min-height: 297mm !important;
        margin: 0 auto !important;
        background: #fff !important;
        page-break-after: avoid;
        font-family: 'Times New Roman', 'Rubik', 'Georgia', serif !important;
        font-size: 12pt !important;
        line-height: 1.65 !important;
        text-align: justify !important;
        color: #111 !important;
    }
    .cru-preview::before { display: none !important; }
    /* El título del panel preview también se oculta en print (es solo UI) */
    .cru-panel > h2 { display: none !important; }

    /* El modal de vista previa, si está abierto, ocupa toda la página y solo se imprime su contenido */
    .cru-preview-modal {
        position: static !important;
        background: #fff !important;
        padding: 0 !important;
        width: 100% !important;
        height: auto !important;
    }
    .cru-preview-modal > *:not(.cru-preview) { display: none !important; }
}

/* Modal de vista previa */
.cru-preview-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 40, 104, 0.85);
    display: none;
    flex-direction: column;
    align-items: stretch;
    z-index: 100000;
    overflow-y: auto;
    padding: 0;
}
.cru-preview-modal.cru-open { display: flex; }
.cru-preview-modal-toolbar {
    position: sticky;
    top: 0;
    background: #fff;
    width: 100%;
    max-width: 210mm;
    margin: 0 auto;
    padding: 0.75rem 1rem;
    border-radius: 0;
    display: flex;
    gap: 0.5rem;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 12px rgba(0,0,0,0.18);
    z-index: 1;
}
.cru-preview-modal-toolbar button {
    background: #002868;
    color: #fff;
    border: 0;
    border-radius: 6px;
    padding: 0.55rem 1rem;
    font-weight: 600;
    cursor: pointer;
    font: inherit;
    font-size: 0.9rem;
}
.cru-preview-modal-toolbar button.cru-btn-ghost {
    background: transparent;
    color: #002868;
    border: 1px solid #002868;
}
.cru-preview-modal-toolbar button.cru-btn-pdf { background: #b71c1c; }
.cru-preview-modal-body {
    width: 100%;
    max-width: 210mm;
    margin: 0 auto;
    padding: 1rem 1rem 2rem;
}
.cru-preview-modal-body .cru-preview {
    margin: 0 !important;
    box-shadow: 0 12px 40px rgba(0,0,0,0.35);
}
@media (max-width: 720px) {
    .cru-preview-modal { padding: 0; }
    .cru-preview-modal-toolbar { padding: 0.6rem 0.75rem; }
    .cru-preview-modal-body { padding: 0.5rem 0.5rem 1.5rem; }
    .cru-preview-modal-body .cru-preview { padding: 1.2rem !important; }
}

/* Accesibilidad: foco visible */
.cru-btn:focus-visible,
.cru-toggle:focus-within {
    outline: 3px solid var(--cru-secondary);
    outline-offset: 2px;
}
