/*!
 * IPMFlow-RAP - CSS
 *
 * @author    Havasi Archibald <hello@ipmflow.com>
 * @copyright 2025 Havasi Archibald
 * @license   GPL-2.0-or-later
 * @link      https://ipmflow.com/
 *
 * @description  Document Manager Styles for IPMFlow Risk Assessment - HYBRID VERSION Original controls + Clean working table
 */

/* Container for the entire document manager interface. */
.ipmflow-documents-view {
    font-family: var(--ipm-font-family);
    padding: 5px var(--ipm-padding) var(--ipm-padding);
    color: var(--ipm-text-color);
    max-width: 1400px;
    width: 100%;
    box-sizing: border-box;
    border-radius: 8px;
}

/* Styles for the "Back to Dashboard" navigation link. */
.documents-back-nav {
    margin-bottom: calc(var(--ipm-margin) * 1.25);
    padding-bottom: var(--ipm-padding);
    border-bottom: var(--ipm-border-width) solid var(--ipm-border-color);
}

.ipmflow-back-btn {
    font-family: var(--ipm-font-family);
    background: linear-gradient(135deg, var(--ipm-link-color) 0%, #005a47 100%);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1em;
    font-weight: bold;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.3s ease;
    text-decoration: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin: 5px 5px 5px 0;
}

/* On smaller screens, the top back button is hidden to avoid redundancy with bottom navigation. */
@media (max-width: 767px) {
    .documents-back-nav {
        display: none;
    }
}

.ipmflow-back-btn:hover {
    background: linear-gradient(135deg, #005a47 0%, #003d32 100%);
    color: white;
    text-decoration: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.ipmflow-back-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 127, 95, 0.2), 0 2px 8px rgba(0, 127, 95, 0.1);
}

.ipmflow-back-btn:active {
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.15);
}

.ipmflow-back-btn .dashicons,
.ipmflow-back-btn svg {
    font-size: 16px;
    width: 16px;
    height: 16px;
    line-height: 1;
    flex-shrink: 0;
}

.ipmflow-documents-header {
    margin-bottom: calc(var(--ipm-margin) * 1.5);
}

.ipmflow-documents-title {
    font-family: var(--ipm-font-family);
    font-size: 21px;
    font-weight: bold;
    color: var(--ipm-heading-color);
    margin: 0 0 10px 0;
    border-bottom: 3px solid var(--ipm-h2-border-color);
    padding-bottom: 8px;
}

.ipmflow-documents-description {
    color: var(--ipm-text-color);
    font-size: 15px;
    margin: 0;
    line-height: var(--ipm-line-height);
}

/* The main control panel for filtering and searching documents. */
.ipmflow-documents-controls {
    background: #ffffff;
    border: 2px solid #e1e8ed;
    border-radius: 12px;
    padding: calc(var(--ipm-padding) * 1.5);
    margin-bottom: calc(var(--ipm-margin) * 1.5);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.ipmflow-documents-controls::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--ipm-link-color) 0%, #005a47 100%);
}

.ipmflow-documents-controls-row {
    display: flex;
    flex-direction: column;
    gap: calc(var(--ipm-padding) * 0.75);
    margin-bottom: var(--ipm-padding);
}

.ipmflow-documents-controls-row:last-child {
    margin-bottom: 0;
}

/* The primary control row containing document type and search filters. */
.ipmflow-documents-controls-row.primary-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: calc(var(--ipm-padding) * 1.25);
    margin-bottom: calc(var(--ipm-padding) * 1.25);
}

/* The secondary control row for sorting and items-per-page options. */
.ipmflow-documents-controls-row.secondary-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: calc(var(--ipm-padding) * 1.25);
    max-width: 600px;
}

.ipmflow-documents-control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ipmflow-documents-control-group label {
    font-family: var(--ipm-font-family);
    font-weight: 600;
    font-size: 12px;
    color: #2c3e50;
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.ipmflow-documents-control-group select,
.ipmflow-documents-control-group input {
    font-family: var(--ipm-font-family);
    padding: 12px 16px;
    border: 2px solid #e1e8ed;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 400;
    color: #2c3e50;
    background-color: #ffffff;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-sizing: border-box;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
    width: 100%;
    min-height: 52px;
    height: auto;
    line-height: 1.4;
    display: flex;
    align-items: center;
}

/* Custom styling for select elements to ensure consistent appearance, removing default browser styles. */
.ipmflow-documents-control-group select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23666' viewBox='0 0 24 24'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 40px;
}

/* Platform-specific adjustments for form controls to ensure a consistent user experience.
 * Targets iOS to prevent zooming on focus and tweaks layout on Android for better touch interaction.
 */
@supports (-webkit-touch-callout: none) {
    .ipmflow-documents-control-group select {
        min-height: 54px;
        height: 54px;
        line-height: 1.4;
        padding: 16px 40px 16px 16px;
        font-size: 16px; /* Prevents auto-zoom on form focus in iOS Safari. */
        vertical-align: middle;
        display: flex;
        align-items: center;
    }
    
    /* Fine-tuning for Android devices, which often require slightly larger touch targets. */
    @media (pointer: coarse) {
        .ipmflow-documents-control-group select,
        .ipmflow-documents-control-group input {
            min-height: 56px;
            padding: 14px 16px;
            font-size: 16px; /* Also prevents zooming on many mobile browsers. */
            line-height: 1.3;
        }
        
        /* Specific vertical padding fix for select elements on Android. */
        .ipmflow-documents-control-group select {
            padding-top: 16px;
            padding-bottom: 16px;
        }
        
        .ipmflow-documents-control-group input[type="text"] {
            padding-top: 14px;
            padding-bottom: 14px;
        }
    }
    
    /* Height adjustments for non-iOS mobile devices (primarily Android) on smaller screens. */
    @supports not (-webkit-touch-callout: none) {
        /* This targets non-iOS devices (mainly Android) */
        @media (max-width: 768px) {
            .ipmflow-documents-control-group select,
            .ipmflow-documents-control-group input {
                min-height: 56px;
                padding: 15px 16px;
                font-size: 16px;
                line-height: 1.2;
                vertical-align: middle;
            }
            
            .ipmflow-documents-control-group select {
                padding-right: 44px; /* More space for arrow */
                background-position: right 14px center;
            }
            
            .ipmflow-documents-control-group input[type="text"] {
                padding-right: 48px; /* More space for search icon */
                background-position: right 16px center;
            }
        }
    }
}

.ipmflow-documents-control-group select:focus,
.ipmflow-documents-control-group input:focus {
    outline: none;
    border-color: var(--ipm-link-color);
    box-shadow: 0 0 0 3px rgba(0, 127, 95, 0.15), 0 4px 12px rgba(0, 0, 0, 0.1);
    background-color: #ffffff;
}

.ipmflow-documents-control-group select:hover,
.ipmflow-documents-control-group input:hover {
    border-color: #007f5f;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12);
}

/* Custom icon and padding for the search input field. */
.ipmflow-documents-control-group input[type="text"] {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23666' viewBox='0 0 24 24'%3E%3Cpath d='M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-size: 16px;
    padding-right: 44px;
}

.ipmflow-documents-refresh-btn,
#refresh-documents {
    font-family: var(--ipm-font-family);
    background: linear-gradient(135deg, var(--ipm-link-color) 0%, #005a47 100%);
    color: white;
    border: none;
    padding: 14px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(0, 127, 95, 0.25);
    margin-top: calc(var(--ipm-padding) * 1.25);
    align-self: flex-start;
    position: relative;
    overflow: hidden;
    height: 48px;
    line-height: 1.6;
}

.ipmflow-documents-refresh-btn::before,
#refresh-documents::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.ipmflow-documents-refresh-btn:hover::before,
#refresh-documents:hover::before {
    left: 100%;
}

.ipmflow-documents-refresh-btn:hover,
#refresh-documents:hover {
    background: linear-gradient(135deg, #005a47 0%, #003d32 100%);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.ipmflow-documents-refresh-btn:disabled,
#refresh-documents:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background-color: #e0e0e0;
    border-color: #cccccc;
    color: #888888;
    box-shadow: none;
    transform: none;
}

.ipmflow-documents-refresh-btn .dashicons,
.ipmflow-documents-refresh-btn svg,
#refresh-documents .dashicons,
#refresh-documents svg {
    font-size: 16px;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* Wrapper for the table displaying the list of documents. */
.ipmflow-documents-list,
.documents-table-wrapper {
    background: var(--ipm-card-bg);
    border: var(--ipm-border-width) solid var(--ipm-border-color);
    border-radius: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    box-shadow: var(--ipm-card-shadow);
    transition: all 0.3s ease;
    -webkit-overflow-scrolling: touch;
}

/* On larger screens, the horizontal scrollbar is only shown if the table content actually overflows.
 * This prevents a scrollbar from appearing unnecessarily. A JS-based fallback is included for cross-browser compatibility.
 */
@media (min-width: 1024px) {
    .ipmflow-documents-list,
    .documents-table-wrapper {
        overflow-x: hidden;
    }
    
    /* Ensures the table takes at least the full container width. */
    .ipmflow-documents-table,
    .documents-table {
        min-width: 100%;
    }
    
    /* The :has() selector enables the scrollbar only when an inline width is set, indicating overflow. */
    .ipmflow-documents-list:has(.ipmflow-documents-table[style*="width"]),
    .documents-table-wrapper:has(.documents-table[style*="width"]) {
        overflow-x: auto;
    }
    
    /* A class added by JavaScript serves as a fallback for browsers that don't support :has(). */
    .ipmflow-documents-list.has-overflow,
    .documents-table-wrapper.has-overflow {
        overflow-x: auto;
    }
}

/* On smaller screens, horizontal scrolling is always enabled as content is more likely to overflow. */
@media (max-width: 1023px) {
    .ipmflow-documents-list,
    .documents-table-wrapper {
        overflow-x: auto;
    }
}

/* === Clean Table Layout === */
/* A modern, clean table design, replacing default styles. */
.documents-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
    font-family: var(--ipm-font-family);
    font-size: 14px;
    min-width: 900px;
}

/* Base styling for all table cells. */
.documents-table th,
.documents-table td {
    padding: 12px;
    border-bottom: 1px solid var(--ipm-table-border-color);
    vertical-align: middle;
    background-color: var(--ipm-card-bg);
}

/* Table header specific styles. */
.documents-table th {
    background-color: var(--ipm-table-header-bg);
    font-weight: bold;
    color: var(--ipm-table-header-text);
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.5px;
    text-align: center;
    border-bottom: 2px solid var(--ipm-table-border-color);
}

/* The first column is typically for titles, so it's left-aligned for readability. */
.documents-table th:first-child {
    text-align: left;
}

/* Proportional column widths for a balanced layout. The first column is the widest for titles. */
.documents-table th:nth-child(1), .documents-table td:nth-child(1) { width: 40%; }
.documents-table th:nth-child(2), .documents-table td:nth-child(2) { width: 15%; text-align: center; min-width: 120px; }
.documents-table th:nth-child(3), .documents-table td:nth-child(3) { width: 8%; text-align: center; }
.documents-table th:nth-child(4), .documents-table td:nth-child(4) { width: 12%; text-align: center; }
.documents-table th:nth-child(5), .documents-table td:nth-child(5) { width: 12%; text-align: center; }
.documents-table th:nth-child(6), .documents-table td:nth-child(6) { width: 13%; text-align: center; }
.documents-table th:nth-child(7), .documents-table td:nth-child(7) { width: 5%; text-align: center; }

.documents-table td:nth-child(1) {
    text-align: left;
}

.document-title strong {
    display: block;
    font-weight: 600;
    color: var(--ipm-heading-color);
    margin-bottom: 4px;
    line-height: 1.3;
}

.document-meta {
    font-size: 0.8em;
    color: var(--ipm-text-color);
    opacity: 0.8;
    line-height: 1.2;
}

.document-meta small {
    display: block;
    margin-bottom: 2px;
}

/* Styles for document type badges (e.g., 'Risk Assessment') for quick identification. */
.document-type {
    display: inline-block !important;
    padding: 6px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #fff;
    text-align: center;
    white-space: nowrap;
    min-width: 80px;
    line-height: 1.2;
    margin: 0 auto;
    background-color: #6c757d; /* Default fallback */
}

/* Specific background colors for different document types to improve visual distinction.
 * High specificity is used to override potential conflicting styles. */
.documents-table .document-type-risk_assessment,
.documents-table .document-type.document-type-risk_assessment {
    background-color: #28a745 !important;
    color: #fff !important;
}

.documents-table .document-type-program,
.documents-table .document-type.document-type-program {
    background-color: #ffc107 !important;
    color: #212529 !important;
}

/* Prevents text from being cut off in the 'Type' column, ensuring badges are fully visible. */
.documents-table td:nth-child(2) {
    overflow: visible !important;
    text-overflow: initial !important;
    white-space: nowrap !important;
}

/* Styling for download buttons within the table. */
.documents-table .btn {
    padding: 6px 10px;
    font-size: 0.8em;
    border-radius: 4px;
    text-decoration: none;
    display: inline-block;
    white-space: nowrap;
}

/* Visual feedback on row hover to improve user interaction. */
.documents-table tbody tr:hover {
    background-color: rgba(0, 127, 95, 0.05);
}

.documents-table tbody tr:last-child td {
    border-bottom: none;
}

/* === End Clean Table Layout === */

/* Pagination for navigating through document pages. */
.ipmflow-documents-pagination,
.document-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--ipm-padding) calc(var(--ipm-padding) * 1.25);
    background: #ffffff;
    border-top: 2px solid var(--ipm-border-color);
    font-family: var(--ipm-font-family);
    border-radius: 0 0 8px 8px;
}

.ipmflow-documents-pagination-info,
.pagination-info {
    font-size: 14px;
    color: var(--ipm-text-color);
    font-weight: 500;
}

.ipmflow-documents-pagination-controls,
.pagination {
    display: flex;
    gap: 8px;
    align-items: center;
    list-style: none !important;
    margin: 0;
    padding: 0;
}

.ipmflow-documents-pagination-btn,
.page-link {
    font-family: var(--ipm-font-family);
    background: linear-gradient(135deg, var(--ipm-link-color) 0%, #005a47 100%);
    color: white;
    border: none;
    padding: 8px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    min-width: 40px;
    height: 40px;
}

.ipmflow-documents-pagination-btn:hover:not(:disabled),
.page-link:hover {
    background: linear-gradient(135deg, #005a47 0%, #003d32 100%);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    color: white;
    text-decoration: none;
}

.ipmflow-documents-pagination-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background: #e0e0e0;
    color: #888888;
    box-shadow: none;
    transform: none;
}

.ipmflow-documents-pagination-current {
    font-size: 14px;
    color: var(--ipm-text-color);
    margin: 0 12px;
    font-weight: 600;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 6px;
}

/* Ensures pagination controls render correctly as a horizontal list without default list styling. */
.pagination,
.pagination li,
.pagination .page-item {
    list-style-type: none !important;
    list-style: none !important;
}

.page-item {
    list-style: none !important;
    margin: 0;
    padding: 0;
}

.page-item.active .page-link {
    background: linear-gradient(135deg, #005a47 0%, #003d32 100%);
    color: white;
}

.page-item.disabled .page-link {
    opacity: 0.6;
    cursor: not-allowed;
    background: #e0e0e0;
    color: #888888;
    pointer-events: none;
}

/* A fallback to forcefully remove list markers that might be inherited from other stylesheets. */
.pagination::before,
.pagination li::before,
.page-item::before {
    content: none !important;
    display: none !important;
}

.pagination ul,
.pagination ol {
    list-style: none !important;
    padding: 0;
    margin: 0;
}

/* Style for the 'My Documents' button, typically shown in the main plugin header. */
.ipmflow-header .ipmflow-my-documents-btn {
    font-family: var(--ipm-font-family);
    background: linear-gradient(135deg, #6c757d 0%, #5a6268 100%);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1em;
    font-weight: bold;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.3s ease;
    text-decoration: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin: 5px;
}

.ipmflow-header .ipmflow-my-documents-btn:hover {
    background: linear-gradient(135deg, #5a6268 0%, #495057 100%);
    color: white;
    text-decoration: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.ipmflow-header .ipmflow-my-documents-btn .dashicons,
.ipmflow-header .ipmflow-my-documents-btn svg {
    font-size: 16px;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* Ensures proper spacing when the button is placed within the header action area. */
.ipmflow-header-actions .ipmflow-my-documents-btn {
    margin-left: 10px;
}

/* Styles for the loading indicator shown while fetching documents. */
.ipmflow-documents-loading,
.documents-loading {
    text-align: center;
    padding: 40px 20px;
    color: var(--ipm-text-color);
    font-family: var(--ipm-font-family);
    background: linear-gradient(135deg, #ffffff 0%, #f0f4f8 100%);
    border-radius: 8px;
    margin: var(--ipm-margin) 0;
}

.ipmflow-documents-loading .dashicons,
.ipmflow-documents-loading svg,
.documents-loading .dashicons,
.documents-loading svg {
    animation: spin 1s linear infinite;
    font-size: 20px;
    margin-right: 8px;
    color: var(--ipm-link-color);
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Styles for messages shown when no documents are found or an error occurs. */
.ipmflow-documents-empty,
.no-documents,
.documents-error {
    text-align: center;
    padding: 40px 20px;
    color: var(--ipm-text-color);
    font-family: var(--ipm-font-family);
    background: linear-gradient(135deg, #ffffff 0%, #f0f4f8 100%);
    border-radius: 8px;
    margin: var(--ipm-margin) 0;
    box-shadow: var(--ipm-card-shadow);
}

.ipmflow-documents-empty .dashicons,
.ipmflow-documents-empty svg,
.no-documents .dashicons,
.no-documents svg,
.documents-error .dashicons,
.documents-error svg {
    font-size: 48px;
    color: var(--ipm-border-color);
    margin-bottom: 15px;
    opacity: 0.5;
}

/* Responsive adjustments for tablet-sized screens and smaller. */
@media (max-width: 768px) {
    .ipmflow-documents-view {
        padding: calc(var(--ipm-padding) * 0.75) 0;
    }
    
    .ipmflow-documents-controls {
        padding: calc(var(--ipm-padding) * 0.75);
        margin-bottom: calc(var(--ipm-margin) * 0.75);
    }
    
    /* Controls are stacked vertically for better usability on narrow screens. */
    .ipmflow-documents-controls-row.primary-controls,
    .ipmflow-documents-controls-row.secondary-controls {
        grid-template-columns: 1fr;
        gap: calc(var(--ipm-padding) * 0.75);
        max-width: none;
    }
    
    .ipmflow-documents-control-group {
        width: 100%;
    }
    
    .ipmflow-documents-control-group label {
        text-align: left;
    }
    
    /* Increase font size and padding for better touch interaction on mobile devices. */
    .ipmflow-documents-control-group select,
    .ipmflow-documents-control-group input {
        min-width: auto;
        width: 100%;
        font-size: 16px; /* Prevents auto-zoom on form focus. */
        min-height: 54px;
        padding: 14px 12px; /* Provides larger touch targets. */
        line-height: 1.3;
    }
    
    /* Further refinement for Android devices. */
    @supports not (-webkit-touch-callout: none) {
        .ipmflow-documents-control-group select,
        .ipmflow-documents-control-group input {
            min-height: 56px;
            padding: 15px 12px;
            line-height: 1.2;
        }
    }
    
    .documents-table {
        font-size: 13px;
    }
    
    .documents-table th,
    .documents-table td {
        padding: 8px 10px;
    }
    
    /* Pagination is stacked vertically to save horizontal space. */
    .ipmflow-documents-pagination {
        flex-direction: column;
        gap: 10px;
        text-align: center;
        padding: calc(var(--ipm-padding) * 0.75);
    }
    
    .ipmflow-documents-refresh-btn {
        width: 100%;
        justify-content: center;
        min-height: 44px; /* Improves touch target size. */
        font-size: 16px;
        padding: 12px 20px;
    }
}

@media (max-width: 600px) {
    .ipmflow-documents-view {
        padding: calc(var(--ipm-padding) * 0.5) 0;
    }
    
    .ipmflow-documents-title {
        font-size: 18px;
        margin-bottom: 8px;
    }
    
    .ipmflow-documents-description {
        font-size: 14px;
    }
    
    /* On very small screens, the table transforms into a card-based layout for better readability. */
    .documents-table-wrapper {
        overflow: visible;
    }
    
    .documents-table {
        display: block;
        width: 100%;
    }
    
    .documents-table thead {
        display: none;
    }
    
    .documents-table tbody {
        display: block;
        width: 100%;
    }
    
    .documents-table tr {
        display: block;
        border: 2px solid var(--ipm-border-color);
        margin-bottom: 15px;
        padding: 15px;
        border-radius: 12px;
        background: var(--ipm-card-bg);
        box-shadow: 0 4px 12px rgba(0,0,0,0.08);
        transition: all 0.3s ease;
        position: relative;
    }
    
    .documents-table tr:hover {
        box-shadow: 0 8px 24px rgba(0,0,0,0.12);
        border-color: var(--ipm-link-color);
    }
    
    .documents-table td {
        display: block;
        border: none;
        padding: 8px 0;
        text-align: left !important;
        width: 100% !important;
    }
    
    .documents-table td:before {
        content: attr(data-label) ": ";
        font-weight: 700;
        color: var(--ipm-heading-color);
        display: inline-block;
        width: 100px;
        text-transform: uppercase;
        font-size: 0.75em;
        letter-spacing: 0.5px;
        margin-bottom: 2px;
    }
    
    .documents-table td:nth-child(7) {
        margin-top: 15px;
        padding-top: 15px;
        border-top: 1px solid var(--ipm-border-color);
        text-align: center !important;
    }
    
    .documents-table td:nth-child(7) .btn {
        width: 100%;
        max-width: 200px;
        padding: 12px 20px;
        font-size: 1em;
    }
}

/* Final adjustments for the smallest mobile screens. */
@media (max-width: 480px) {
    .ipmflow-documents-controls {
        padding: calc(var(--ipm-padding) * 0.5);
    }
    
    .ipmflow-documents-control-group select,
    .ipmflow-documents-control-group input {
        padding: 15px 12px; /* Even larger touch targets */
        font-size: 16px;
        min-height: 56px;
        line-height: 1.2;
    }
    
    .ipmflow-documents-refresh-btn {
        padding: 14px 20px;
        font-size: 16px;
        min-height: 48px;
    }
    
    .ipmflow-documents-pagination {
        padding: calc(var(--ipm-padding) * 0.5);
    }
    
    .ipmflow-documents-pagination-btn {
        padding: 8px 16px;
        font-size: 16px;
        min-height: 44px;
    }
}