/* Modern Filter Form Styles */
.filterform {
    background-color: #ffffff;
    border-radius: 8px;
    padding: 0.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    border: 1px solid #e0e0e0;
    margin-bottom: 0.5rem;
    display: block;
    box-sizing: border-box;
}

/* Header Styling */
.filterform>center,
.filterform .batch-section-header {
    display: block;
    width: 100%;
    margin-bottom: 1rem;
    font-weight: 600;
    background-color: var(--primary-color, #72a2c3) !important;
    color: white !important;
    padding: 0.5rem;
    border-radius: 4px;
    box-sizing: border-box;
    text-align: center;
}

/* Inputs and Selects - Inline for Desktop */
.filterform input[type="text"],
.filterform input[type="date"],
.filterform input[type="number"],
.filterform select {
    display: inline-block;
    padding: 0.5rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.9rem;
    min-width: 150px;
    width: auto;
    margin: 0.2rem;
    vertical-align: middle;
    box-sizing: border-box;
}

.filterform input:focus,
.filterform select:focus {
    outline: none;
    border-color: var(--primary-color, #0a3d62);
    box-shadow: 0 0 0 2px rgba(10, 61, 98, 0.1);
}

/* Submit Button - Inline for Desktop */
.filterform input[type="submit"] {
    display: inline-block;
    background-color: var(--primary-color, #0a3d62);
    color: white;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: background-color 0.2s;
    height: auto;
    width: auto;
    margin: 0.2rem;
    vertical-align: middle;
    box-sizing: border-box;
}

.filterform input[type="submit"]:hover {
    background-color: var(--primary-light, #3c6e96);
}

/* Responsive adjustments */
@media screen and (max-width: 768px) {

    /* Constrain main element to prevent overflow */
    main {
        padding: 0.3rem !important;
        width: 100%;
        max-width: 100vw;
        overflow-x: hidden;
        box-sizing: border-box;
    }

    .filterform {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        padding: 0.4rem !important;
        margin: 0 0 0.5rem 0 !important;
        width: calc(100% - 0.6rem) !important;
        max-width: calc(100vw - 0.6rem) !important;
        box-sizing: border-box;
        overflow: visible;
    }

    /* Force direct children to block - EXCEPT paginatedData */
    .filterform>*:not(.paginatedData) {
        max-width: 100%;
        box-sizing: border-box;
        display: block;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    /* Hide scripts, styles, hidden inputs */
    .filterform>script,
    .filterform>style,
    .filterform>input[type="hidden"] {
        display: none !important;
    }

    /* Form controls - exclude pagination buttons */
    .filterform input:not([type="hidden"]),
    .filterform select,
    .filterform textarea,
    .filterform button:not(.paginatedButton) {
        display: block;
        width: 100%;
        max-width: 100%;
        margin: 0.3rem 0 !important;
        padding: 0.6rem !important;
        box-sizing: border-box;
        min-width: 0;
        font-size: 1rem;
    }

    /* Pagination buttons container */
    .filterform .paginatedButtons {
        gap: 0.6rem !important;
        justify-content: center;
    }

    /* Pagination buttons */
    .filterform .paginatedButton {
        display: inline-block !important;
        width: auto !important;
        min-width: 2.5rem;
        margin: 0.2rem !important;
        padding: 0.5rem 1rem !important;
    }

    /* Labels and spans - but not inside paginatedData */
    .filterform label:not(.paginatedData *),
    .filterform span:not(.paginatedData *) {
        display: block;
        width: 100%;
        max-width: 100%;
        margin-bottom: 0.2rem !important;
        margin-top: 0.5rem !important;
        text-align: left;
        white-space: normal !important;
        word-wrap: break-word;
        box-sizing: border-box;
    }

    /* Header adjustments */
    .filterform>center,
    .filterform .batch-section-header {
        margin-bottom: 0.8rem !important;
        padding: 0.6rem;
        font-size: 1rem;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    /* Submit button specific styling */
    .filterform input[type="submit"] {
        margin-top: 0.8rem !important;
        background-color: var(--primary-color, #0a3d62);
        color: white;
        font-weight: bold;
        width: 100%;
    }

    /* Tables inside filterform - but not paginatedTable */
    .filterform table:not(.paginatedTable) {
        display: block;
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        white-space: nowrap;
    }

    .filterform table:not(.paginatedTable) td,
    .filterform table:not(.paginatedTable) th {
        white-space: normal;
        min-width: auto;
    }
}