/* Modal Styles - INTRANEURO */

/* Base Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s ease;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    position: relative;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideIn 0.3s ease;
}

/* Close Button */
.close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 2rem;
    font-weight: 300;
    color: var(--text-secondary);
    cursor: pointer;
    line-height: 1;
    transition: color 0.3s ease;
    z-index: 9999;
}

.close:hover {
    color: var(--text-primary);
}

/* Login Modal */
.login-content {
    width: 400px;
    padding: 0;
    overflow: hidden;
}

.login-container {
    padding: 3rem 2rem;
    text-align: center;
}

.login-logo {
    width: 120px;
    height: 120px;
    margin-bottom: 1.5rem;
}

.login-container h2 {
    color: var(--text-primary);
    font-size: 1.5rem;
    margin-bottom: 2rem;
    font-weight: 400;
}

#loginForm .form-group {
    margin-bottom: 1rem;
}

#loginForm input {
    width: 100%;
    padding: 1rem;
    font-size: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

#loginForm .btn-primary {
    width: 100%;
    padding: 1rem;
    font-size: 1rem;
    margin-top: 1rem;
}

/* Admission Modal */
#admissionModal .modal-content {
    width: 700px;
    padding: 2rem;
}

#admissionModal h2 {
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    font-size: 1.8rem;
}

/* Patient Modal */
.patient-modal-content {
    width: 50%;
    max-width: 700px;
    padding: 0;
}

.patient-modal-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 400px;
}

.modal-section {
    padding: 2rem;
}

.modal-section h2 {
    font-size: 1.2rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
}

.admission-section {
    border-right: 1px solid var(--border-color);
}

.discharge-section {
    background-color: var(--background);
}

/* Patient Data Display */
.patient-info-row {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.patient-info-row:last-child {
    border-bottom: none;
}

.info-label {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.info-value {
    color: var(--text-primary);
    font-size: 0.95rem;
}

/* Discharge Form in Modal */
.discharge-form {
    margin-top: 1rem;
    color: var(--text-primary);
}

.discharge-form h3 {
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.discharge-form label {
    color: var(--text-primary);
    font-weight: 600;
}

.discharge-form .form-group {
    margin-bottom: 1rem;
}

.ranking-selector {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.star {
    font-size: 1.5rem;
    color: var(--border-color);
    cursor: pointer;
    transition: color 0.3s ease;
}

.star:hover,
.star.active {
    color: var(--warning-color);
}

/* Modal Footer */
.modal-footer {
    padding: 2rem;
    border-top: 1px solid var(--border-color);
    background-color: var(--background);
}

.observations-section {
    margin-top: 1.5rem;
}

.observations-section h3 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.observations-section textarea {
    width: 100%;
    min-height: 100px;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    resize: vertical;
}

/* Timeline */
#patientTimeline {
    margin-bottom: 2rem;
}

.timeline-item {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    padding-left: 2rem;
    position: relative;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: 0.5rem;
    top: 0.5rem;
    width: 8px;
    height: 8px;
    background-color: var(--primary-color);
    border-radius: 50%;
}

.timeline-date {
    font-size: 0.85rem;
    color: var(--text-secondary);
    min-width: 100px;
}

.timeline-event {
    font-size: 0.9rem;
    color: var(--text-primary);
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

/* Responsive */
@media (max-width: 1024px) {
    .patient-modal-split {
        grid-template-columns: 1fr;
    }
    
    .admission-section {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
}

@media (max-width: 768px) {
    .modal {
        padding: 0;
        overflow-x: hidden;
        background-color: rgba(0, 0, 0, 0.7);
    }
    
    .modal-content {
        width: 100%;
        max-width: 100%;
        min-width: 100%;
        margin: 0;
        max-height: 100vh;
        overflow-y: auto;
        overflow-x: hidden;
        border-radius: 0;
        box-sizing: border-box;
        animation: slideUp 0.3s ease;
    }
    
    @keyframes slideUp {
        from {
            transform: translateY(100%);
            opacity: 0;
        }
        to {
            transform: translateY(0);
            opacity: 1;
        }
    }
    
    /* Botón close fijo para mobile */
    .close {
        position: fixed !important;
        top: 1rem;
        right: 1rem;
        background: rgba(255, 255, 255, 0.95);
        border-radius: 50%;
        width: 44px;
        height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.5rem;
        font-weight: 400;
        color: #333;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
        border: 1px solid rgba(0, 0, 0, 0.1);
        z-index: 10000;
    }
    
    .close:hover {
        background: rgba(255, 255, 255, 1);
        color: #000;
        transform: scale(1.05);
    }
    
    .patient-modal-content {
        width: 100%;
        max-width: 100%;
        min-width: 100%;
        margin: 0;
        padding: 0;
        padding-top: 70px; /* Espacio para el botón compartir circular */
        overflow-x: hidden;
        box-sizing: border-box;
    }
    
    .patient-modal-split {
        display: block;
        overflow-x: hidden;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    .modal-section {
        padding: 1.5rem !important;
        padding-right: 1.5rem !important; /* Asegurar padding derecho completo */
        overflow-x: hidden;

    /* Botón de egreso en mobile - stack vertical */
    .modal-section h2 {
        margin-bottom: 0.5rem !important;
    }

    #dischargeBtn {
        width: 100%;
        margin-top: 0.5rem;
        padding: 0.6rem 1rem !important;
        font-size: 0.9rem !important;
    }
        word-wrap: break-word;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    /* Arreglar título cortado en móviles */
    .modal-section h2 {
        margin-top: 0.5rem !important;
        padding-top: 0.5rem !important;
        line-height: 1.4 !important;
        font-size: 1.2rem !important;
    }
    
    /* Estilos del botón compartir se manejan dinámicamente en JS */
    
    .modal-section * {
        box-sizing: border-box !important;
        max-width: 100% !important;
    }
    
    .admission-section {
        border-right: none !important;
        border-bottom: 2px solid var(--border-color);
        margin-bottom: 1rem;
    }
    
    .discharge-section {
        background-color: #f8f9fa;
        border-radius: 8px;
        margin: 0.5rem;
    }
    
    .modal-section h2 {
        font-size: 1.1rem;
        margin-bottom: 1.2rem;
        padding-bottom: 0.75rem;
        word-wrap: break-word;
        overflow-wrap: break-word;
        border-bottom: 2px solid var(--border-color);
    }
    
    .patient-info-row {
        display: block;
        width: 100%;
        max-width: 100%;
        padding: 0.5rem 0.75rem;
        margin: 0;
        overflow-x: hidden;
        word-wrap: break-word;
        box-sizing: border-box;
        border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    }
    
    .info-label {
        display: block;
        font-weight: 600;
        font-size: 0.85rem;
        color: var(--text-secondary);
        margin-bottom: 0.3rem;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    .info-value {
        display: block;
        font-size: 0.95rem;
        margin: 0;
        padding: 0.2rem 0;
        word-wrap: break-word;
        overflow-wrap: break-word;
        max-width: 100%;
        width: 100%;
        white-space: normal;
        line-height: 1.4;
        color: var(--text-primary);
    }
    
    /* Textareas específicas que causan overflow */
    #patientObservations,
    #patientPendingTasks,
    textarea {
        width: calc(100% - 1rem) !important;
        max-width: calc(100% - 1rem) !important;
        min-width: 0 !important;
        padding: 0.75rem !important;
        margin: 0.5rem !important;
        border: 1px solid var(--border-color) !important;
        border-radius: 6px !important;
        box-sizing: border-box !important;
        resize: vertical !important;
        font-size: 14px !important;
        overflow-x: hidden !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
    }
    
    .login-content {
        width: 90%;
        max-width: 400px;
    }
    
    /* Botón de guardar observaciones/tareas en móvil */
    .btn.btn-primary {
        width: 100% !important;
        padding: 1rem !important;
        font-size: 1rem !important;
        margin-top: 1rem;
        border-radius: 8px;
    }
    
    /* Mejorar inputs y selects en móviles */
    .discharge-form input,
    .discharge-form select,
    .discharge-form textarea {
        width: 100% !important;
        padding: 0.75rem !important;
        font-size: 16px !important; /* Previene zoom en iOS */
        border-radius: 6px !important;
        margin-bottom: 0.5rem;
    }
    
    /* Toggle de alta programada */
    .form-group[style*="background: #f0f8ff"] {
        margin: 0.5rem !important;
        border-radius: 12px !important;
    }
}
/* Modal de admisión más grande */
.admission-modal .modal-content {
    max-width: 800px;
    width: 90%;
}

/* Hacer que diagnóstico tenga más protagonismo */
#diagnosis {
    font-size: 16px;
    padding: 12px;
}

#diagnosisDetails {
    font-size: 15px;
    padding: 10px;
    min-height: 80px;
}

/* Contenedor de observaciones y pendientes */
.observations-container {
    display: flex;
    gap: 20px;
    margin-top: 1.5rem;
}

.observations-column {
    flex: 1;
}

.observations-column h3 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.observations-column textarea {
    width: 100%;
    min-height: 100px;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    resize: vertical;
    margin-bottom: 1rem;
}

/* Responsive: columnas apiladas en pantallas pequeñas */
@media (max-width: 768px) {
    .observations-container {
        flex-direction: column;
        gap: 10px;
    }
}
/* Estilos para Escala de Rankin */
.rankin-selector {
    display: flex;
    gap: 1rem;
    margin-top: 0.5rem;
    align-items: center;
}

.rankin-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.circle {
    font-size: 1.5rem;
    color: var(--border-color);
    cursor: pointer;
    transition: color 0.3s ease;
    user-select: none;
}

.circle:hover,
.circle.active {
    color: var(--primary-color);
}

.rankin-number {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Mejorar textarea de detalles adicionales */
#dischargeDetails {
    min-height: 100px;
    resize: vertical;
}

#dischargePendingTasks {
    min-height: 80px;
    resize: vertical;
}

/* Espaciado mejorado para autorización */
.discharge-form .form-group:last-of-type {
    margin-bottom: 1.5rem;
}

/* Modal de paciente - definición removida para evitar conflictos */

/* Arreglar alineación de datos de paciente */
.patient-info-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.patient-info-row:last-child {
    border-bottom: none;
}

.info-label {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.9rem;
    flex: 0 0 auto;
    min-width: 120px;
    text-align: left;
}

.info-value {
    color: var(--text-primary);
    font-size: 0.95rem;
    flex: 1;
    text-align: right;
    word-wrap: break-word;
}

/* Para las filas en grid, mantener la alineación */
.grid-info-row {
    display: flex;
    flex-direction: column;
}

.grid-info-row .patient-info-row {
    margin: 0;
    padding: 0.5rem 0;
}

/* Responsive para modal optimizado */
@media (max-width: 1300px) {
    .patient-modal-content {
        width: 60%;
        max-width: 750px;
    }
}

/* Botón compartir mejorado */
.btn-secondary {
    background-color: #6c757d;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.btn-secondary:hover {
    background-color: #5a6268;
}

/* ===================================================================
   MODAL MODULAR - Sistema de Tabs (v3.0.0)
   ================================================================ */

/* Patient Header - Solo para el modal */
.modal .patient-header {
    padding: 2rem 2rem 1rem 2rem;
    border-bottom: 1px solid var(--border-color);
    background: white;
    color: var(--text-primary);
}

.modal .patient-header h2 {
    margin: 0 0 0.5rem 0;
    font-size: 1.6rem;
    font-weight: 600;
}

.modal .patient-meta {
    display: flex;
    gap: 1.5rem;
    font-size: 0.95rem;
    opacity: 0.95;
}

.modal .patient-meta span {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Tabs Navigation */
.modal-tabs {
    display: flex;
    background-color: #f8f9fa;
    border-bottom: 2px solid var(--border-color);
    overflow-x: auto;
}

.tab-btn {
    flex: 1;
    padding: 1rem 1.5rem;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.3s ease;
    position: relative;
    white-space: nowrap;
}

.tab-btn:hover {
    background-color: rgba(102, 126, 234, 0.1);
    color: var(--primary-color);
}

.tab-btn.active {
    background-color: white;
    color: var(--primary-color);
    font-weight: 600;
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
}

/* Tab Contents */
.tab-content {
    display: none;
    padding: 2rem;
    min-height: 400px;
    animation: fadeInTab 0.3s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fadeInTab {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Component Header Styles */
.component-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
}

.component-header h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1.3rem;
    color: var(--text-primary);
}

.component-header .subtitle {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Discharge Component Specific Styles */
.discharge-form-content {
    margin-top: 1.5rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.form-group label.required::after {
    content: ' *';
    color: #dc3545;
}

.form-group input[type="date"],
.form-group input[type="text"],
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.field-hint {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.form-actions .btn {
    flex: 1;
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
}

/* Discharged Info Styles */
.discharged-info {
    padding: 1rem;
}

.alert {
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 1.5rem;
}

.alert-info {
    background-color: #d1ecf1;
    border: 1px solid #bee5eb;
    color: #0c5460;
}

.alert-warning {
    background-color: #fff3cd;
    border: 1px solid #ffeaa7;
    color: #856404;
}

.alert strong {
    display: block;
    margin-bottom: 0.25rem;
    font-size: 1.05rem;
}

.alert p {
    margin: 0;
    font-size: 0.9rem;
}

.info-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background-color: #f8f9fa;
    border-radius: 6px;
    border-left: 3px solid var(--primary-color);
}

.info-row .info-label {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.info-row .info-value {
    color: var(--text-primary);
    font-size: 1rem;
    text-align: right;
}

.discharged-actions {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

/* Responsive - Tabs */
@media (max-width: 768px) {
    .modal .patient-header {
        padding: 1.5rem 1rem 0.75rem 1rem;
    }

    .modal .patient-header h2 {
        font-size: 1.3rem;
    }

    .modal .patient-meta {
        flex-direction: column;
        gap: 0.5rem;
        font-size: 0.85rem;
    }

    .modal-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .tab-btn {
        flex: 0 0 auto;
        padding: 0.875rem 1rem;
        font-size: 0.9rem;
    }

    .tab-content {
        padding: 1.5rem 1rem;
        min-height: 300px;
    }

    .form-actions {
        flex-direction: column;
    }

    .form-actions .btn {
        width: 100%;
    }
}