/* Estilos personalizados para el formulario de Historia Clínica */

/*
 * Vista Alsalud y vista Studio comparten el mismo <form> con clase
 * alsalud-historia-clinica-form. Odoo a veces deja el .row del snippet sin flex;
 * sin esto, los .col-lg-6 se apilan y el orden luce 1, 8, 2, 9…
 */
form.alsalud-historia-clinica-form .s_website_form_rows.row,
.alsalud-historia-clinica-root .s_website_form_rows.row {
    display: flex !important;
    flex-wrap: wrap !important;
    width: 100%;
    align-items: flex-start;
}

form.alsalud-historia-clinica-form .s_website_form_rows.row > .contact-header.col-12,
form.alsalud-historia-clinica-form .s_website_form_rows.row > .form-section.col-12,
.alsalud-historia-clinica-root .s_website_form_rows.row > .contact-header.col-12,
.alsalud-historia-clinica-root .s_website_form_rows.row > .form-section.col-12 {
    flex: 0 0 100% !important;
    max-width: 100% !important;
}

form.alsalud-historia-clinica-form .s_website_form_rows.row > .s_website_form_field.col-lg-6,
.alsalud-historia-clinica-root .s_website_form_rows.row > .s_website_form_field.col-lg-6 {
    flex: 0 0 100% !important;
    max-width: 100% !important;
    width: 100% !important;
    box-sizing: border-box;
}

@media (min-width: 992px) {
    form.alsalud-historia-clinica-form .s_website_form_rows.row > .s_website_form_field.col-lg-6,
    .alsalud-historia-clinica-root .s_website_form_rows.row > .s_website_form_field.col-lg-6 {
        flex: 0 0 50% !important;
        max-width: 50% !important;
        width: 50% !important;
        box-sizing: border-box;
    }

    form.alsalud-historia-clinica-form .s_website_form_rows.row > .s_website_form_field.col-6,
    .alsalud-historia-clinica-root .s_website_form_rows.row > .s_website_form_field.col-6 {
        flex: 0 0 50% !important;
        max-width: 50% !important;
        box-sizing: border-box;
    }

    form.alsalud-historia-clinica-form .s_website_form_rows.row > .s_website_form_field.col-lg-5,
    .alsalud-historia-clinica-root .s_website_form_rows.row > .s_website_form_field.col-lg-5 {
        flex: 0 0 41.666667% !important;
        max-width: 41.666667% !important;
        box-sizing: border-box;
    }

    form.alsalud-historia-clinica-form .s_website_form_rows.row > .s_website_form_field.col-lg-4,
    .alsalud-historia-clinica-root .s_website_form_rows.row > .s_website_form_field.col-lg-4 {
        flex: 0 0 33.333333% !important;
        max-width: 33.333333% !important;
        box-sizing: border-box;
    }

    form.alsalud-historia-clinica-form .s_website_form_rows.row > .s_website_form_field.col-lg-3,
    .alsalud-historia-clinica-root .s_website_form_rows.row > .s_website_form_field.col-lg-3 {
        flex: 0 0 25% !important;
        max-width: 25% !important;
        box-sizing: border-box;
    }

    form.alsalud-historia-clinica-form .s_website_form_rows.row > .s_website_form_field.col-md-6,
    .alsalud-historia-clinica-root .s_website_form_rows.row > .s_website_form_field.col-md-6 {
        flex: 0 0 50% !important;
        max-width: 50% !important;
        box-sizing: border-box;
    }
}

form.alsalud-historia-clinica-form .s_website_form_rows.row > .s_website_form_field.col-12:not(.col-lg-6):not(.col-md-6):not(.col-6),
.alsalud-historia-clinica-root .s_website_form_rows.row > .s_website_form_field.col-12:not(.col-lg-6):not(.col-md-6):not(.col-6) {
    flex: 0 0 100% !important;
    max-width: 100% !important;
}

form.alsalud-historia-clinica-form .s_website_form_rows.row > p,
.alsalud-historia-clinica-root .s_website_form_rows.row > p {
    flex: 0 0 100% !important;
    width: 100%;
}

/* Secciones 5 / 5.1: grid 2 columnas (DOM en orden 1,8,2,9… → visual 1–7 | 8–14) */
form.alsalud-historia-clinica-form .s_website_form_rows.row > .alsalud-section-card.col-12,
.alsalud-historia-clinica-root .s_website_form_rows.row > .alsalud-section-card.col-12 {
    flex: 0 0 100% !important;
    max-width: 100% !important;
    width: 100% !important;
}

form.alsalud-historia-clinica-form .alsalud-section-card,
.alsalud-historia-clinica-root .alsalud-section-card {
    background: #fff;
    border: 1px solid #e8ecf1;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(44, 62, 80, 0.06);
    padding: 1.25rem 1.5rem 1.5rem;
    margin-bottom: 1.75rem;
}

form.alsalud-historia-clinica-form .alsalud-section-heading,
.alsalud-historia-clinica-root .alsalud-section-heading {
    color: #2c3e50;
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0 0 0.35rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #7c9af8;
}

form.alsalud-historia-clinica-form .alsalud-section-intro,
.alsalud-historia-clinica-root .alsalud-section-intro {
    color: #6c757d;
    font-size: 0.9rem;
    margin: 0 0 1rem;
    line-height: 1.45;
}

form.alsalud-historia-clinica-form .alsalud-two-col-yesno,
.alsalud-historia-clinica-root .alsalud-two-col-yesno {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem 1.25rem;
    align-items: stretch;
    margin-bottom: 0.25rem;
}

@media (max-width: 991.98px) {
    form.alsalud-historia-clinica-form .alsalud-two-col-yesno,
    .alsalud-historia-clinica-root .alsalud-two-col-yesno {
        grid-template-columns: 1fr;
    }
}

form.alsalud-historia-clinica-form .alsalud-yesno-cell,
.alsalud-historia-clinica-root .alsalud-yesno-cell {
    margin-bottom: 0 !important;
    padding: 0.65rem 0.75rem;
    background: #f8fafc;
    border: 1px solid #e9eef5;
    border-radius: 8px;
    min-width: 0;
}

form.alsalud-historia-clinica-form .alsalud-yesno-cell > .row,
.alsalud-historia-clinica-root .alsalud-yesno-cell > .row {
    align-items: center;
    margin: 0;
}

form.alsalud-historia-clinica-form .alsalud-yesno-cell .s_website_form_label,
.alsalud-historia-clinica-root .alsalud-yesno-cell .s_website_form_label {
    font-size: 0.82rem;
    line-height: 1.35;
    margin-bottom: 0;
}

form.alsalud-historia-clinica-form .alsalud-yesno-cell .s_website_form_multiple.row,
.alsalud-historia-clinica-root .alsalud-yesno-cell .s_website_form_multiple.row {
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: center;
    gap: 0.35rem 0.75rem;
    margin: 0 !important;
}

form.alsalud-historia-clinica-form .alsalud-yesno-cell .s_website_form_multiple .radio,
.alsalud-historia-clinica-root .alsalud-yesno-cell .s_website_form_multiple .radio {
    flex: 0 0 auto !important;
    width: auto !important;
    max-width: none !important;
    padding: 0 !important;
}

form.alsalud-historia-clinica-form .alsalud-yesno-cell .form-check,
.alsalud-historia-clinica-root .alsalud-yesno-cell .form-check {
    padding: 0.45rem 0.65rem !important;
    margin: 0 !important;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    border-radius: 6px;
}

form.alsalud-historia-clinica-form .alsalud-yesno-cell .form-check-input,
.alsalud-historia-clinica-root .alsalud-yesno-cell .form-check-input {
    width: 1.1rem;
    height: 1.1rem;
    margin-top: 0 !important;
}

form.alsalud-historia-clinica-form .alsalud-especifique-below,
.alsalud-historia-clinica-root .alsalud-especifique-below {
    margin-top: 1rem !important;
    max-width: 100%;
}

form.alsalud-historia-clinica-form .alsalud-label-soft,
.alsalud-historia-clinica-root .alsalud-label-soft {
    font-weight: 600;
    color: #5a6570;
}

/* Sección 4: columnas Padre/Madre como “pilares” alineados */
form.alsalud-historia-clinica-form .alsalud-family-pillar,
.alsalud-historia-clinica-root .alsalud-family-pillar {
    background: #f8fafc;
    border: 1px solid #e9eef5;
    border-radius: 8px;
    padding: 1rem 1.1rem 1.15rem;
    min-width: 0;
}

form.alsalud-historia-clinica-form .alsalud-pillar-title,
.alsalud-historia-clinica-root .alsalud-pillar-title {
    color: #2c3e50;
    font-size: 1rem;
    font-weight: 700;
    margin: 0 0 0.85rem;
    padding-bottom: 0.4rem;
    border-bottom: 2px solid #c5d4f5;
}

form.alsalud-historia-clinica-form .alsalud-family-extras,
.alsalud-historia-clinica-root .alsalud-family-extras {
    margin-top: 0.5rem;
}

form.alsalud-historia-clinica-form .alsalud-section-card .family-section,
.alsalud-historia-clinica-root .alsalud-section-card .family-section {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 0;
    width: 100%;
}

form.alsalud-historia-clinica-form .alsalud-section-card .family-section > .row,
.alsalud-historia-clinica-root .alsalud-section-card .family-section > .row {
    width: 100%;
    margin-left: 0;
    margin-right: 0;
}

/* Sección 6: mismo lenguaje visual que Sí/No en tarjeta */
form.alsalud-historia-clinica-form .alsalud-nopat-stack,
.alsalud-historia-clinica-root .alsalud-nopat-stack {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

form.alsalud-historia-clinica-form .alsalud-nopat-stack > .s_website_form_field[data-type="selection"],
.alsalud-historia-clinica-root .alsalud-nopat-stack > .s_website_form_field[data-type="selection"] {
    margin-bottom: 0 !important;
    padding: 0.65rem 0.75rem;
    background: #f8fafc;
    border: 1px solid #e9eef5;
    border-radius: 8px;
}

form.alsalud-historia-clinica-form .alsalud-nopat-stack > .s_website_form_field[data-type="selection"] .s_website_form_multiple.row,
.alsalud-historia-clinica-root .alsalud-nopat-stack > .s_website_form_field[data-type="selection"] .s_website_form_multiple.row {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center;
    gap: 0.35rem 0.75rem;
    margin: 0 !important;
}

form.alsalud-historia-clinica-form .alsalud-nopat-stack > .s_website_form_field[data-type="selection"] .s_website_form_multiple .radio,
.alsalud-historia-clinica-root .alsalud-nopat-stack > .s_website_form_field[data-type="selection"] .s_website_form_multiple .radio {
    flex: 0 0 auto !important;
    width: auto !important;
    max-width: none !important;
    padding: 0 !important;
}

form.alsalud-historia-clinica-form .alsalud-nopat-stack > .s_website_form_field[data-type="selection"] .form-check,
.alsalud-historia-clinica-root .alsalud-nopat-stack > .s_website_form_field[data-type="selection"] .form-check {
    padding: 0.45rem 0.65rem !important;
    margin: 0 !important;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    border-radius: 6px;
}

form.alsalud-historia-clinica-form .alsalud-nopat-stack > .s_website_form_field[data-type="char"],
.alsalud-historia-clinica-root .alsalud-nopat-stack > .s_website_form_field[data-type="char"] {
    margin-bottom: 0.35rem !important;
    margin-top: -0.15rem;
    padding: 0.5rem 0.65rem 0.65rem 0.85rem;
    background: #fff;
    border-left: 3px solid #c5d4f5;
    border-radius: 0 6px 6px 0;
    box-shadow: 0 1px 0 rgba(44, 62, 80, 0.04);
}

form.alsalud-historia-clinica-form .alsalud-nopat-stack > .s_website_form_field[data-type="char"] .s_website_form_label,
.alsalud-historia-clinica-root .alsalud-nopat-stack > .s_website_form_field[data-type="char"] .s_website_form_label {
    font-size: 0.82rem;
    font-weight: 600;
    color: #6c757d;
}

form.alsalud-historia-clinica-form .alsalud-subsection-heading,
.alsalud-historia-clinica-root .alsalud-subsection-heading {
    color: #34495e;
    font-size: 0.95rem;
    font-weight: 700;
    margin: 1.15rem 0 0.5rem;
    padding-top: 0.35rem;
    border-top: 1px dashed #dee6f0;
    width: 100%;
    flex: 0 0 100%;
}

form.alsalud-historia-clinica-form .alsalud-nopat-stack > .alsalud-subsection-heading:first-child,
.alsalud-historia-clinica-root .alsalud-nopat-stack > .alsalud-subsection-heading:first-child {
    margin-top: 0.25rem;
    padding-top: 0;
    border-top: none;
}

/* Padre/Madre + bloques siguientes (flex ya definido en .family-section) */
form.alsalud-historia-clinica-form .family-section,
.alsalud-historia-clinica-root .family-section {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 1rem 1.25rem;
    width: 100%;
}

form.alsalud-historia-clinica-form .family-section > .row,
.alsalud-historia-clinica-root .family-section > .row {
    flex: 0 0 100% !important;
    width: 100%;
}

/* Contenedor principal del formulario */
#wrap .s_website_form {
    background-color: #f8f9fa;
    padding: 2rem 0;
}

/* Secciones del formulario con cards */
.form-section {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 2rem;
    margin-bottom: 2rem;
}

.form-section-title {
    color: #2c3e50;
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 3px solid #7c9af8;
}

/* Campos de contacto en la parte superior */
.contact-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 2rem;
}

.contact-header h3 {
    color: white;
    margin-bottom: 1rem;
    font-size: 1.25rem;
    font-weight: 600;
}

.contact-header .s_website_form_field {
    margin-bottom: 1rem;
}

.contact-header .s_website_form_label {
    color: white;
    font-weight: 500;
}

.contact-header .form-control {
    background-color: rgba(255, 255, 255, 0.95);
    border: none;
    border-radius: 4px;
    padding: 0.5rem 0.75rem;
}

.contact-header .form-control:focus {
    background-color: white;
    box-shadow: 0 0 0 0.2rem rgba(255, 255, 255, 0.5);
}

/* Campos del formulario */
.s_website_form_field {
    margin-bottom: 1.25rem;
}

.s_website_form_label {
    font-weight: 600;
    color: #495057;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.s_website_form_input.form-control {
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 0.625rem 0.75rem;
    transition: all 0.3s ease;
    font-size: 0.95rem;
}

.s_website_form_input.form-control:focus {
    border-color: #7c9af8;
    box-shadow: 0 0 0 0.2rem rgba(124, 154, 248, 0.25);
    outline: none;
}

/* Radio buttons mejorados */
.s_website_form_multiple .form-check {
    padding: 0.5rem;
    margin: 0.25rem 0;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.s_website_form_multiple .form-check:hover {
    background-color: #f8f9fa;
}

.s_website_form_multiple .form-check-input {
    margin-top: 0.35rem;
    cursor: pointer;
}

.s_website_form_multiple .form-check-label {
    cursor: pointer;
    padding-left: 0.5rem;
    font-weight: 500;
}

.s_website_form_multiple .form-check-input:checked {
    background-color: #7c9af8;
    border-color: #7c9af8;
}

/* Agrupación tipo Bootstrap row (los campos ya traen col-*) */
.form-row-group.row {
    margin-bottom: 1.5rem;
}

.form-row-group:not(.row) {
    margin-bottom: 1.5rem;
}

/* Enfermedades familiares: Bootstrap row + col-lg-6 en el XML */
.diseases-grid.row {
    margin-top: 1rem;
}

.disease-item {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    background-color: #f8f9fa;
    border-radius: 4px;
    border: 1px solid #e9ecef;
    transition: all 0.2s ease;
}

.disease-item:hover {
    background-color: #e9ecef;
    border-color: #7c9af8;
}

.disease-item label {
    flex: 1;
    margin: 0;
    font-weight: 500;
    color: #495057;
}

.disease-item .radio-group {
    display: flex;
    gap: 1rem;
    margin-left: auto;
}

/* Sección de historia familiar: fila Padre/Madre + bloques col-lg-6 (secc. 5–6) */
.family-section {
    margin-top: 1.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem 1.25rem;
    align-items: flex-start;
}

.family-section > .row {
    flex: 1 1 100%;
    width: 100%;
}

.family-section > p,
.family-section > .s_website_form_field.col-12:not(.col-lg-6) {
    flex: 1 1 100%;
    width: 100%;
}

.family-section > .s_website_form_field.col-lg-6 {
    flex: 1 1 calc(50% - 0.75rem);
    max-width: calc(50% - 0.75rem);
    min-width: min(100%, 300px);
}

@media (max-width: 991.98px) {
    .family-section > .s_website_form_field.col-lg-6 {
        flex: 1 1 100%;
        max-width: 100%;
    }
}

.family-member-card {
    background-color: #f8f9fa;
    border-left: 4px solid #7c9af8;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
    border-radius: 4px;
}

.family-member-title {
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

/* Botón de envío mejorado */
.s_website_form_submit {
    margin-top: 2rem;
    text-align: center;
}

.s_website_form_send {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 0.875rem 2.5rem;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 6px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.s_website_form_send:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

.s_website_form_send:active {
    transform: translateY(0);
}

/* Campos de archivo mejorados */
.s_website_form_field[data-type="binary"] {
    padding: 1rem;
    background-color: #f8f9fa;
    border: 2px dashed #dee2e6;
    border-radius: 4px;
    text-align: center;
    transition: all 0.3s ease;
}

.s_website_form_field[data-type="binary"]:hover {
    border-color: #7c9af8;
    background-color: #f0f4ff;
}

/* Firma de examinado: mantener canvas visible (no reemplazar por widget file del editor) */
.s_website_form_field_signature .signature-pad-wrapper {
    display: block !important;
}
.s_website_form_field_signature .signature-data {
    display: none !important;
}

/* Responsive */
@media (max-width: 768px) {
    .form-section {
        padding: 1.25rem;
    }
    
    .form-row-group {
        grid-template-columns: 1fr;
    }
    
    .diseases-grid {
        grid-template-columns: 1fr;
    }
    
    .contact-header {
        padding: 1rem;
    }
}

/* Espaciado mejorado para campos de fecha */
.s_website_form_date {
    position: relative;
}

.s_website_form_date .input-group-text {
    background-color: #7c9af8;
    color: white;
    border: 1px solid #7c9af8;
    cursor: pointer;
}

.s_website_form_date .input-group-text:hover {
    background-color: #667eea;
}

/* Textarea mejorado */
textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

/* Mensaje de bienvenida */
.s_embed_code {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    padding: 2rem;
    border-radius: 8px;
    margin-bottom: 2rem;
    text-align: center;
}

.s_embed_code p {
    font-size: 1.1rem;
    color: #495057;
    margin: 0;
}

