/* Estilo general y tipografía */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f4f7f9;
    color: #333;
    margin: 0;
    line-height: 1.6;
}

header {
    background-color: #0d2c4d;
    color: #fff;
    padding: 1rem 2rem;
    text-align: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

main {
    padding: 2rem 1rem; /* Reducimos el padding lateral para móviles */
}

.contenedor {
    max-width: 1200px;
    margin: 0 auto;
    background-color: #fff;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 0 20px rgba(0,0,0,0.05);
}

h2 {
    color: #0d2c4d;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 0.5rem;
    margin-bottom: 1.5rem;
}

/* Estilos de botones */
.btn-agregar, .btn-guardar, .btn-cancelar, .btn-editar, .btn-eliminar {
    padding: 10px 18px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    text-decoration: none;
    color: #fff;
    margin: 5px;
    transition: background-color 0.3s ease, transform 0.2s;
}

.btn-agregar { background-color: #1a5ca3; }
.btn-guardar { background-color: #28a745; }
.btn-cancelar { background-color: #6c757d; }
.btn-editar { background-color: #ffc107; color: #333; padding: 5px 10px; font-size: 0.9rem; }
.btn-eliminar { background-color: #dc3545; padding: 5px 10px; font-size: 0.9rem; }

.btn-agregar:hover, .btn-guardar:hover, .btn-editar:hover, .btn-eliminar:hover {
    transform: translateY(-2px);
}

/* Estilos del Formulario */
.formulario-oculto {
    display: none;
}
#formulario-cliente form {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e0e0e0;
}
.grupo-form {
    flex: 1 1 calc(50% - 20px);
    display: flex;
    flex-direction: column;
}
.grupo-form.full-width {
    flex-basis: 100%;
}
.grupo-form label {
    margin-bottom: 5px;
    font-weight: 600;
    color: #555;
}
.grupo-form input, .grupo-form select, .grupo-form textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 1rem;
    box-sizing: border-box; /* Añadido para mejor consistencia */
}
.botones-form {
    flex-basis: 100%;
    text-align: right;
}

/* Estilos de la tabla */
.tabla-responsive {
    overflow-x: auto;
    margin-top: 2rem;
}
table {
    width: 100%;
    border-collapse: collapse;
}
th, td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}
thead th {
    background-color: #e9ecef;
    color: #495057;
    font-weight: 600;
}
tbody tr:hover {
    background-color: #f8f9fa;
}
td.acciones {
    white-space: nowrap;
}

/* Estados de los casos */
.estado {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    color: #fff;
    font-weight: bold;
    text-transform: capitalize;
}
.estado.activo { background-color: #28a745; }
.estado.en-proceso { background-color: #ffc107; color: #333; }
.estado.cerrado { background-color: #6c757d; }


/* --- Media Queries para Responsividad --- */
/* Para tablets y móviles (pantallas de 768px o menos) */
@media (max-width: 768px) {
    .grupo-form {
        /* Hacemos que cada campo del formulario ocupe el 100% del ancho */
        flex-basis: 100%;
    }

    .botones-form {
        /* Centramos los botones en móviles y añadimos espacio superior */
        text-align: center;
        margin-top: 1rem;
    }

    .btn-guardar, .btn-cancelar {
        /* Hacemos los botones un poco más grandes para que sean fáciles de tocar */
        width: 45%;
        padding: 12px;
    }

    h1 {
        font-size: 1.5rem;
    }

    main {
        padding: 1rem;
    }
    
    .contenedor {
        padding: 1rem;
    }
}
/* --- Nuevos Estilos para Búsqueda, Paginación y Ordenamiento --- */

/* Contenedor del header de la tabla y botón agregar */
.acciones-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

/* Formulario de Búsqueda */
.contenedor-busqueda {
    background-color: #f8f9fa;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    border: 1px solid #e0e0e0;
}
.form-busqueda {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}
.form-busqueda input, .form-busqueda select {
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 0.9rem;
    flex-grow: 1;
}
.form-busqueda input[type="date"] {
    min-width: 150px;
}
.form-busqueda button, .form-busqueda a {
    padding: 8px 15px;
    border: none;
    border-radius: 5px;
    color: #fff;
    cursor: pointer;
    text-decoration: none;
}
.btn-buscar { background-color: #0d2c4d; }
.btn-limpiar { background-color: #6c757d; }

/* Controles de la tabla (Mostrar X registros) */
.controles-tabla {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}
.form-vista {
    display: flex;
    align-items: center;
    gap: 5px;
}
.total-registros {
    color: #666;
}

/* Estilos para Ordenamiento en Cabeceras de Tabla */
thead th a {
    text-decoration: none;
    color: inherit;
    display: block;
}
thead th a.sorted {
    font-weight: 800;
    color: #0d2c4d;
}

/* Paginación */
.navegacion-paginacion {
    text-align: center;
    margin-top: 2rem;
}
.btn-paginacion {
    display: inline-block;
    padding: 8px 12px;
    margin: 0 3px;
    border: 1px solid #ddd;
    border-radius: 5px;
    background-color: #fff;
    color: #0d2c4d;
    text-decoration: none;
    transition: background-color 0.2s, color 0.2s;
}
.btn-paginacion:hover {
    background-color: #f4f7f9;
}
.btn-paginacion.activo {
    background-color: #0d2c4d;
    color: #fff;
    border-color: #0d2c4d;
}