* { box-sizing: border-box; }
body { font-family: Arial, sans-serif; background-color: #e9ecef; padding: 30px; margin: 0; }
.contenedor { display: flex; gap: 30px; max-width: 1200px; margin: 0 auto; justify-content: center; align-items: flex-start; }

.formulario { background: white; padding: 30px; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); flex: 1; max-width: 400px; position: sticky; top: 30px; width: 100%; }
.header-form { display: flex; align-items: center; justify-content: space-between; border-bottom: 2px solid #004085; padding-bottom: 15px; margin-bottom: 20px; }
.header-form img { height: 55px; object-fit: contain; }
.header-form-text { text-align: center; flex-grow: 1; padding: 0 10px; }
.header-form-text h2 { margin: 0; font-size: 16px; color: #004085; text-transform: uppercase; }
.header-form-text p { margin: 3px 0 0; font-size: 12px; color: #555; font-weight: bold; }
.campo { margin-bottom: 20px; }
label { display: block; font-weight: bold; margin-bottom: 8px; color: #333; }
input[type="text"], input[type="date"], input[type="password"], textarea { width: 100%; padding: 10px; border: 1px solid #ced4da; border-radius: 4px; font-family: inherit; }
button { background: #0d6efd; color: white; padding: 14px; width: 100%; border: none; cursor: pointer; border-radius: 4px; font-size: 16px; font-weight: bold; transition: background 0.3s; }
button:hover { background: #0b5ed7; }
button:disabled { background: #198754; cursor: default; }

.acciones-extra { display: none; flex-direction: column; gap: 10px; margin-top: 15px; }
.btn-editar { background: #ffc107; color: #000; }
.btn-editar:hover { background: #e0a800; }
.btn-compartir { background: #17a2b8; }
.btn-compartir:hover { background: #138496; }
.btn-imprimir { background: #6c757d; }
.btn-imprimir:hover { background: #5a6268; }

.vista-previa-contenedor { flex: 1.5; max-width: 794px; width: 100%; margin: 0 auto; }
.panel-coordinador { background: white; padding: 20px; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); margin-bottom: 20px; text-align: center; border-left: 5px solid #28a745; }
.panel-coordinador h3 { margin-top: 0; color: #28a745; }
.btn-aprobar { background: #28a745; font-size: 18px; padding: 15px; }
.btn-aprobar:hover { background: #218838; }

.vista-previa { background: white; padding: 50px 60px; border-radius: 2px; box-shadow: 0 10px 25px rgba(0,0,0,0.15); color: #212529; width: 100%; min-height: 1100px; margin: 0 auto; }
.header-institucional { display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid #333; padding-bottom: 15px; margin-bottom: 20px; }
/* LOGOS MÁS GRANDES */
.header-institucional img { height: 85px; object-fit: contain; } 
.header-titulos { text-align: center; flex-grow: 1; padding: 0 10px; }
.header-titulos h1 { margin: 0; font-size: 21px; color: #000; text-transform: uppercase; }
.header-titulos h2 { margin: 5px 0 0 0; font-size: 15px; color: #555; text-transform: uppercase; }
.fecha-doc { text-align: right; color: #555; font-size: 14px; margin-bottom: 20px; }
.datos-pdf { font-size: 14px; line-height: 1.7; text-align: justify; }
.caja-material { background: #f8f9fa; border: 1px solid #dee2e6; padding: 15px; margin: 15px 0; font-family: "Courier New", Courier, monospace; font-weight: bold; }
.clausula-pdf { margin-top: 25px; text-align: justify; }

.contenedor-firmas { display: flex; justify-content: space-between; margin-top: 60px; gap: 20px; }
.firma-digital { border: 2px solid #cc0000; padding: 6px; display: flex; align-items: center; background: white; width: 48%; border-radius: 4px; }
.firma-logo { width: 45px; text-align: center; border-right: 1px solid #cc0000; padding-right: 8px; margin-right: 8px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.firma-logo img { max-width: 100%; height: auto; display: block; }
.firma-logo p { margin: 4px 0 0 0; font-size: 8px; font-weight: bold; color: #cc0000; }
.firma-datos { font-size: 10px; line-height: 1.4; color: #000; word-wrap: break-word; }

.loader-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(255,255,255,0.85); justify-content: center; align-items: center; flex-direction: column; z-index: 9999; }
.spinner { border: 6px solid #f3f3f3; border-top: 6px solid #0d6efd; border-radius: 50%; width: 60px; height: 60px; animation: spin 1s linear infinite; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
.loader-text { margin-top: 20px; font-size: 18px; font-weight: bold; color: #333; }
.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); justify-content: center; align-items: center; z-index: 1000; }
.modal-content { background: white; padding: 30px; border-radius: 8px; width: 90%; max-width: 400px; text-align: center; }
.url-box { background: #f1f3f5; padding: 10px; border: 1px solid #ced4da; border-radius: 4px; word-break: break-all; margin: 15px 0; font-family: monospace; color: #0d6efd; }
.btn-copiar { background: #28a745; margin-bottom: 10px; }
.btn-cerrar { background: #dc3545; }
/* Agrega esto debajo de tus estilos de botones actuales (.btn-copiar, .btn-cerrar, etc) */
/* ESTILOS DEL BOTÓN ENVIAR NATIVO (Oculto en PC por defecto) */
/* BOTÓN WARNING (OCULTO EN PC) */
.btn-compartir-nativo { 
    display: none !important; /* 🚨 Fuerza absoluta para ocultarlo en PC */
    flex: 1;
    background: #ffc107; /* Color Warning (Amarillo/Ámbar) */
    color: #000; /* Letra negra para que se lea bien con el amarillo */
    padding: 14px; 
    border: none; 
    cursor: pointer; 
    border-radius: 4px; 
    font-size: 16px; 
    font-weight: bold; 
    transition: background 0.3s; 
}

.btn-compartir-nativo:hover { 
    background: #e0a800; /* Warning un poco más oscuro al pasar el dedo/mouse */
}
/* ================= RESPONSIVE DESIGN (MÓVILES) ================= */
@media (max-width: 800px) {
    body { padding: 15px; }
    .contenedor { flex-direction: column; align-items: center; }
    
    .formulario, .vista-previa-contenedor { width: 100%; max-width: 100%; }
    
    /* 🚨 ESTA ES LA MAGIA QUE ARREGLA EL SCROLL 🚨 */
    .formulario { 
        position: relative; /* Le quita el modo "pegajoso" */
        top: 0; 
    }

    .vista-previa { padding: 30px 20px; min-height: auto; }
    .header-institucional { flex-direction: row; justify-content: space-between; align-items: center; gap: 5px; }
    .header-institucional img { height: 50px; } 
    .header-titulos h1 { font-size: 14px; }
    .header-titulos h2 { font-size: 11px; }
    .contenedor-firmas { flex-direction: column; gap: 15px; }
    .firma-digital { width: 100%; }

    /* Mostrar el botón naranja solo en celulares */
    .btn-compartir-nativo { 
        display: block !important; 
    }
}

/* ================= IMPRESIÓN (A4 CENTRADO) ================= */
@media print {
    @page { size: A4 portrait; margin: 2cm; }
    body { background: white; padding: 0; margin: 0; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .formulario, .panel-coordinador, #loaderGlobal, .modal-overlay, #accionesExtra { display: none !important; }
    .contenedor, .vista-previa-contenedor { display: block !important; width: 100% !important; max-width: 100% !important; margin: 0 !important; padding: 0 !important; }
    .vista-previa { box-shadow: none !important; border: none !important; padding: 0 !important; margin: 0 !important; width: 100% !important; max-width: 100% !important; min-height: auto !important; color: #000 !important; }
    .caja-material, .clausula-pdf { page-break-inside: avoid; break-inside: avoid; }
    
    /* FIX: OBLIGAMOS A QUE LAS FIRMAS ESTÉN UNA AL LADO DE OTRA AL IMPRIMIR */
    .contenedor-firmas { 
        display: flex !important; 
        flex-direction: row !important; 
        justify-content: space-between !important; 
        gap: 20px !important; 
        page-break-inside: avoid; 
    }
    .firma-digital { 
        width: 48% !important; 
        display: flex !important; 
        flex-direction: row !important; 
    }
}