/* Base Layout */
.caudal_historico_wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1.5rem;
    max-width: 100%;
    margin: 0 auto;
}

/* Form Section Row */
.caudal_historico_form_section {
    background: white;
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    width: 100%;
    min-height: 80px;
    display: flex;
    align-items: flex-start;  /* Cambiado a flex-start para alineación izquierda */
    justify-content: flex-start;  /* Cambiado a flex-start para alineación izquierda */
}

/* Form Elements in Horizontal Layout */
.caudal_historico_form {
    display: flex;
    align-items: flex-start;  /* Cambiado a flex-start */
    gap: 1.5rem;
    width: 100%;
    max-width: 1200px;
}

.caudal_historico_form fieldset {
    border: none;
    padding: 0;
    margin: 0;
    flex: 1;
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;  /* Cambiado a flex-start */
    justify-content: flex-start;  /* Cambiado a flex-start */
}

.caudal_historico_form legend {
    position: absolute;
    top: -2rem;
    left: 0;  /* Añadido para alinear a la izquierda */
    color: #1a1a1a;
    font-size: 1.25rem;
    font-weight: 500;
}

.caudal_historico_form_group {
    flex: 1;
    margin: 0;
    max-width: 200px;  /* Añadido para controlar el ancho de los grupos */
}

.caudal_historico_form_group label {
    display: block;
    color: #64748b;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 0.5rem;
    text-align: left;  /* Añadido para asegurar alineación izquierda */
}

.caudal_historico_form_group input {
    width: 100%;
    padding: 0.5rem;
    background-color: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    color: #1a1a1a;
    height: 36px;
}

/* Submit Button */
.caudal_historico_submit_button {
    margin: 0;
    flex-shrink: 0;
    align-self: flex-end;  /* Alineado con los inputs */
}

.caudal_historico_submit_button input[type="submit"] {
    height: 36px;
    background: #0771B1;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
    white-space: nowrap;
}

.caudal_historico_submit_button input[type="submit"]:hover {
    background: #065d8f;
}

/* Table Section */
.caudal_historico_table_container {
    background: white;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.caudal_historico_table_title {
    color: #1a1a1a !important;
    font-size: 1.25rem !important;
    font-weight: 500 !important;
    padding: 1rem;
    border-bottom: 1px solid #e2e8f0;
}

.caudal_historico_table_responsive {
    overflow: auto;
    max-height: calc(100vh - 300px);
    position: relative;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
}

.caudal_historico_table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    min-width: 1200px;
}

/* Header styling */
.caudal_historico_table thead th {
    position: sticky;
    top: 0;
    z-index: 20;
    background: #0771B1;
    color: white;
    font-weight: 500;
    text-align: center;
    padding: 0.75rem;
    border: 1px solid #e2e8f0;
    box-shadow: inset 0 -1px 0 #e2e8f0;
}

/* Fixed first and last column */
.caudal_historico_table td:first-child,
.caudal_historico_table th:first-child,
.caudal_historico_table td:last-child,
.caudal_historico_table th:last-child {
    position: sticky;
    z-index: 10;
    background: #E8F4FF;
}

.caudal_historico_table td:first-child,
.caudal_historico_table th:first-child {
    left: 0;
}

.caudal_historico_table td:last-child,
.caudal_historico_table th:last-child {
    right: 0;
}

/* Corner cells */
.caudal_historico_table thead th:first-child,
.caudal_historico_table thead th:last-child {
    position: sticky;
    z-index: 30;
    background: #0771B1;
    box-shadow: 
        inset 0 -1px 0 #e2e8f0,
        inset -1px 0 0 #e2e8f0;
}

/* Regular cells */
.caudal_historico_table td {
    padding: 0.75rem;
    border: 1px solid #e2e8f0;
    text-align: center;
    transition: background-color 0.2s ease;
}

/* Even/Odd rows */
.caudal_historico_table tr:nth-child(even) {
    background-color: #f8f9fa;
}

.caudal_historico_table tr:nth-child(odd) {
    background-color: #ffffff;
}

/* Enhanced hover effects */
.caudal_historico_table tr:hover td {
    background-color: #2B6CB0;
    color: white;
}

.caudal_historico_table tr:hover td:first-child,
.caudal_historico_table tr:hover td:last-child {
    background-color: #2B6CB0;
    color: white;
}

.caudal_historico_table tr:hover td.estadistica {
    background-color: #2F855A;
    color: white;
}

/* Statistical columns */
.caudal_historico_table th.estadistica,
.caudal_historico_table td.estadistica {
    background-color: #E3F1E3;
    border-right: 2px solid #64A164;
    font-weight: 500;
}

.caudal_historico_table thead th.estadistica {
    background-color: #4C8B4C;
    z-index: 20;
    box-shadow: inset 0 -1px 0 #e2e8f0;
}

.caudal_historico_table th.estadistica:first-of-type,
.caudal_historico_table td.estadistica:first-of-type {
    border-left: 3px solid #4C8B4C;
}

.caudal_historico_table th[class*="estadistica"]:nth-of-type(2),
.caudal_historico_table td[class*="estadistica"]:nth-of-type(2) {
    border-left: 3px solid #4C8B4C;
}

.caudal_historico_table th.estadistica-final,
.caudal_historico_table td.estadistica-final {
    border-right: 3px solid #4C8B4C;
}

/* Alert Messages */
.caudal_historico_alert {
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    background: #F0F9FF;
    border: 1px solid #BAE6FD;
    color: #0369A1;
}

.caudal_historico_error {
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    background: #FEE2E2;
    border: 1px solid #FECACA;
    color: #DC2626;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .caudal_historico_form {
        flex-direction: column;
        gap: 1rem;
    }

    .caudal_historico_form fieldset {
        flex-direction: column;
        gap: 1rem;
    }

    .caudal_historico_form_group {
        max-width: 100%;  /* Ajustado para vista móvil */
    }

    .caudal_historico_submit_button {
        width: 100%;
    }

    .caudal_historico_submit_button input[type="submit"] {
        width: 100%;
    }

    .caudal_historico_table_responsive {
        max-height: calc(100vh - 500px);
    }
}

@media (max-width: 768px) {
    .caudal_historico_wrapper {
        padding: 1rem;
    }

    .caudal_historico_form_section,
    .caudal_historico_table_container {
        padding: 1rem;
    }

    .caudal_historico_table td,
    .caudal_historico_table th {
        padding: 0.5rem;
        font-size: 13px;
    }
}