:root {
	--primary-color: #3f9d6e;
	--primary-dark: #2c7b52;
	--secondary-color: #4287f5;
	--text-color: #333;
	--light-gray: #f5f5f5;
	--border-color: #e0e0e0;
	--error-color: #e74c3c;
	--success-color: #2ecc71;
	--warning-color: #f39c12;
}

* {
	box-sizing: border-box;
}

body {
	font-family: 'Roboto', 'Helvetica Neue', 'Helvetica', Arial, sans-serif;
	font-size: 16px;
	line-height: 1.5;
	color: var(--text-color);
	background-color: #f9f9f9;
}

/* Header Styles */
header {
	background-color: var(--primary-color);
	min-height: 4em;
	color: #fff;
	margin-bottom: 1.5em;
	box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
	padding: 0.5em 0;
	display: flex;
	align-items: center;
}

header h1 {
	font-size: clamp(1.2em, 4vw, 2em);
	font-weight: 700;
	display: inline-block;
	vertical-align: middle;
	word-break: break-word;
}

header h2 {
	font-size: clamp(1em, 3.5vw, 1.8em);
	display: inline-block;
	vertical-align: middle;
}

header .container:before {
	content: '';
	display: inline-block;
	height: 100%;
	vertical-align: middle;
}

.container {
	width: 90%;
	max-width: 1200px;
	height: 100%;
	margin: 0 auto;
}

@media screen and (max-width: 768px) {
	header {
		padding: 0.7em 0;
	}

	header h1 {
		font-size: 1.5em;
	}

	.container {
		width: 95%;
	}
}

@media screen and (max-width: 480px) {
	header {
		padding: 0.8em 0;
		margin-bottom: 1em;
	}

	header h1 {
		font-size: 1.3em;
	}

	header .fa-heartbeat {
		margin-right: 5px;
	}

	.container {
		width: 92%;
	}
}

/* Section Styles */
section {
	margin: 1.5em 0;
	overflow: hidden;
	background-color: #fff;
	border-radius: 8px;
	box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
	padding: 1.5em;
}

section h2 {
	font-size: 2em;
	font-weight: 500;
	display: block;
	padding-bottom: 0.5em;
	border-bottom: 1px solid var(--border-color);
	margin-bottom: 0.8em;
	color: var(--primary-color);
}

@media screen and (max-width: 768px) {
	section {
		margin: 1.2em 0;
		padding: 1.2em;
	}

	section h2 {
		font-size: 1.6em;
		padding-bottom: 0.4em;
		margin-bottom: 0.6em;
	}
}

@media screen and (max-width: 480px) {
	section {
		margin: 1em 0;
		padding: 1em;
		border-radius: 6px;
	}

	section h2 {
		font-size: 1.4em;
		padding-bottom: 0.3em;
		margin-bottom: 0.5em;
	}
}

/* Table Styles */
.table-container {
	overflow-x: auto;
	margin-bottom: 1em;
	border-radius: 5px;
	transition: height 0.5s ease-out;
	-webkit-overflow-scrolling: touch; /* Improves scrolling on iOS */
	box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

table {
	width: 100%;
	margin-bottom: 0.5em;
	table-layout: fixed;
	border-collapse: separate;
	border-spacing: 0;
	border: 1px solid var(--border-color);
	border-radius: 5px;
	min-width: 650px; /* Ensures horizontal scroll on small screens */
}

td,
th {
	padding: 0.8em;
	margin: 0;
	border-bottom: 1px solid var(--border-color);
	text-align: center;
	word-break: break-word;
}

th {
	font-weight: 600;
	background-color: var(--light-gray);
	color: var(--primary-color);
	position: sticky;
	top: 0;
}

tr:hover {
	background-color: rgba(63, 157, 110, 0.05);
}

.paciente {
	transition: all 0.3s ease;
}

/* Responsive table styles */
@media screen and (max-width: 992px) {
	td,
	th {
		padding: 0.7em 0.5em;
		font-size: 0.95em;
	}

	table {
		min-width: 600px;
	}
}

@media screen and (max-width: 768px) {
	.table-container {
		border: 1px solid var(--border-color);
		border-radius: 8px;
		box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
		margin-top: 0.5em;
	}

	table {
		min-width: 580px;
	}

	th {
		font-size: 0.9em;
		position: sticky;
		top: 0;
		background-color: var(--light-gray);
		z-index: 1;
	}

	td {
		font-size: 0.9em;
		padding: 0.6em 0.4em;
	}
}

@media screen and (max-width: 480px) {
	.table-container {
		margin-top: 0.8em;
	}

	table {
		min-width: 550px;
	}

	th,
	td {
		padding: 0.5em 0.3em;
		font-size: 0.85em;
	}
}

/* Form Styles */
.form-container {
	background-color: #fff;
	padding: 1.5em;
	border-radius: 8px;
}

.form-row {
	display: flex;
	flex-wrap: wrap;
	margin-bottom: 1em;
	gap: 1rem;
}

label {
	color: #555;
	display: block;
	margin-bottom: 0.5em;
	font-weight: 500;
}

.campo {
	margin: 0;
	width: 100%;
	border: 1px solid var(--border-color);
	border-radius: 4px;
	padding: 0.8em;
	font-size: 0.95em;
	transition: border-color 0.3s ease;
	-webkit-appearance: none;
}

.campo:focus {
	outline: none;
	border-color: var(--primary-color);
	box-shadow: 0 0 0 2px rgba(63, 157, 110, 0.2);
}

.campo-medio {
	display: inline-block;
	padding-right: 0;
	width: 100%;
}

.grupo {
	width: 48%;
	padding: 10px 10px 10px 0;
}

.form-actions {
	display: flex;
	justify-content: flex-end;
	gap: 10px;
	margin-top: 1em;
}

/* Formulario responsivo */
@media screen and (max-width: 992px) {
	.form-row {
		gap: 0.8rem;
	}
}

@media screen and (max-width: 768px) {
	.form-container {
		padding: 1.2em;
	}

	.form-row {
		flex-direction: column;
		gap: 0.5rem;
	}

	.grupo {
		width: 100%;
		padding: 5px 0;
	}

	.campo-medio {
		width: 100%;
	}

	.form-actions {
		flex-direction: row;
		justify-content: space-between;
	}

	.form-actions button {
		min-width: 45%;
	}
}

@media screen and (max-width: 480px) {
	.form-container {
		padding: 1em;
	}

	.form-actions {
		flex-direction: column-reverse;
		gap: 0.8rem;
	}

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

	label {
		font-size: 0.95em;
	}

	.campo {
		padding: 0.7em;
		font-size: 16px; /* Prevents iOS zoom on focus */
	}
}

/* Button Styles */
button {
	padding: 0.8em 1.5em;
	border: 0;
	border-radius: 4px;
	font-size: 1em;
	font-weight: 500;
	cursor: pointer;
	transition: all 0.2s ease;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
}

.boton {
	margin: 10px 0;
}

.bto-principal {
	background-color: var(--primary-color);
	color: white;
}

.bto-principal:hover {
	background-color: var(--primary-dark);
	transform: translateY(-2px);
	box-shadow: 0 3px 5px rgba(0, 0, 0, 0.1);
}

.bto-secundario {
	background-color: #e0e0e0;
	color: #555;
}

.bto-secundario:hover {
	background-color: #d0d0d0;
}

button:active {
	transform: translateY(1px);
}

button[disabled='disabled'],
button:disabled {
	background-color: #cccccc;
	color: #999;
	cursor: not-allowed;
}

/* Container to action buttons */
.button-container {
	display: flex;
	gap: 1rem;
	flex-wrap: wrap;
	margin: 1rem 0;
}

@media screen and (max-width: 768px) {
	.button-container {
		flex-direction: column;
		width: 100%;
	}

	.button-container button {
		width: 100%;
	}

	button {
		padding: 0.7em 1.2em;
		font-size: 0.95em;
	}
}

@media screen and (max-width: 480px) {
	.button-container {
		margin: 0.8rem 0;
		gap: 0.8rem;
	}

	button {
		padding: 0.7em 1em;
		font-size: 0.9em;
	}

	.boton {
		margin: 5px 0;
	}
}

/* Search Styles */
.search-container {
	display: flex;
	align-items: center;
	margin-bottom: 1em;
	position: relative;
	width: 100%;
	max-width: 400px;
}

.search-container label {
	position: absolute;
	left: 12px;
	color: #999;
	margin-bottom: 0;
}

#filtrar-tabla {
	width: 100%;
	height: 40px;
	padding-left: 35px;
	border: 1px solid var(--border-color);
	border-radius: 20px;
	font-size: 0.95em;
	transition: all 0.3s ease;
}

#filtrar-tabla:focus {
	outline: none;
	border-color: var(--primary-color);
	box-shadow: 0 0 0 2px rgba(63, 157, 110, 0.2);
}

@media screen and (max-width: 768px) {
	.search-container {
		max-width: 100%;
	}
}

@media screen and (max-width: 480px) {
	.search-container {
		margin-bottom: 0.8em;
	}

	#filtrar-tabla {
		height: 38px;
		font-size: 0.9em;
	}
}

/* Message Styles */
.message-container {
	margin: 1em 0;
	width: 100%;
}

#mensajes-errores {
	color: var(--error-color);
	padding: 0.5em 0;
	list-style-type: disc;
	margin-left: 1.5em;
}

#mensajes-errores li {
	margin-bottom: 0.3em;
}

.error-message {
	color: var(--error-color);
	background-color: rgba(231, 76, 60, 0.1);
	padding: 0.8em;
	border-radius: 4px;
	display: inline-block;
	margin-top: 0.5em;
	width: 100%;
}

.success-message {
	color: var(--success-color);
	background-color: rgba(46, 204, 113, 0.1);
	padding: 0.8em;
	border-radius: 4px;
	display: inline-block;
	margin-top: 0.5em;
	width: 100%;
}

@media screen and (max-width: 768px) {
	.message-container {
		margin: 0.8em 0;
	}

	#mensajes-errores {
		margin-left: 1.2em;
		font-size: 0.95em;
	}

	.error-message,
	.success-message {
		padding: 0.7em;
		font-size: 0.95em;
		text-align: center;
	}
}

@media screen and (max-width: 480px) {
	.message-container {
		margin: 0.6em 0;
	}

	#mensajes-errores {
		margin-left: 1em;
		font-size: 0.9em;
	}

	.error-message,
	.success-message {
		padding: 0.6em;
		font-size: 0.9em;
	}
}

/* Status Indicators */
.campo-invalido {
	border: 1px solid var(--error-color);
	background-color: rgba(231, 76, 60, 0.05);
}

.paciente-incorrecto {
	background-color: rgba(231, 76, 60, 0.1);
}

/* Animations */
.fadeOut {
	opacity: 0;
	transform: translateX(20px);
	transition: all 0.5s ease;
}

/* Animación para eliminar pacientes */
.paciente-eliminado {
	animation: eliminarPaciente 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
	pointer-events: none;
	overflow: hidden;
	box-sizing: border-box;
}

@keyframes eliminarPaciente {
	0% {
		opacity: 1;
		transform: translateY(0) scale(1);
		background-color: rgba(231, 76, 60, 0.05);
		max-height: 65px;
		margin-top: 0;
		margin-bottom: 0;
		border-width: 1px;
		padding: 0.8em;
	}
	20% {
		opacity: 0.9;
		transform: translateY(-5px) scale(0.98);
		background-color: rgba(231, 76, 60, 0.1);
	}
	60% {
		opacity: 0.4;
		max-height: 45px;
		margin-top: 0;
		margin-bottom: 0;
		border-width: 1px;
		transform: translateY(5px) scale(0.95);
		background-color: rgba(231, 76, 60, 0.15);
	}
	100% {
		opacity: 0;
		max-height: 0px;
		padding-top: 0;
		padding-bottom: 0;
		margin-top: 0;
		margin-bottom: 0;
		border-width: 0;
		transform: translateY(10px) scale(0.95);
		background-color: rgba(231, 76, 60, 0.2);
	}
}

.invisible {
	display: none;
}

/* Responsive Styles */
@media screen and (max-width: 768px) {
	.container {
		width: 95%;
	}

	.grupo {
		width: 100%;
	}

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

	#filtrar-tabla,
	#filtrar-tabla:focus {
		width: 100%;
	}

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

	button {
		width: 100%;
	}

	.container {
		flex-direction: column;
		gap: 1em;
		text-align: center;
	}

	section h2 {
		font-size: 1.5em;
	}

	th,
	td {
		padding: 0.5em 0.3em;
		font-size: 0.9em;
	}
}

/* Estado IMC adicional para tabla de pacientes */
.estado-imc {
	font-weight: bold;
}

.peso-bajo {
	color: var(--warning-color);
}

.peso-normal {
	color: var(--success-color);
}

.sobrepeso {
	color: var(--warning-color);
}

.obesidad {
	color: var(--error-color);
}

/* Estilos para el modal de edición */
.modal {
	display: none;
	position: fixed;
	z-index: 1000;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background-color: rgba(0, 0, 0, 0.5);
	align-items: center;
	justify-content: center;
	overflow: auto;
}

/* Animaciones para el modal */
.modal-contenido {
	background-color: white;
	border-radius: 8px;
	max-width: 600px;
	width: 90%;
	box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
	animation: modalIn 0.3s ease;
	transition: transform 0.3s ease, opacity 0.3s ease;
}

.modal-salida .modal-contenido {
	animation: none;
	transform: translateY(20px);
	opacity: 0;
}

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

.modal-header {
	padding: 1rem 1.5rem;
	border-bottom: 1px solid var(--border-color);
	display: flex;
	justify-content: space-between;
	align-items: center;
}

.modal-header h3 {
	font-size: 1.3rem;
	color: var(--primary-color);
	font-weight: 500;
	display: flex;
	align-items: center;
	gap: 0.5rem;
}

.boton-cerrar {
	background: none;
	border: none;
	font-size: 1.2rem;
	color: #999;
	cursor: pointer;
	padding: 5px;
	transition: all 0.2s ease;
}

.boton-cerrar:hover {
	color: var(--error-color);
	transform: scale(1.1);
}

.modal-body {
	padding: 1.5rem;
}

.modal-footer {
	padding: 1rem 1.5rem;
	border-top: 1px solid var(--border-color);
	display: flex;
	justify-content: flex-end;
	gap: 0.8rem;
}

#editar-mensajes-errores {
	color: var(--error-color);
	list-style-type: disc;
	margin-left: 1.5em;
	margin-top: 0.5em;
}

#editar-mensajes-errores li {
	margin-bottom: 0.3em;
}

/* Estilos para botones de acción en tabla */
.acciones-paciente {
	display: flex;
	gap: 0.5rem;
	justify-content: center;
}

.boton-accion {
	background: none;
	border: none;
	cursor: pointer;
	padding: 6px;
	border-radius: 4px;
	transition: all 0.2s ease;
}

.editar-btn {
	color: var(--secondary-color);
}

.editar-btn:hover {
	background-color: rgba(66, 135, 245, 0.1);
	transform: scale(1.1);
}

.eliminar-btn {
	color: var(--error-color);
}

.eliminar-btn:hover {
	background-color: rgba(231, 76, 60, 0.1);
	transform: scale(1.1);
}

/* Efectos de actualización */
.paciente-actualizado {
	animation: actualizado 1s ease;
}

@keyframes actualizado {
	0%,
	100% {
		background-color: transparent;
	}
	50% {
		background-color: rgba(46, 204, 113, 0.2);
	}
}

/* Responsive para modal */
@media screen and (max-width: 768px) {
	.modal-contenido {
		width: 95%;
		margin: 10px;
	}
}

/* Estilos específicos para el modal de confirmación */
.modal-confirmacion {
	max-width: 450px;
}

.mensaje-confirmacion {
	font-size: 1.1rem;
	text-align: center;
	color: var(--text-color);
	margin: 1rem 0;
	line-height: 1.5;
}

/* Botón de eliminación */
.bto-error {
	background-color: var(--error-color);
	color: white;
}

.bto-error:hover {
	background-color: #c0392b;
	transform: translateY(-2px);
	box-shadow: 0 3px 5px rgba(0, 0, 0, 0.1);
}
