/* Novamed Adverse Event Form Styles */
:root {
    --novamed-primary: #0F529D;
    --novamed-primary-hover: hsl(213, 76%, 31%);
    --novamed-border: #B9B9B9;
    --novamed-placeholder: #B9B9B9;
    --novamed-text: #000000;
    --novamed-white: #FFFFFF;
}

/* Reset and base styles */
.novamed-aef-popup *,
.novamed-aef-popup *::before,
.novamed-aef-popup *::after {
    box-sizing: border-box;
}


input[type="text"], input[type="number"], input[type="email"], input[type="url"], input[type="password"], input[type="search"], input[type=reset], input[type=tel], input[type=date], select, textarea{
    font-size: 15px;
}


/* Popup Overlay */
.novamed-aef-popup-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 999999;
    overflow-y: auto;
    padding: 20px;
}

.novamed-aef-popup-overlay.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Popup Container */
.novamed-aef-popup {
    position: relative;
    background: var(--novamed-white);
    width: 90%;
    max-width: 90%;
    height: 95%;
    border-radius: 10px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.3);
    margin: 20px auto;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Popup Header */
.novamed-aef-header {
    background: var(--novamed-primary);
    color: var(--novamed-white);
    padding: 20px 30px;
    border-radius: 10px 10px 0 0;
    position: relative;
}

.novamed-aef-header h2 {
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
    font-size: 18px;
    margin: 0 0 8px 0;
    line-height: 1.4;
    color: var(--novamed-white);
}

.novamed-aef-header p {
    font-family: 'Montserrat', sans-serif;
    font-weight: 400;
    font-size: 12px;
    margin: 0;
    opacity: 0.95;
    line-height: 1.5;
}

.novamed-aef-header a {
    color: var(--novamed-white);
    text-decoration: underline;
}

/* Close Button */
.novamed-aef-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: transparent;
    border: none;
    color: var(--novamed-white);
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    padding: 5px;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
}


/* Popup Body */
.novamed-aef-body {
    padding: 30px;
    max-height: calc(90vh - 160px);
    overflow-y: auto;
}

/* Form Sections */
.novamed-aef-section {
    margin-bottom: 30px;
}

.novamed-aef-section-title {
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
    font-size: 16px;
    color: var(--novamed-primary);
    text-align: center;
    margin: 0 0 20px 0;
    padding-top: 15px;
    border-top: 1px solid var(--novamed-primary);
}

/* Form Grid */
.novamed-aef-form-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}

.novamed-aef-form-grid.two-cols {
    grid-template-columns: repeat(2, 1fr);
}

.novamed-aef-form-grid.four-cols {
    grid-template-columns: repeat(4, 1fr);
}

.novamed-aef-form-group {
    display: flex;
    flex-direction: column;
}

.novamed-aef-form-group.full-width {
    grid-column: 1 / -1;
}

.novamed-aef-form-group.span-2 {
    grid-column: span 2;
}

/* Form Labels */
.novamed-aef-label {
    font-family: 'Montserrat', sans-serif;
    font-weight: 500;
    font-size: 15px;
    color: var(--novamed-text);
    margin-bottom: 6px;
    display: block;
}

.novamed-aef-label.required::after {
    content: ' *';
    color: #e74c3c;
}

/* Form Inputs */
.novamed-aef-input,
.novamed-aef-select,
.novamed-aef-textarea {
    font-family: 'Montserrat', sans-serif;
    font-size: 13px;
    padding: 10px 12px;
    border: 1px solid var(--novamed-border);
    border-radius: 5px;
    background: var(--novamed-white);
    color: var(--novamed-text);
    transition: border-color 0.3s ease;
    width: 100%;
}

.novamed-aef-input::placeholder,
.novamed-aef-select::placeholder,
.novamed-aef-textarea::placeholder {
    color: var(--novamed-placeholder);
    opacity: 1;
}

.novamed-aef-input:focus,
.novamed-aef-select:focus,
.novamed-aef-textarea:focus {
    outline: none;
    border-color: var(--novamed-primary);
}

.novamed-aef-textarea {
    resize: vertical;
    min-height: 80px;
    font-family: 'Montserrat', sans-serif;
    line-height: 1.4;
}

.novamed-aef-select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23B9B9B9' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px;
    padding-right: 35px;
}

/* Datepicker input */
.novamed-aef-input.datepicker {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23B9B9B9' stroke-width='2'%3E%3Crect x='3' y='4' width='18' height='18' rx='2' ry='2'%3E%3C/rect%3E%3Cline x1='16' y1='2' x2='16' y2='6'%3E%3C/line%3E%3Cline x1='8' y1='2' x2='8' y2='6'%3E%3C/line%3E%3Cline x1='3' y1='10' x2='21' y2='10'%3E%3C/line%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 40px;
    cursor: pointer;
}

/* Checkbox Group */
.novamed-aef-checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.novamed-aef-checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.novamed-aef-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--novamed-primary);
}

.novamed-aef-checkbox-label {
    font-family: 'Montserrat', sans-serif;
    font-size: 15px;
    color: var(--novamed-text);
    cursor: pointer;
    user-select: none;
}

/* Radio Group */
.novamed-aef-radio-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.novamed-aef-radio-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.novamed-aef-radio {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--novamed-primary);
}

.novamed-aef-radio-label {
    font-family: 'Montserrat', sans-serif;
    font-size: 15px;
    color: var(--novamed-text);
    cursor: pointer;
    user-select: none;
}

/* Grid complejo: 3 columnas con row spans para evento adverso */
.novamed-aef-event-complex-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    grid-auto-rows: auto;
    gap: 15px;
    margin-bottom: 20px;
}

/* Descripción ocupa 2 filas (row span) */
.novamed-aef-description-span {
    grid-row: span 2;
    display: flex;
    flex-direction: column;
}

/* Textarea ocupa toda la altura disponible */
.novamed-aef-textarea-full-height {
    flex: 1;
    min-height: 200px;
    resize: vertical;
}

/* Fecha condicional ocupa 2 columnas */
.novamed-aef-date-span {
    grid-column: span 2;
}

/* Evolucion Section */
.novamed-aef-evolucion-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Grid especial para Evolución y Seriedad */
.novamed-aef-evolucion-seriedad-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 30px;
    margin-top: 20px;
}

/* Seriedad Section - Lista vertical */
.novamed-aef-seriedad-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Date conditional */
.novamed-aef-date-conditional {
    display: none;
}

.novamed-aef-date-conditional.visible {
    display: block;
}

/* Grid de 5 columnas para información comercial */
.novamed-aef-commercial-grid {
    grid-template-columns: repeat(5, 1fr) !important;
}

/* Grid de 4 columnas para diagnósticos */
.novamed-aef-diagnostics-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin-bottom: 20px;
    align-items: center;
}

/* Checkboxes inline (horizontal) */
.novamed-aef-checkboxes-inline {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.novamed-aef-checkboxes-inline .novamed-aef-checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Manejo del Evento y Desenlace Table */
.novamed-aef-table-section {
    margin-top: 25px;
}

.novamed-aef-table-container {
    overflow-x: auto;
    margin-top: 15px;
    border-radius: 15px;
    overflow: hidden;
}

.novamed-aef-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-family: 'Montserrat', sans-serif;
    font-size: 15px;
    border: 1px solid var(--novamed-border);
    border-radius: 15px;
}

.novamed-aef-table thead {
    background-color: #EBEBEB;
}

.novamed-aef-table th {
    font-weight: 600;
    padding: 12px 8px;
    text-align: center;
    border-right: 1px solid var(--novamed-border);
    border-bottom: 1px solid var(--novamed-border);
    color: var(--novamed-text);
}

.novamed-aef-table th:last-child {
    border-right: none;
}

.novamed-aef-table th:first-child {
    text-align: left;
    width: 70%;
    color: transparent;
    border-top-left-radius: 15px;
}

.novamed-aef-table thead tr:first-child th:last-child {
    border-top-right-radius: 15px;
}

.novamed-aef-table td {
    padding: 10px 8px;
    border-right: 1px solid var(--novamed-border);
    border-bottom: 1px solid var(--novamed-border);
}

.novamed-aef-table td:last-child {
    border-right: none;
}

.novamed-aef-table tr:last-child td {
    border-bottom: none;
}

.novamed-aef-table tr:last-child td:first-child {
    border-bottom-left-radius: 15px;
}

.novamed-aef-table tr:last-child td:last-child {
    border-bottom-right-radius: 15px;
}



.novamed-aef-table td:not(:first-child) {
    text-align: center;
    vertical-align: middle;
}

.novamed-aef-table-radio {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--novamed-primary);
    margin: 0 auto;
    display: block;
}

/* Columnas Si, No, No sabe con ancho fijo igual */
.novamed-aef-table th:nth-child(2),
.novamed-aef-table th:nth-child(3),
.novamed-aef-table th:nth-child(4) {
    width: 40px;
    min-width: 40px;
    max-width: 40px;
}

.novamed-aef-table td {
    padding: 10px 8px;

}

.novamed-aef-table td:first-child {
    text-align: left;
    font-family: 'Montserrat', sans-serif;
    font-size: 15px;
    font-weight: 400;
    line-height: 1.4;
    color: var(--novamed-text);
}

.novamed-aef-table td:nth-child(2),
.novamed-aef-table td:nth-child(3),
.novamed-aef-table td:nth-child(4) {
    width: 40px;
    min-width: 40px;
    max-width: 40px;
    text-align: center;
    vertical-align: middle;
}

.novamed-aef-table-radio {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--novamed-primary);
    margin: 0 auto;
    display: block;
}

/* Disclaimer Text */
.novamed-aef-disclaimer {
    font-family: 'Montserrat', sans-serif;
    font-size: 10px;
    color: #666;
    line-height: 1.5;
    margin-top: 20px;
    padding: 15px 0;
    background-color: transparent;
    border-radius: 0;
    text-align: justify;
}

/* Authorization Checkbox */
.novamed-aef-authorization {
    margin-top: 20px;
    padding: 15px 0;
    background-color: transparent;
    border-radius: 0;
}

.novamed-aef-authorization-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.novamed-aef-authorization-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--novamed-primary);
    margin-top: 2px;
    flex-shrink: 0;
}

.novamed-aef-authorization-label {
    font-family: 'Montserrat', sans-serif;
    font-size: 11px;
    color: var(--novamed-text);
    cursor: pointer;
    user-select: none;
    line-height: 1.5;
}

.novamed-aef-authorization-label.required::after {
    content: ' *';
    color: #e74c3c;
    font-weight: bold;
}

/* Submit Button */
.novamed-aef-submit-container {
    margin-top: 25px;
    text-align: center;
}

.novamed-aef-submit {
    background-color: var(--novamed-primary);
    color: var(--novamed-white);
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
    font-size: 14px;
    padding: 14px 60px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    width: 100%;
    max-width: 400px;
}

.novamed-aef-submit:hover {
    background-color: var(--novamed-primary-hover);
    color: var(--novamed-white) !important;
}

.novamed-aef-submit:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

/* Loading Spinner */
.novamed-aef-loading {
    display: none;
    text-align: center;
    padding: 20px;
}

.novamed-aef-loading.active {
    display: block;
}

.novamed-aef-spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--novamed-primary);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Success/Error Messages */
.novamed-aef-message {
    display: none;
    padding: 15px;
    border-radius: 5px;
    margin-bottom: 20px;
    font-family: 'Montserrat', sans-serif;
    font-size: 13px;
    text-align: center;
}

.novamed-aef-message.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.novamed-aef-message.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.novamed-aef-message.active {
    display: block;
}

/* Custom Scrollbar */
.novamed-aef-body::-webkit-scrollbar {
    width: 8px;
}

.novamed-aef-body::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.novamed-aef-body::-webkit-scrollbar-thumb {
    background: var(--novamed-primary);
    border-radius: 4px;
}

.novamed-aef-body::-webkit-scrollbar-thumb:hover {
    background: var(--novamed-primary-hover);
}

/* Responsive Design */
@media (max-width: 768px) {
    .novamed-aef-popup {
        max-width: 100%;
        margin: 0;
        border-radius: 0;
        height: 100vh;
        width: 100%;
    }
    
    .novamed-aef-header {
        border-radius: 0;
        padding: 20px;
    }
    
    .novamed-aef-header h2 {
        font-size: 16px;
        padding-right: 30px;
    }
    
    .novamed-aef-header p {
        font-size: 11px;
    }
    
    .novamed-aef-body {
        padding: 20px;
        max-height: calc(100vh - 140px);
    }
    
    .novamed-aef-form-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .novamed-aef-form-grid.two-cols,
    .novamed-aef-form-grid.four-cols {
        grid-template-columns: 1fr;
    }
    
    .novamed-aef-form-group.span-2 {
        grid-column: span 1;
    }
    
    .novamed-aef-event-complex-grid {
        grid-template-columns: 1fr;
    }
    
    .novamed-aef-description-span {
        grid-row: auto;
    }
    
    .novamed-aef-date-span {
        grid-column: auto;
    }
    
    .novamed-aef-textarea-full-height {
        min-height: 120px;
    }
    
    .novamed-aef-evolucion-seriedad-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .novamed-aef-commercial-grid {
        grid-template-columns: 1fr !important;
    }
    
    .novamed-aef-diagnostics-grid {
        grid-template-columns: 1fr;
    }
    
    .novamed-aef-table {
        font-size: 10px;
    }
    
    .novamed-aef-table th,
    .novamed-aef-table td {
        padding: 8px 5px;
    }
    
    .novamed-aef-submit {
        padding: 12px 40px;
        font-size: 13px;
    }

    .novamed-aef-checkbox-label {
        font-size: 15px;
    }

    input[type="text"], input[type="number"], input[type="email"], input[type="url"], input[type="password"], input[type="search"], input[type=reset], input[type=tel], input[type=date], select, textarea{
    font-size: 15px;
    }

    .novamed-aef-radio-label{
        font-size: 15px;
    }

}

@media (max-width: 480px) {
    .novamed-aef-header h2 {
        font-size: 15px;
    }
    
    .novamed-aef-header p {
        font-size: 12px;
    }
    
    .novamed-aef-body {
        padding: 15px;
    }
    
    .novamed-aef-section-title {
        font-size: 15px;
    }
    
    .novamed-aef-label {
        font-size: 12px;
    }
    
    .novamed-aef-input,
    .novamed-aef-select,
    .novamed-aef-textarea {
        font-size: 12px;
        padding: 9px 10px;
    }
    
    .novamed-aef-table {
        font-size: 12px;
    }
    
    .novamed-aef-disclaimer {
        font-size: 10px;
    }
    
    .novamed-aef-authorization-label {
        font-size: 10px;
    }

    .novamed-aef-input, .novamed-aef-select, .novamed-aef-textarea{
        font-size: 12px !important;
    }

    .novamed-aef-table td:first-child{
        font-size: 12px;
    }

    .novamed-aef-checkbox-label{
        font-size: 12px;
    }

    .novamed-aef-radio-label{
        font-size: 12px;
    }
}

/* jQuery UI Datepicker Customization */
.ui-datepicker {
    font-family: 'Montserrat', sans-serif !important;
    font-size: 12px !important;
}

.ui-datepicker-header {
    background-color: var(--novamed-primary) !important;
    color: var(--novamed-white) !important;
}

.ui-datepicker-title {
    color: var(--novamed-white) !important;
}

.ui-datepicker th {
    color: var(--novamed-primary) !important;
    font-weight: 600 !important;
}

.ui-state-default {
    border: 1px solid var(--novamed-border) !important;
}

.ui-state-active,
.ui-state-highlight {
    background-color: var(--novamed-primary) !important;
    color: var(--novamed-white) !important;
}

.ui-state-hover {
    background-color: var(--novamed-primary-hover) !important;
    color: var(--novamed-white) !important;
}
