* { box-sizing: border-box; }
body { 
    margin: 0; 
    font-family: Arial, sans-serif; 
    background-color: #e0e0e0; 
    padding-top: 70px; /* Espacio para la barra fija */
}

.app-container { 
    display: flex; 
    min-height: 100vh;
}

.form-panel {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    background: #fff;
    padding: 15px 20px 30px;
    overflow-y: auto;
}

/* BARRA DE BOTONES FIJA */
.action-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: #1a237e;
    padding: 10px 15px;
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    flex-wrap: wrap;
}

.action-bar .btn-export,
.action-bar .btn-preview {
    flex: 1;
    min-width: 120px;
    max-width: 220px;
    padding: 10px 12px;
    border: none;
    border-radius: 4px;
    font-weight: bold;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.action-bar .btn-export {
    background: #2e7d32;
    color: white;
}

.action-bar .btn-export:hover {
    background: #1b5e20;
    transform: scale(1.02);
}

.action-bar .btn-preview {
    background: #0288d1;
    color: white;
}

.action-bar .btn-preview:hover {
    background: #01579b;
    transform: scale(1.02);
}

/* Botones inferiores (respaldo) */
.action-bar-bottom {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

.action-bar-bottom .btn-export,
.action-bar-bottom .btn-preview {
    flex: 1;
    min-width: 120px;
    padding: 12px 16px;
    border: none;
    border-radius: 4px;
    font-weight: bold;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.action-bar-bottom .btn-export {
    background: #2e7d32;
    color: white;
}

.action-bar-bottom .btn-preview {
    background: #0288d1;
    color: white;
}

.form-panel h2 { 
    font-size: 18px; 
    margin-top: 10px; 
    color: #111; 
    border-bottom: 2px solid #333; 
    padding-bottom: 5px; 
}

fieldset { 
    border: 1px solid #ccc; 
    border-radius: 4px; 
    margin-bottom: 12px; 
    padding: 10px; 
}

legend { 
    font-weight: bold; 
    font-size: 13px; 
    color: #333; 
    padding: 0 8px;
}

label { 
    display: block; 
    font-size: 11px; 
    font-weight: bold; 
    margin-top: 6px; 
}

input, textarea, select { 
    width: 100%; 
    padding: 6px 8px; 
    font-size: 13px; 
    border: 1px solid #aaa; 
    border-radius: 3px; 
    margin-top: 2px; 
    background: #fafafa;
}

input:focus, textarea:focus, select:focus {
    border-color: #1a237e;
    outline: none;
    background: #fff;
}

.grid-2 { 
    display: grid; 
    grid-template-columns: 1fr 1fr; 
    gap: 8px; 
}

.dynamic-row { 
    display: flex; 
    gap: 4px; 
    margin-bottom: 6px; 
    align-items: center; 
    flex-wrap: wrap;
}

.btn-del { 
    background: #d32f2f; 
    color: white; 
    border: none; 
    border-radius: 3px; 
    cursor: pointer; 
    padding: 4px 10px; 
    font-weight: bold; 
    font-size: 12px;
}

.btn-del:hover {
    background: #b71c1c;
}

.btn-add { 
    background: #1976d2; 
    color: white; 
    border: none; 
    border-radius: 3px; 
    cursor: pointer; 
    padding: 6px 12px; 
    font-size: 12px; 
    margin-top: 5px; 
    font-weight: bold; 
}

.btn-add:hover {
    background: #0d47a1;
}

.btn-expand { 
    background: #0288d1; 
    color: white; 
    border: none; 
    border-radius: 3px; 
    cursor: pointer; 
    padding: 4px 8px; 
    font-weight: bold; 
    font-size: 10px; 
}

.btn-expand:hover {
    background: #01579b;
}

/* Selección Múltiple de Responsables */
.multiselect-box {
    border: 1px solid #aaa;
    border-radius: 3px;
    padding: 4px 6px;
    max-height: 80px;
    overflow-y: auto;
    background: #fafafa;
    width: 100%;
}

.multiselect-item { 
    display: flex; 
    align-items: center; 
    gap: 6px; 
    font-size: 11px; 
    margin-bottom: 2px; 
    padding: 2px 0;
}

.multiselect-item input { 
    width: auto; 
    margin: 0; 
}

.multiselect-item span {
    font-size: 11px;
}

/* MODAL PARA TEXTO LARGO */
.modal-overlay {
    position: fixed;
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 15px;
}

.modal-content {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    width: 500px;
    max-width: 100%;
    max-height: 90vh;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    overflow-y: auto;
}

.modal-content h3 { 
    margin-top: 0; 
    font-size: 16px; 
    color: #1a237e;
}

.modal-actions { 
    display: flex; 
    justify-content: flex-end; 
    gap: 10px; 
    margin-top: 15px; 
}

/* MODAL DE PREVISUALIZACIÓN */
.modal-preview {
    width: 90%;
    max-width: 850px;
    padding: 0;
    background: #f5f5f5;
}

.modal-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: #1a237e;
    color: white;
    border-radius: 8px 8px 0 0;
    position: sticky;
    top: 0;
    z-index: 10;
}

.modal-preview-header h3 {
    margin: 0;
    color: white;
    font-size: 16px;
}

.modal-preview-header .btn-del {
    background: #c62828;
}

.preview-scroll {
    max-height: 65vh;
    overflow-y: auto;
    padding: 20px;
    background: white;
}

.preview-scroll .word-document {
    width: 100%;
    max-width: 210mm;
    margin: 0 auto;
    padding: 8mm 10mm;
    background: #ffffff;
    box-shadow: 0 0 5px rgba(0,0,0,0.1);
    font-family: 'Times New Roman', Times, serif !important;
}

.preview-scroll .word-document * {
    font-family: 'Times New Roman', Times, serif !important;
}

.preview-scroll .header-section { 
    text-align: center; 
    margin-bottom: 15px; 
}

.preview-scroll .header-section p { 
    margin: 2px 0; 
}

.preview-scroll .title-bold { 
    font-weight: bold; 
    text-transform: uppercase; 
}

.preview-scroll .meta-line { 
    text-align: left; 
    margin: 2px 0; 
    font-size: 11pt; 
}

.preview-scroll .section-header {
    font-weight: bold;
    font-size: 11pt;
    margin-top: 14px;
    margin-bottom: 6px;
    text-transform: uppercase;
}

.preview-scroll .sub-label {
    font-weight: normal;
    margin-top: 6px;
    margin-bottom: 3px;
}

.preview-scroll .text-block {
    margin: 2px 0 8px 0;
    white-space: pre-wrap;
}

.preview-scroll table.tbl-word {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 8px;
}

.preview-scroll table.tbl-word th, 
.preview-scroll table.tbl-word td {
    border: 1px solid #000000;
    padding: 4px 6px;
    text-align: left;
    font-size: 10.5pt;
    font-family: 'Times New Roman', Times, serif !important;
}

.preview-scroll table.tbl-word th {
    font-weight: bold;
    background-color: transparent;
}

.preview-scroll table.tbl-signatures {
    width: 100%;
    border: none;
    margin-top: 25px;
}

.preview-scroll table.tbl-signatures td {
    border: none;
    width: 50%;
    vertical-align: top;
    text-align: left;
    padding-right: 15px;
}

.preview-scroll .signature-box p { 
    margin: 2px 0; 
    font-size: 10.5pt; 
}

.preview-scroll .img-firma {
    max-width: 150px;
    max-height: 60px;
    object-fit: contain;
    display: block;
    margin-bottom: 5px;
}

/* RESPONSIVE */
@media (max-width: 600px) {
    body {
        padding-top: 120px;
    }

    .action-bar {
        padding: 8px 10px;
        flex-direction: column;
        gap: 6px;
    }

    .action-bar .btn-export,
    .action-bar .btn-preview {
        min-width: 100%;
        max-width: 100%;
        padding: 12px;
        font-size: 14px;
    }

    .form-panel {
        padding: 10px 12px;
    }

    .grid-2 {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .dynamic-row {
        flex-direction: column;
        align-items: stretch;
        gap: 4px;
    }

    .dynamic-row input,
    .dynamic-row select {
        width: 100%;
    }

    .modal-preview {
        width: 95%;
        padding: 0;
    }

    .preview-scroll {
        padding: 10px;
        max-height: 55vh;
    }

    .preview-scroll .word-document {
        padding: 5mm;
    }

    .modal-preview-header {
        flex-direction: column;
        gap: 8px;
        padding: 12px 15px;
    }

    .modal-preview-header .btn-del {
        width: 100%;
        text-align: center;
    }

    .action-bar-bottom {
        flex-direction: column;
    }

    .action-bar-bottom .btn-export,
    .action-bar-bottom .btn-preview {
        min-width: 100%;
    }

    .multiselect-box {
        max-height: 60px;
    }

    .multiselect-item {
        font-size: 12px;
    }

    .multiselect-item input {
        transform: scale(1.1);
    }

    input, textarea, select {
        font-size: 16px; /* Evita zoom en iOS */
    }
}