/* --- Reseteo Básico y Variables CSS --- */
:root {
    --primary-color: #3498db; /* Azul */
    --secondary-color: #2ecc71; /* Verde */
    --danger-color: #e74c3c; /* Rojo */
    --light-bg: #f8f9fa;
    --dark-text: #34495e;
    --light-text: #7f8c8d;
    --border-color: #e0e0e0;
    --panel-bg: #ffffff;
    --hover-bg: #ecf0f1;
    --active-bg: #dbeafc; /* Azul muy claro para activo */
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    background-color: var(--light-bg);
    color: var(--dark-text);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* --- Encabezado de la Aplicación --- */
.app-header {
    background-color: var(--primary-color);
    color: white;
    padding: 15px 30px;
    display: flex;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.app-header h1 {
    font-size: 1.5rem;
    margin: 0;
    flex-grow: 1; /* Empuja el input a la derecha */
    margin-left: 15px; /* Espacio después del icono */
}

.header-icon {
    font-size: 1.8rem;
}

.institution-input input[type="text"] {
    padding: 8px 10px;
    border: none;
    border-radius: 4px;
    background-color: rgba(255, 255, 255, 0.9);
    color: var(--dark-text);
    font-size: 0.9rem;
    min-width: 250px;
}
.institution-input input[type="text"]::placeholder {
    color: var(--light-text);
}

/* --- Contenedor Principal (Paneles) --- */
.app-container {
    display: flex;
    flex-grow: 1; /* Ocupa el espacio restante */
    overflow: hidden; /* Evita scroll doble */
    padding: 20px;
    gap: 20px; /* Espacio entre paneles */
}

/* --- Estilos Comunes de Paneles --- */
.panel {
    background-color: var(--panel-bg);
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Contenido interno scrollable si es necesario */
}

.panel-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #fdfdfe; /* Ligeramente diferente para destacar */
}

.panel-header h2 {
    font-size: 1.1rem;
    color: var(--primary-color);
    margin: 0;
}

.panel-header h2 i {
    margin-right: 8px;
}

/* --- Panel Izquierdo (Lista) --- */
.list-panel {
    flex: 0 0 300px; /* Ancho fijo */
    max-width: 300px;
}

.patient-list {
    list-style: none;
    padding: 0;
    flex-grow: 1; /* Ocupa el espacio */
    /* overflow-y: auto; */ /* Scroll handled by container on mobile */
    margin: 0;
}

.patient-list li {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background-color 0.2s ease;
    font-size: 0.95rem;
}

.patient-list li:hover {
    background-color: var(--hover-bg);
}

.patient-list li.active {
    background-color: var(--active-bg);
    font-weight: bold;
    color: var(--primary-color);
}

.patient-list li .list-icon {
    margin-right: 10px;
    color: var(--primary-color);
    width: 20px; /* Alineación */
    text-align: center;
}
.patient-list li.active .list-icon {
    color: var(--primary-color);
}


.patient-list li span {
    flex-grow: 1; /* Empuja la flecha a la derecha */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.patient-list li .arrow-icon {
    color: var(--light-text);
    margin-left: 10px;
}

/* --- Panel Derecho (Detalles) --- */
.detail-panel {
    flex: 1; /* Ocupa el espacio restante */
    /* overflow-y: auto; */ /* Scroll handled by container on mobile */
    padding: 20px;
}

.placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: var(--light-text);
}

.placeholder i {
    font-size: 3rem;
    margin-bottom: 15px;
    color: #bdc3c7; /* Gris claro */
}

/* --- Estilos del Formulario --- */
#patient-form {
    /* display: block; */ /* Se controla con .hidden */
}

.form-section {
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px dashed var(--border-color);
}
.form-section:last-of-type {
    border-bottom: none;
     margin-bottom: 0;
}


.form-section h3 {
    font-size: 1rem;
    color: var(--primary-color);
    margin-bottom: 15px;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
}

.form-section h3 i {
    margin-right: 8px;
}

.form-grid {
    display: grid;
    gap: 15px;
}
.two-cols { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.three-cols { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

.form-group {
    margin-bottom: 10px; /* Espacio dentro de la grilla */
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    font-size: 0.85rem;
    color: #555;
}
.form-group label i {
    margin-right: 5px;
    width: 15px; /* Alineación */
    text-align: center;
    color: var(--light-text);
}

.form-group input[type="text"],
.form-group input[type="date"],
.form-group input[type="number"],
.form-group textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.9rem;
    transition: border-color 0.2s ease;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

.form-group textarea {
    resize: vertical;
    min-height: 60px;
}

/* --- Estilos específicos Índices --- */
.indices-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 20px;
}
.index-group h4 {
    font-size: 0.9rem;
    text-align: center;
    margin-bottom: 10px;
    color: var(--secondary-color); /* Verde */
}
.index-group .form-group label {
    display: inline-block; /* Poner Reg/Dg al lado del input */
    margin-right: 5px;
    width: auto; /* Ancho automático */
    font-weight: normal;
}
.index-group .form-group input {
    display: inline-block;
    width: calc(100% - 40px); /* Ajustar ancho para que quepa la etiqueta */
    padding: 5px 8px; /* Más pequeño */
    text-align: center;
}

/* --- Acciones del Formulario --- */
.form-actions {
    margin-top: 25px;
    display: flex;
    justify-content: flex-end; /* Botones a la derecha */
    gap: 10px;
}

.save-status {
    text-align: right;
    font-size: 0.85rem;
    color: var(--secondary-color);
    margin-top: 10px;
    min-height: 1.2em; /* Para evitar saltos de layout */
}


/* --- Estilos Comunes de Botones --- */
.btn {
    padding: 10px 15px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
    display: inline-flex; /* Alinear icono y texto */
    align-items: center;
    justify-content: center;
    gap: 8px; /* Espacio entre icono y texto */
}

.btn i {
    /* font-size: 1rem; */ /* Tamaño del icono dentro del botón */
}

.btn-primary { background-color: var(--primary-color); color: white; }
.btn-primary:hover { background-color: #2980b9; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }

.btn-secondary { background-color: #7f8c8d; color: white; }
.btn-secondary:hover { background-color: #6c7a89; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }

.btn-success { background-color: var(--secondary-color); color: white; }
.btn-success:hover { background-color: #27ae60; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }

.btn-danger { background-color: var(--danger-color); color: white; }
.btn-danger:hover { background-color: #c0392b; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }

.btn-full-width {
    display: flex; /* Ocupa todo el ancho */
    width: calc(100% - 40px); /* Ajustar por padding del panel */
    margin: 20px;
}


/* --- Utilidades --- */
.hidden {
    display: none !important;
}

/* --- Responsividad --- */
@media (max-width: 768px) {
    .app-header {
        flex-direction: column;
        align-items: flex-start;
        padding: 15px;
    }
    .app-header h1 {
        margin-left: 0;
        margin-top: 10px;
        margin-bottom: 10px;
    }
    .institution-input {
        width: 100%;
        margin-top: 10px;
    }
     .institution-input input[type="text"] {
         width: 100%;
     }

    .app-container {
        flex-direction: column;
        padding: 10px;
        gap: 10px;
        overflow-y: auto; /* Make container scrollable */
        /* Let body flex handle height */
    }
    .list-panel {
        flex: 0 0 auto; /* No fijo, altura automática */
        max-width: 100%;
        /* max-height: 30vh; */ /* REMOVED */
        overflow: visible; /* Allow content to determine height */
    }
     .patient-list {
         overflow-y: visible; /* Don't scroll list independently */
     }
    .detail-panel {
         flex: 0 0 auto; /* Height based on content */
         /* max-height: calc(70vh - 100px); */ /* REMOVED */
         overflow: visible; /* Allow content to determine height */
    }
    .form-grid.two-cols,
    .form-grid.three-cols,
    .indices-grid {
        grid-template-columns: 1fr; /* Una columna en móvil */
    }
    .form-actions {
        flex-direction: column; /* Botones apilados */
    }
     .form-actions .btn {
         width: 100%;
     }
}
/* --- Centered Notification --- */
.center-notification {
    display: none; /* Hidden by default */
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #4CAF50; /* Green background */
    color: white;
    padding: 15px 30px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    z-index: 9999; /* Ensure it's on top of everything */
    font-size: 1.1em;
    text-align: center;
    opacity: 0; /* Start fully transparent */
    transition: opacity 0.5s ease-in-out; /* Fade effect */
}

.center-notification.show {
    display: block; /* Make it visible */
    opacity: 1; /* Fade in */
}