/* Ajustes generales */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, sans-serif;
    line-height: 1.5;
    color: #333;
    background-color: #f5f6f7;
}

main {
    width: 95%;
    max-width: 1200px;
    margin: 25px auto;
    padding: 20px;
    background-color: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
}

/* Títulos y enlaces */
h2 {
    margin-top: 0;
    margin-bottom: 20px;
    color: #292929;
}

h3 {
    margin-top: 25px;
    margin-bottom: 12px;
}

a {
    color: #1769aa;
}

a:hover {
    text-decoration: none;
}

/* Botones generales */
button,
.btn-crear {
    display: inline-block;
    padding: 9px 14px;
    border: none;
    border-radius: 4px;
    font: inherit;
    text-decoration: none;
    cursor: pointer;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid #1769aa;
    outline-offset: 2px;
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Botón para crear reservas */
.btn-crear {
    margin-bottom: 18px;
    background-color: #1769aa;
    color: white;
}

.btn-crear:hover {
    background-color: #12558a;
}

/* Filtros */
#filtros-reservas {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 18px;
    padding: 16px;
    background-color: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 5px;
}

.filtro-grupo {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
}

.filtro-grupo label {
    font-weight: bold;
    font-size: 0.9rem;
}

.filtro-grupo input,
.filtro-grupo select {
    width: 100%;
    min-width: 0;
    min-height: 38px;
    padding: 7px 9px;
    border: 1px solid #bbb;
    border-radius: 4px;
    background-color: #fff;
    font: inherit;
}

#filtros-reservas button[type="submit"] {
    align-self: end;
    background-color: #1769aa;
    color: white;
}

#filtros-reservas button[type="submit"]:hover {
    background-color: #12558a;
}

#limpiarFiltros {
    align-self: end;
    margin-left: 0 !important;
    border: 1px solid #bbb;
    background-color: #fff;
    color: #333;
}

#limpiarFiltros:hover {
    background-color: #eee;
}

#estado-listado {
    min-height: 1.5em;
    margin: 10px 0;
    color: #555;
}

/* Tabla de reservas */
.tabla-contenedor {
    width: 100%;
    overflow-x: auto;
    margin: 15px 0 25px;
    border: 1px solid #ddd;
    border-radius: 5px;
}

.tabla-reservas {
    width: 100%;
    border-collapse: collapse;
    background-color: #fff;
}

.tabla-reservas th,
.tabla-reservas td {
    padding: 11px 12px;
    border-bottom: 1px solid #ddd;
    text-align: left;
    vertical-align: middle;
}

.tabla-reservas th {
    background-color: #f0f2f4;
    color: #333;
    font-weight: bold;
    white-space: nowrap;
}

.tabla-reservas tbody tr:last-child td {
    border-bottom: none;
}

.tabla-reservas tbody tr:hover {
    background-color: #f8f9fa;
}

.tabla-reservas td a {
    white-space: nowrap;
}

/* Etiquetas de estado en la tabla */
.estado-etiqueta {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.85rem;
    white-space: nowrap;
}

.estado-pendiente {
    background-color: #fff3cd;
    color: #856404;
}

.estado-confirmada {
    background-color: #d4edda;
    color: #155724;
}

.estado-cancelada {
    background-color: #f8d7da;
    color: #721c24;
}

/* Datos de la reserva */
.detalle-reserva {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 24px;
    margin: 0 0 25px;
}

.detalle-reserva p {
    margin: 0;
    padding: 11px 0;
    border-bottom: 1px solid #eee;
    overflow-wrap: anywhere;
}

.estado-detalle {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 12px;
    font-size: 0.9rem;
}

.estado-detalle-pendiente {
    background-color: #fff3cd;
    color: #856404;
}

.estado-detalle-confirmada {
    background-color: #d4edda;
    color: #155724;
}

.estado-detalle-cancelada {
    background-color: #f8d7da;
    color: #721c24;
}

/* Historial de eventos */
.historial-eventos {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 15px 0 25px;
}

.evento {
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-left: 4px solid #999;
    border-radius: 5px;
    background-color: #fafafa;
}

.evento-cabecera {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}

.evento-tipo {
    display: inline-block;
    padding: 4px 9px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: bold;
    background-color: #e9ecef;
    color: #343a40;
}

.evento-creada {
    background-color: #e2e3e5;
    color: #383d41;
}

.evento-confirmada {
    background-color: #d4edda;
    color: #155724;
}

.evento-cancelada {
    background-color: #f8d7da;
    color: #721c24;
}

.evento-pendiente {
    background-color: #fff3cd;
    color: #856404;
}

.evento-actual {
    padding: 3px 8px;
    border: 1px solid #bbb;
    border-radius: 10px;
    color: #555;
    font-size: 0.75rem;
    font-weight: 600;
}

.evento-descripcion {
    margin: 5px 0;
    overflow-wrap: anywhere;
}

.evento-fecha {
    margin: 8px 0 0;
    color: #666;
    font-size: 0.85rem;
}

/* Botones de confirmar y cancelar */
.btn-confirmar,
.btn-cancelar {
    margin: 5px 5px 5px 0;
    padding: 9px 14px;
    border: none;
    border-radius: 4px;
    color: #fff;
    font: inherit;
    cursor: pointer;
}

.btn-confirmar {
    background-color: #198754;
}

.btn-confirmar:hover {
    background-color: #146c43;
}

.btn-cancelar {
    background-color: #c0392b;
}

.btn-cancelar:hover {
    background-color: #962d22;
}

.btn-confirmar:disabled,
.btn-cancelar:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Mensajes de confirmación, cancelación y estado */
#mensajeConfirmacion,
#mensajeCancelacion {
    margin: 8px 0;
    overflow-wrap: anywhere;
}

.detalle-volver {
    display: inline-block;
    margin-top: 15px;
}


/* Página para crear una reserva */
.formulario-pagina {
    max-width: 850px;
    margin: 0 auto;
}

.formulario-pagina h1 {
    margin-top: 0;
    margin-bottom: 8px;
    font-size: 1.8rem;
}

.formulario-intro {
    margin-top: 0;
    margin-bottom: 24px;
    color: #666;
}

.formulario-reserva {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    padding: 20px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background-color: #fafafa;
}

.campo-formulario {
    display: flex;
    flex-direction: column;
    min-width: 0;
    gap: 6px;
}

.campo-formulario label {
    font-weight: bold;
    font-size: 0.95rem;
}

.campo-formulario input,
.campo-formulario textarea {
    width: 100%;
    min-width: 0;
    padding: 10px;
    border: 1px solid #bbb;
    border-radius: 4px;
    background-color: #fff;
    color: #333;
    font: inherit;
}

.campo-formulario input {
    min-height: 40px;
}

.campo-formulario textarea {
    resize: vertical;
}

.campo-formulario input:focus,
.campo-formulario textarea:focus {
    border-color: #1769aa;
    outline: 2px solid #d7eaff;
}

.campo-completo {
    grid-column: 1 / -1;
}

.error {
    min-height: 0;
    color: #b42318;
    font-size: 0.85rem;
    overflow-wrap: anywhere;
}

.error:not(:empty) {
    padding: 4px 0;
}

.formulario-acciones {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.btn-guardar {
    background-color: #1769aa;
    color: white;
}

.btn-guardar:hover {
    background-color: #12558a;
}

.btn-guardar:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-volver {
    display: inline-block;
    padding: 8px 12px;
    border: 1px solid #bbb;
    border-radius: 4px;
    background-color: white;
    color: #333;
    text-decoration: none;
}

.btn-volver:hover {
    background-color: #eee;
}

.mensaje-formulario {
    margin: 0;
    overflow-wrap: anywhere;
}

/* Paginación del listado */
.paginacion {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 20px;
}

.paginacion button {
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background-color: #fff;
    color: #333;
    cursor: pointer;
}

.paginacion button:hover:not(:disabled) {
    background-color: #e8f1fa;
}

.paginacion button:disabled {
    background-color: #1769aa;
    border-color: #1769aa;
    color: #fff;
    cursor: default;
}

/* Cabecera centrada */
header {
    text-align: center;
    padding: 20px;
    margin-bottom: 20px;
}

header h1 {
    margin: 0;
}

/* Pie de página centrado */
footer {
    text-align: center;
    padding: 20px;
    margin-top: 20px;
    color: #666;
}

footer p {
    margin: 0;
}

/* Tablet */
@media (max-width: 800px) {
    main {
        width: 96%;
        padding: 16px;
    }

    #filtros-reservas {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* Móvil */
@media (max-width: 520px) {
    main {
        width: 100%;
        margin: 0;
        padding: 14px;
        border: none;
        border-radius: 0;
    }

    #filtros-reservas {
        grid-template-columns: 1fr;
        padding: 12px;
    }

    #filtros-reservas button {
        width: 100%;
        min-height: 40px;
    }

    .detalle-reserva {
        grid-template-columns: 1fr;
    }

    .tabla-reservas {
        min-width: 760px;
    }

    .evento {
        padding: 10px;
    }

    .btn-confirmar,
    .btn-cancelar {
        width: 100%;
        margin: 5px 0;
    }
}

/* Formulario en móviles */
@media (max-width: 600px) {
    .formulario-reserva {
        grid-template-columns: 1fr;
        padding: 14px;
        gap: 15px;
    }

    .campo-completo {
        grid-column: auto;
    }

    .formulario-acciones {
        flex-direction: column;
        align-items: stretch;
    }

    .btn-guardar,
    .btn-volver {
        width: 100%;
        text-align: center;
    }

    .formulario-pagina h1 {
        font-size: 1.5rem;
    }
}

@media (max-width: 520px) {
    .paginacion {
        gap: 5px;
    }

    .paginacion button {
        padding: 8px 10px;
    }
}