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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #eef2f5;
    height: 100vh;
    overflow: hidden;
}

.login-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #0078d7 0%, #005a9e 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.login-card {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    width: 340px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    border: 1px solid #c0c0c0;
}

.login-card h2 {
    color: #0078d7;
    margin-bottom: 1.5rem;
    text-align: center;
    font-size: 1.3rem;
}

.login-input-group {
    margin-bottom: 1rem;
}

.login-input-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #2c3e50;
}

.login-input-group input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #c0c0c0;
    border-radius: 4px;
    font-size: 0.9rem;
}

.login-btn {
    width: 100%;
    padding: 10px;
    background: #0078d7;
    color: white;
    border: none;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 1rem;
}

.login-hint {
    text-align: center;
    margin-top: 1rem;
    font-size: 0.75rem;
    color: #6c757d;
}

.app {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: #eef2f5;
}

.hidden {
    display: none !important;
}

.top-bar {
    background: #0078d7;
    color: white;
    padding: 8px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #0063b1;
}

.title {
    font-size: 1.2rem;
    font-weight: 600;
}

.top-right {
    display: flex;
    gap: 20px;
    font-size: 0.85rem;
    align-items: center;
}

.logout-btn-top {
    background: #e67e22;
    padding: 4px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
}

.main-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
    padding: 12px 16px;
    gap: 16px;
}

.patient-list {
    width: 20%;
    background: white;
    border: 1px solid #c0c0c0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.list-header {
    background: #e1e9f0;
    padding: 10px;
    font-weight: 600;
    border-bottom: 1px solid #c0c0c0;
    font-size: 0.9rem;
    color: #1e4663;
}

.search-box {
    padding: 10px;
    border-bottom: 1px solid #c0c0c0;
}

.search-box input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #c0c0c0;
    border-radius: 4px;
    font-size: 0.85rem;
}

.search-results {
    max-height: 200px;
    overflow-y: auto;
    border-bottom: 1px solid #c0c0c0;
    background: white;
}

.search-result-item {
    padding: 8px 12px;
    border-bottom: 1px solid #e1e9f0;
    cursor: pointer;
    font-size: 0.8rem;
}

.search-result-item:hover {
    background: #f0f7ff;
}

.search-result-item .result-name {
    font-weight: 600;
}

.search-result-item .result-dni {
    font-size: 0.7rem;
    color: #6c757d;
}

.pendientes-header {
    background: #e1e9f0;
    padding: 8px 10px;
    font-weight: 600;
    font-size: 0.8rem;
    border-bottom: 1px solid #c0c0c0;
}

.pendientes-container {
    flex: 1;
    overflow-y: auto;
}

.pendiente-item {
    padding: 10px 12px;
    border-bottom: 1px solid #e1e9f0;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: background 0.1s;
}

.pendiente-item:hover {
    background: #f0f7ff;
}

.pendiente-item.attended {
    background: #e8f5e9;
    color: #2e7d32;
}

.pendiente-item.active-patient {
    background: #e3f2fd;
    border-left: 3px solid #0078d7;
}

.pendiente-name {
    font-weight: 600;
}

.pendiente-dni {
    font-size: 0.7rem;
    color: #6c757d;
}

.action-buttons {
    padding: 10px;
    border-top: 1px solid #c0c0c0;
    display: flex;
    gap: 8px;
}

.small-btn {
    flex: 1;
    padding: 6px;
    background: #f0f4f8;
    border: 1px solid #c0c0c0;
    border-radius: 4px;
    font-size: 0.7rem;
    cursor: pointer;
    font-weight: 600;
}

.small-btn:hover {
    background: #e5f0ff;
}

.small-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.work-area {
    width: 80%;
    background: white;
    border: 1px solid #c0c0c0;
    display: flex;
    flex-direction: column;
    overflow-y: auto !important;
    overflow-x: hidden;
    flex: 1;
    min-height: 0;
    max-height: calc(100vh - 100px);
}

.patient-header {
    background: #f0f4f8;
    padding: 12px 20px;
    border-bottom: 1px solid #c0c0c0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    flex-wrap: wrap;
    position: sticky;
    top: 0;
    z-index: 10;
}

.patient-info {
    display: flex;
    gap: 15px;
    align-items: center;
    min-width: 250px;
}

.photo-placeholder {
    width: 48px;
    height: 48px;
    background: #c0d4e8;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}

.patient-name-large {
    font-size: 1.3rem;
    font-weight: 600;
    color: #1e4663;
}

.patient-details {
    color: #5a6e7a;
    font-size: 0.8rem;
}

.patient-actions {
    margin-top: 6px;
    display: flex;
    gap: 12px;
}

.patient-action-btn {
    background: #e9ecef;
    border: 1px solid #c0c0c0;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
}

.patient-action-btn:hover {
    background: #e5f0ff;
}

.patient-action-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #e9ecef;
}

.header-right {
    flex: 1;
    min-width: 400px;
}

.contacto-header {
    background: #e9ecef;
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 10px;
}

.contacto-header .titulo, .ante-header .titulo, .rams-header .titulo, .muh-header .titulo {
    font-weight: 600;
    color: #0078d7;
    margin-bottom: 6px;
    font-size: 0.8rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.edit-btn-small {
    background: none;
    border: 1px solid #c0c0c0;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.65rem;
    cursor: pointer;
}

.edit-btn-small:hover {
    background: #e5f0ff;
}

.contacto-fila {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.contacto-item {
    flex: 1;
    min-width: 120px;
}

.contacto-item label {
    font-size: 0.6rem;
    color: #6c757d;
    display: block;
}

.contacto-item input {
    width: 100%;
    border: 1px solid #c0c0c0;
    padding: 4px 6px;
    font-size: 0.75rem;
    border-radius: 3px;
    background: #f8f9fa;
}

.contacto-item input:not([disabled]) {
    background: white;
}

.edad-text {
    font-size: 0.75rem;
    color: #2c3e50;
    background: #e9ecef;
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-block;
}

.cabecera-tres-columnas {
    display: flex;
    gap: 12px;
    margin-top: 5px;
}

.ante-col {
    flex: 2;
}

.rams-col {
    flex: 1;
}

.muh-col {
    flex: 1;
}

.ante-header, .rams-header, .muh-header {
    background: #f8f9fa;
    padding: 8px;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
}

.ante-header textarea, .rams-header textarea, .muh-header textarea {
    width: 100%;
    border: 1px solid #c0c0c0;
    padding: 6px;
    font-size: 0.75rem;
    font-family: 'Segoe UI', monospace;
    resize: vertical;
    background: #f8f9fa;
}

.ante-header textarea:not([disabled]), .rams-header textarea:not([disabled]), .muh-header textarea:not([disabled]) {
    background: white;
}

.inner-work {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.tabs-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.tabs-header {
    display: flex;
    background: #f0f4f8;
    border-bottom: 1px solid #c0c0c0;
    padding-left: 8px;
    gap: 2px;
}

.tab {
    background: #e4eaf1;
    border: none;
    padding: 10px 20px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    color: #2c3e50;
}

.tab.active {
    background: white;
    border-bottom: 2px solid #0078d7;
    color: #0078d7;
}

.tab-content {
    flex: 1;
    overflow-y: auto !important;
    padding: 20px;
    min-height: 0;
}

.tab-pane {
    display: none;
}

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

.atencion-layout {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.anamnesis-col {
    flex: 0.7;
}

.signos-col {
    flex: 0.3;
}

.seccion-grupo {
    border: 1px solid #d0d8e5;
    padding: 15px;
    background: white;
    margin-bottom: 15px;
}

.seccion-titulo {
    font-weight: 600;
    color: #0078d7;
    margin-bottom: 12px;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 6px;
    font-size: 0.9rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.text-area-anamnesis {
    width: 100%;
    height: 250px;
    border: 1px solid #c0c0c0;
    padding: 10px;
    font-family: 'Segoe UI', monospace;
    font-size: 0.85rem;
    resize: vertical;
}

.data-line {
    margin-bottom: 12px;
    font-size: 0.85rem;
}

.data-label {
    font-weight: 600;
    display: inline-block;
    width: 70px;
}

.vital-input {
    border: 1px solid #c0c0c0;
    padding: 5px 8px;
    width: 80px;
}

.vital-input:disabled {
    background: #f8f9fa;
}

.pa-group {
    display: inline-flex;
    gap: 5px;
    align-items: center;
}

.pa-group input {
    width: 55px;
}

.cie-row {
    display: flex;
    gap: 10px;
    margin-bottom: 8px;
    align-items: center;
}

.cie-search-container {
    position: relative;
    flex: 3;
}

.cie-busqueda {
    width: 100%;
    border: 1px solid #c0c0c0;
    padding: 6px;
}

.cie-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #c0c0c0;
    border-top: none;
    max-height: 150px;
    overflow-y: auto;
    z-index: 100;
    display: none;
}

.cie-suggestion-item {
    padding: 6px 10px;
    cursor: pointer;
    font-size: 0.8rem;
}

.cie-suggestion-item:hover,
.cie-suggestion-item.selected {
    background: #e5f0ff;
}

.cie-suggestion-item .cie-codigo-sug {
    font-family: monospace;
    color: #0078d7;
    font-weight: 600;
    margin-right: 8px;
}

.cie-codigo {
    flex: 1;
    background: #e9ecef;
    border: 1px solid #c0c0c0;
    padding: 6px;
    font-family: monospace;
    color: #2c3e50;
    tabindex: -1;
}

.med-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    align-items: center;
}

.med-search-container {
    position: relative;
    flex: 2;
}

.med-nombre {
    width: 100%;
    border: 1px solid #c0c0c0;
    padding: 5px;
}

.med-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #c0c0c0;
    border-top: none;
    max-height: 150px;
    overflow-y: auto;
    z-index: 100;
    display: none;
}

.med-suggestion-item {
    padding: 6px 10px;
    cursor: pointer;
    font-size: 0.8rem;
}

.med-suggestion-item:hover,
.med-suggestion-item.selected {
    background: #e5f0ff;
}

.med-cantidad { flex: 1; border: 1px solid #c0c0c0; padding: 5px; }
.med-presentacion-text { width: 80px; background: #e9ecef; padding: 5px; border: 1px solid #c0c0c0; text-align: center; font-size: 0.75rem; tabindex: -1; }
.med-posologia { flex: 2; border: 1px solid #c0c0c0; padding: 5px; }

.lab-row, .img-row {
    margin-bottom: 8px;
}

.lab-row input, .img-row input {
    width: 100%;
    border: 1px solid #c0c0c0;
    padding: 6px;
}

.accion-final {
    display: flex;
    gap: 12px;
    margin-top: 15px;
    justify-content: flex-end;
}

.btn-guardar {
    background: #0078d7;
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
}

.btn-guardar:disabled {
    background: #c0c0c0;
    cursor: not-allowed;
}

.btn-imprimir-combinado {
    background: #28a745;
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
}

.btn-imprimir-combinado:disabled {
    background: #c0c0c0;
    cursor: not-allowed;
}

.historial-item {
    border: 1px solid #d0d8e5;
    margin-bottom: 15px;
    background: white;
}

.historial-fecha {
    background: #e1e9f0;
    padding: 10px;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.85rem;
}

.historial-detalle {
    display: none;
    padding: 15px;
}

.historial-detalle.mostrar {
    display: block;
}

.historial-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
}

.historial-anamnesis {
    width: 100%;
    margin-bottom: 10px;
}

.historial-anamnesis h5 { color: #0078d7; margin-bottom: 5px; font-size: 0.85rem; }
.historial-anamnesis p { background: #f8f9fa; padding: 10px; border: 1px solid #e0e0e0; border-radius: 4px; font-size: 0.8rem; }
.historial-medicamentos { width: 48%; }
.historial-lab-img { width: 48%; }
.historial-medicamentos h5, .historial-lab-img h5 {
    color: #0078d7;
    margin-bottom: 5px;
    font-size: 0.8rem;
}
.historial-medicamentos p, .historial-lab-img p {
    background: #f8f9fa;
    padding: 8px;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    font-size: 0.75rem;
    margin-bottom: 8px;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 3000;
}

.modal-content {
    background: white;
    padding: 20px;
    border-radius: 8px;
    width: 380px;
}

.modal-content h3 {
    color: #0078d7;
    margin-bottom: 15px;
}

.modal-content input, .modal-content select {
    width: 100%;
    padding: 8px;
    margin-bottom: 10px;
    border: 1px solid #c0c0c0;
    border-radius: 4px;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 15px;
}

.btn-primary {
    background: #0078d7;
    color: white;
    border: none;
    padding: 6px 16px;
    border-radius: 4px;
    cursor: pointer;
}

.btn-secondary {
    background: #e9ecef;
    border: 1px solid #c0c0c0;
    padding: 6px 16px;
    border-radius: 4px;
    cursor: pointer;
}

.admin-panel {
    padding: 20px;
    height: 100%;
    overflow-y: auto;
}

.admin-section {
    margin-bottom: 30px;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 15px;
    background: #f9f9f9;
}

.admin-section h3 {
    margin-bottom: 15px;
    color: #0078d7;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table th, .admin-table td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: left;
}

.admin-table th {
    background: #f0f4f8;
}

.admin-table button {
    margin: 0 2px;
    padding: 2px 8px;
    cursor: pointer;
}

.btn-agregar {
    background: #28a745;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    margin-bottom: 10px;
}

.tab-admin {
    display: flex;
    gap: 2px;
    margin-bottom: 15px;
    border-bottom: 1px solid #ddd;
}

.tab-admin-btn {
    padding: 8px 16px;
    background: #e9ecef;
    border: none;
    cursor: pointer;
    font-weight: 600;
}

.tab-admin-btn.active {
    background: #0078d7;
    color: white;
}

.admin-content {
    display: none;
}

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

/* Scroll para el área de trabajo */
.work-area {
    overflow-y: auto !important;
}

.tab-content {
    overflow-y: auto !important;
}

.pendientes-container {
    overflow-y: auto !important;
}

/* ============================================
   ESTILOS CONSISTENTES PARA HISTORIAL
   ============================================ */

.historial-diagnosticos,
.historial-medicamentos,
.historial-lab-img,
.historial-signos {
    background: #f8f9fa;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 10px;
}

.historial-diagnosticos h5,
.historial-medicamentos h5,
.historial-lab-img h5,
.historial-signos h5 {
    color: #0078d7;
    margin-bottom: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 5px;
}

.historial-diagnosticos p,
.historial-medicamentos p,
.historial-lab-img p,
.historial-signos p {
    color: #2c3e50;
    font-size: 0.8rem;
    line-height: 1.4;
    margin: 0;
}

.historial-anamnesis {
    background: #f8f9fa;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 10px;
}

.historial-anamnesis h5 {
    color: #0078d7;
    margin-bottom: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 5px;
}

.historial-anamnesis p {
    color: #2c3e50;
    font-size: 0.8rem;
    line-height: 1.4;
    margin: 0;
}

.historial-fecha {
    background: #e1e9f0;
    padding: 10px 15px;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.85rem;
    color: #1e4663;
    border-radius: 8px 8px 0 0;
}

.historial-item {
    border: 1px solid #d0d8e5;
    margin-bottom: 15px;
    border-radius: 8px;
    overflow: hidden;
    background: white;
}

.historial-detalle {
    padding: 15px;
    background: white;
}

.historial-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Asegurar scroll en todo el contenido */
.work-area {
    overflow-y: auto !important;
}

.tab-content {
    overflow-y: auto !important;
}

.patient-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #f0f4f8;
}

/* ============================================
   DISTRIBUCIÓN DE 2 COLUMNAS PARA HISTORIAL
   ============================================ */

.historial-row-2cols {
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.historial-row-2cols > div {
    flex: 1;
    min-width: 200px;
    background: #f8f9fa;
    padding: 12px;
    border-radius: 8px;
}

/* Ajustes responsive para pantallas pequeñas */
@media (max-width: 768px) {
    .historial-row-2cols {
        flex-direction: column;
        gap: 12px;
    }
    
    .historial-row-2cols > div {
        width: 100%;
    }
}

/* Estilo para input type date */
input[type="date"] {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    padding: 4px 6px;
    font-size: 0.75rem;
    border: 1px solid #c0c0c0;
    border-radius: 3px;
    background: #f8f9fa;
}

input[type="date"]:not([disabled]) {
    background: white;
}

input[type="date"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
}

/* Estilos para documentos */
.historial-documentos {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 8px;
    margin-top: 12px;
}

.historial-documentos h5 {
    color: #0078d7;
    margin-bottom: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 5px;
}

.historial-documentos p {
    color: #2c3e50;
    font-size: 0.8rem;
    line-height: 1.4;
    margin: 0;
}

.historial-documentos a {
    display: inline-block;
    margin: 2px 0;
}

.historial-documentos a:hover {
    text-decoration: underline;
}

/* Scroll para pendientes */
.pendientes-container {
    overflow-y: auto !important;
    max-height: calc(100vh - 280px);
    min-height: 200px;
}

/* Asegurar que la lista de pacientes también tenga scroll */
.patients-container {
    overflow-y: auto !important;
    max-height: calc(100vh - 250px);
}
