/* ===================================================
   UNIFIED LIST VIEW SYSTEM
   =================================================== */

/* Universal List View Styling System for EmploymentOnboarding */
/* This file provides consistent list view styling across the entire application */

/* ===================================================
   BASE LIST VIEW CONTAINER
   =================================================== */

.list-view-container {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    min-height: 100vh;
    background-color: #f8f9fa;
}

.list-view-content {
    padding: 1.5rem 2rem;
}

/* ===================================================
   STANDARDIZED PAGE HEADERS
   =================================================== */

.list-page-header {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 2rem;
    padding: 1.5rem 2rem 1rem 2rem;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border: 1px solid #e9ecef;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.list-page-header h1,
.list-page-header h2,
.list-page-header h3,
.list-page-header h4 {
    margin: 0;
    font-size: 1.75rem;
    font-weight: 600;
    color: inherit;
}

.list-page-header .page-icon {
    font-size: 1.5rem;
    color: #007bff;
    flex-shrink: 0;
}

.list-page-header .page-subtitle {
    font-size: 0.875rem;
    font-weight: 400;
    color: #6c757d;
    margin-top: 0.25rem;
    margin-bottom: 0;
}

.list-page-header .ms-auto {
    margin-left: auto;
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* ===================================================
   STANDARDIZED FILTER SECTIONS
   =================================================== */

.list-filter-section {
    background: #ffffff;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.list-filter-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e9ecef;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border-radius: 8px 8px 0 0;
    display: flex;
    justify-content: between;
    align-items: center;
}

.list-filter-body {
    padding: 1.5rem;
}

.list-filter-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e9ecef;
}

.filter-form-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: #495057;
    margin-bottom: 0.5rem;
}

.filter-form-control,
.filter-form-select {
    font-size: 0.875rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.filter-form-control:focus,
.filter-form-select:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* ===================================================
   STANDARDIZED TABLE STYLING
   =================================================== */

.list-table-container {
    background: #ffffff;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

.list-table {
    margin: 0;
    font-size: 0.875rem;
}

.list-table thead th {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-color: #dee2e6;
    font-weight: 600;
    font-size: 0.8125rem;
    color: #495057;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 1rem 0.75rem;
    vertical-align: middle;
}

.list-table tbody td {
    padding: 0.875rem 0.75rem;
    vertical-align: middle;
    border-color: #e9ecef;
    color: #212529;
}

.list-table tbody tr:hover {
    background-color: rgba(0, 123, 255, 0.05);
}

.list-table tbody tr.selected {
    background-color: rgba(0, 123, 255, 0.1);
}

/* ===================================================
   STANDARDIZED CARD GRID STYLING
   =================================================== */

.list-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
    /* Fix horizontal stretching */
    max-width: 100%;
    justify-content: start;
    /* Ensure all cards in the same row have equal heights */
    align-items: stretch;
    /* Add padding to prevent edge-to-edge layout */
    padding: 0.5rem;
}

.list-card {
    background: #ffffff;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease-in-out;
    display: flex;
    flex-direction: column;
    /* Variable-driven card system */
    min-height: var(--card-min-height, 320px);
    max-width: 400px;
    width: 100%;
    justify-self: start;
    /* Add margin to ensure no overlap even with box-shadow */
    margin: 0.25rem;
}

.list-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Fix for Bootstrap row cards that get stretched - ONLY WITHIN LIST VIEW CONTEXTS */
.list-view-container .row .list-card,
.list-view-container .row .card,
.list-card-grid .row .list-card,
.list-card-grid .row .card {
    height: 100%; /* Enable uniform heights */
    max-width: 400px !important; /* Prevent horizontal stretching in rows */
    width: 100% !important;
    display: flex;
    flex-direction: column;
}

/* Ensure cards in grid layouts maintain uniform heights */
.list-card-grid .card,
.list-view-container .card {
    height: 100%; /* Match grid cell height */
    display: flex;
    flex-direction: column;
}

/* Card body should grow to fill remaining space in uniform-height cards */
.list-card-grid .card-body,
.list-view-container .card-body {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

/* Card footer should stick to bottom in uniform-height cards */
.list-card-grid .card-footer,
.list-view-container .card-footer {
    margin-top: auto;
    flex-shrink: 0;
}

/* Additional card structure styling */
.list-view-container .list-card-header,
.list-card-grid .list-card-header {
    padding: 1.25rem 1.25rem 0.75rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: none;
}

.list-view-container .list-card-body,
.list-card-grid .list-card-body {
    padding: 0.75rem 1.25rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: var(--body-align, flex-start);
    align-items: var(--body-align-items, stretch);
    gap: var(--body-gap, 0.5rem);
    overflow: var(--card-body-overflow, hidden);
}

.list-view-container .list-card-footer,
.list-card-grid .list-card-footer {
    padding: 0.75rem 1.25rem 1.25rem 1.25rem;
    background-color: transparent;
    border-top: 1px solid #e9ecef;
    margin-top: auto;
}

.list-view-container .list-card-title,
.list-card-grid .list-card-title {
    margin: 0 0 0.25rem 0;
    font-size: var(--title-size, 1.125rem);
    font-weight: var(--title-weight, 600);
    color: #2c3e50;
    line-height: 1.3;
}

.list-view-container .list-card-subtitle,
.list-card-grid .list-card-subtitle {
    color: #6c757d;
    font-size: 0.875rem;
    font-weight: 400;
}

/* Form template specific improvements */
.list-card-grid .list-card {
    /* Ensure consistent card sizes for form templates */
    min-width: 300px;
    max-width: 380px;
    width: 100%;
    /* Height managed by CSS variables now */
}

/* Better grid layout for different screen sizes */
@media (min-width: 1400px) {
    .list-card-grid {
        grid-template-columns: repeat(auto-fill, minmax(340px, 360px));
        justify-content: start;
        max-width: none;
    }
}

@media (min-width: 1200px) and (max-width: 1399px) {
    .list-card-grid {
        grid-template-columns: repeat(auto-fill, minmax(320px, 350px));
        justify-content: start;
    }
}

@media (min-width: 992px) and (max-width: 1199px) {
    .list-card-grid {
        grid-template-columns: repeat(auto-fill, minmax(300px, 340px));
        justify-content: start;
    }
}

@media (min-width: 768px) and (max-width: 991px) {
    .list-card-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 320px));
        justify-content: start;
    }
}

/* ===================================================
   STANDARDIZED LOADING STATES
   =================================================== */

.list-loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
}

.list-loading-spinner {
    width: 3rem;
    height: 3rem;
    border: 0.3rem solid #e9ecef;
    border-top: 0.3rem solid #007bff;
    border-radius: 50%;
    animation: list-spinner-spin 1s linear infinite;
}

.list-loading-text {
    margin-top: 1rem;
    font-size: 1rem;
    color: #6c757d;
    font-weight: 500;
}

@keyframes list-spinner-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===================================================
   STANDARDIZED EMPTY STATES
   =================================================== */

.list-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
    background: #ffffff;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.list-empty-icon {
    font-size: 4rem;
    color: #dee2e6;
    margin-bottom: 1.5rem;
}

.list-empty-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: #495057;
    margin-bottom: 0.75rem;
}

.list-empty-description {
    font-size: 1rem;
    color: #6c757d;
    margin-bottom: 2rem;
    max-width: 400px;
}

.list-empty-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: center;
}

/* ===================================================
   STANDARDIZED STATUS BADGES
   =================================================== */

.list-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: 20px;
    border: 1px solid transparent;
    margin-bottom: var(--card-badge-mb, 0.25rem);
}

.list-status-badge.status-success {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    color: #155724;
    border-color: #c3e6cb;
}

.list-status-badge.status-warning {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    color: #856404;
    border-color: #ffeaa7;
}

.list-status-badge.status-danger {
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
    color: #721c24;
    border-color: #f5c6cb;
}

.list-status-badge.status-info {
    background: linear-gradient(135deg, #d1ecf1 0%, #bee5eb 100%);
    color: #0c5460;
    border-color: #bee5eb;
}

.list-status-badge.status-secondary {
    background: linear-gradient(135deg, #e2e3e5 0%, #d6d8db 100%);
    color: #383d41;
    border-color: #d6d8db;
}

.list-status-badge.status-primary {
    background: linear-gradient(135deg, #cce5ff 0%, #b3d7ff 100%);
    color: #004085;
    border-color: #b3d7ff;
}

/* ===================================================
   STANDARDIZED BULK ACTIONS
   =================================================== */

.list-bulk-actions {
    background: linear-gradient(135deg, rgba(0, 123, 255, 0.1) 0%, rgba(0, 123, 255, 0.05) 100%);
    border: 1px solid rgba(0, 123, 255, 0.2);
    border-radius: 8px;
    padding: 1rem 1.5rem;
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.list-bulk-selected-text {
    font-weight: 600;
    color: #004085;
    font-size: 0.875rem;
}

.list-bulk-actions-group {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* ===================================================
   STANDARDIZED PAGINATION
   =================================================== */

.list-pagination-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
    border-radius: 0 0 8px 8px;
}

.list-pagination-info {
    font-size: 0.875rem;
    color: #6c757d;
}

.list-pagination-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* ===================================================
   ACTION COLUMN IMPROVEMENTS
   =================================================== */

/* Action column flex layout for better spacing */
.list-table td .d-flex.gap-1 {
    align-items: center;
    justify-content: flex-start;
    flex-wrap: nowrap;
}

/* Ensure all dropdown buttons in action columns are consistently sized */
.list-table .dropdown .btn.dropdown-toggle {
    min-width: 40px !important;
    min-height: 32px !important;
    padding: 0.375rem 0.5rem !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* Fix dropdown toggle arrow positioning */
.list-table .dropdown .btn.dropdown-toggle::after {
    margin-left: 0.25rem !important;
    vertical-align: middle !important;
}

/* Ensure action buttons have consistent sizing */
.list-table .btn-group-sm .btn {
    min-height: 32px !important;
    min-width: 40px !important;
}

/* Improve action column spacing on mobile */
@media (max-width: 768px) {
    .list-table td .d-flex.gap-1 {
        flex-wrap: wrap;
        gap: 0.25rem !important;
    }
    
    .list-table .dropdown .btn.dropdown-toggle {
        min-width: 36px !important;
        min-height: 30px !important;
        padding: 0.25rem 0.375rem !important;
    }
}

/* ===================================================
   RESPONSIVE DESIGN
   =================================================== */

@media (max-width: 768px) {
    .list-view-content {
        padding: 1.5rem 1.5rem;
    }
    
    .list-page-header {
        padding: 1rem 1.5rem 0.75rem 1.5rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .list-page-header h1,
    .list-page-header h2,
    .list-page-header h3,
    .list-page-header h4 {
        font-size: 1.5rem;
    }
    
    .list-page-header .ms-auto {
        margin-left: 0;
        width: 100%;
        justify-content: flex-start;
    }
    
    .list-filter-body {
        padding: 1rem;
    }
    
    .list-filter-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }
    
    .list-card-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
        padding: 0.25rem;
    }
    
    .list-table-container {
        overflow-x: auto;
    }
    
    .list-pagination-container {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
    
    .list-bulk-actions {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
    
    .list-bulk-actions-group {
        justify-content: center;
    }
}

@media (max-width: 576px) {
    .list-view-content {
        padding: 1.5rem 1rem;
    }
    
    .list-page-header {
        padding: 0.75rem 1rem 0.5rem 1rem;
        margin-bottom: 1.5rem;
    }
    
    .list-filter-section {
        margin-bottom: 1rem;
    }
    
    .list-filter-body {
        padding: 0.75rem;
    }
    
    .list-table thead th,
    .list-table tbody td {
        padding: 0.5rem 0.375rem;
        font-size: 0.75rem;
    }
    
    .list-card-header,
    .list-card-body,
    .list-card-footer {
        padding: 1rem;
    }
    
    .list-empty-state {
        padding: 2rem 1rem;
    }
    
    .list-empty-icon {
        font-size: 3rem;
    }
    
    .list-empty-title {
        font-size: 1.25rem;
    }
}

/* ===================================================
   FORM TEMPLATES SPECIFIC FIXES
   =================================================== */

/* Prevent Bootstrap row from forcing equal heights/widths */
.list-card-grid .row {
    --bs-gutter-x: 1.5rem;
    --bs-gutter-y: 1.5rem;
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)) !important;
    gap: var(--bs-gutter-y) var(--bs-gutter-x) !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Override Bootstrap card width forcing */
.list-card-grid .card,
.list-card-grid .list-card {
    width: auto !important;
    max-width: 380px !important;
    min-width: 300px !important;
    height: auto !important;
    flex: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Fix for any Bootstrap column classes inside card grid */
.list-card-grid [class*="col-"] {
    flex: none !important;
    width: auto !important;
    max-width: 380px !important;
    min-width: 300px !important;
    padding: 0 !important;
}

/* Ensure card content doesn't stretch */
.list-card-grid .card-body,
.list-card-grid .list-card-body {
    flex: 1 1 auto;
    width: 100%;
    max-width: none;
}

/* Fix for flex utilities that might cause stretching */
.list-card-grid .d-flex {
    width: 100%;
    max-width: none;
}

.list-card-grid .w-100 {
    width: 100% !important;
    max-width: none !important;
}

/* Form templates card layout improvements */
.list-card-grid .list-card .row {
    --bs-gutter-x: 0.5rem;
    margin: 0;
    width: 100%;
}

.list-card-grid .list-card .row .col-4 {
    flex: 0 0 auto;
    width: 33.333333%;
    padding: 0 0.25rem;
}

/* Prevent text overflow in cards */
.list-card-grid .list-card .card-text {
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    max-width: 100%;
}

/* Status badge improvements in cards */
.list-card-grid .list-status-badge {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    display: inline-block;
}

/* Additional fix for any remaining stretch issues */
.list-card-grid * {
    box-sizing: border-box;
}

/* Force grid behavior on the card container */
.list-card-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(320px, max-content)) !important;
    justify-content: start !important;
    align-content: start !important;
    gap: 1.5rem !important;
}

/* Ensure cards maintain their intrinsic size */
.list-card-grid > * {
    justify-self: start !important;
    align-self: start !important;
    width: auto !important;
    max-width: 380px !important;
    min-width: 300px !important;
}

/* Override any Bootstrap width utilities */
.list-card-grid .w-100,
.list-card-grid .flex-fill {
    width: auto !important;
    max-width: 380px !important;
    flex: none !important;
}

/* ===================================================
   PRINT STYLES
   =================================================== */
@media print {
    .list-page-header,
    .list-filter-section,
    .list-bulk-actions,
    .list-pagination-container {
        background: none !important;
        border: 1px solid #000 !important;
        box-shadow: none !important;
    }
    
    .list-page-header .page-icon {
        color: #000 !important;
    }
    
    .list-table thead th {
        background: none !important;
        border: 1px solid #000 !important;
    }
    
    .list-table tbody td {
        border: 1px solid #000 !important;
    }
    
    .list-status-badge {
        background: none !important;
        border: 1px solid #000 !important;
        color: #000 !important;
    }
    
    .list-card {
        border: 1px solid #000 !important;
        box-shadow: none !important;
        break-inside: avoid;
    }
}

/* ===================================================
   HIGH CONTRAST MODE SUPPORT
   =================================================== */

@media (prefers-contrast: high) {
    .list-page-header,
    .list-filter-section,
    .list-table-container,
    .list-card {
        border-width: 2px !important;
    }
    
    .list-table thead th,
    .list-table tbody td {
        border-width: 2px !important;
    }
    
    .list-status-badge {
        border-width: 2px !important;
        font-weight: 700 !important;
    }
}

/* ===================================================
   REDUCED MOTION SUPPORT
   =================================================== */

@media (prefers-reduced-motion: reduce) {
    .list-card,
    .filter-form-control,
    .filter-form-select {
        transition: none !important;
    }
    
    .list-card:hover {
        transform: none !important;
    }
    
    .list-loading-spinner {
        animation: none !important;
    }
}

/* ===================================================
   UTILITY CLASSES
   =================================================== */

.list-view-table-mode .list-card-grid {
    display: none;
}

.list-view-grid-mode .list-table-container {
    display: none;
}

.list-highlight-row {
    background-color: rgba(255, 193, 7, 0.1) !important;
}

.list-selected-row {
    background-color: rgba(0, 123, 255, 0.1) !important;
}

.list-error-row {
    background-color: rgba(220, 53, 69, 0.1) !important;
}

.list-success-row {
    background-color: rgba(40, 167, 69, 0.1) !important;
}

.list-text-primary {
    color: #007bff !important;
}

.list-text-secondary {
    color: #6c757d !important;
}

.list-text-success {
    color: #28a745 !important;
}

.list-text-danger {
    color: #dc3545 !important;
}

.list-text-warning {
    color: #ffc107 !important;
}

.list-text-info {
    color: #17a2b8 !important;
}

.list-text-muted {
    color: #6c757d !important;
}

.list-font-weight-bold {
    font-weight: 600 !important;
}

.list-font-weight-normal {
    font-weight: 400 !important;
}

/* Form Settings specific styles */
.form-setting-status-text {
    font-weight: 700 !important;
    color: inherit;
    font-size: inherit;
    line-height: inherit;
}

/* Workflow Actions specific styles */
.list-card-body .list-font-weight-bold {
    font-weight: 600 !important;
    color: inherit;
    font-size: inherit;
}

/* Ensure workflow action status badges are properly positioned */
.list-card .list-status-badge {
    margin-bottom: 0.5rem;
    display: inline-block;
    white-space: nowrap;
}

/* Add proper spacing for workflow action card content */
.list-card-body .text-center {
    margin-top: auto;
    padding-bottom: 0.5rem;
}

/* Workflow Actions - now handled by page variables */

.list-small-text {
    font-size: 0.75rem !important;
}

.list-large-text {
    font-size: 1.125rem !important;
}

/* Variable-Based Metric Class for Big Numbers */
.list-metric {
    font-size: var(--metric-font-size, 2rem);
    line-height: 1.1;
    font-weight: var(--metric-weight, 700);
    color: inherit;
    margin: 0;
}

/* ===================================================
   PAGE-SPECIFIC VARIABLE SCOPES
   =================================================== */

/* Work Hours Page - Bigger time display, taller cards */
.work-hours-page {
    --card-min-height: 360px;
    --metric-font-size: 2.5rem;
    --card-badge-mb: 0.5rem;
    --body-gap: 0.75rem;
}

/* Enforce strict equal heights for work hours cards */
.work-hours-page .list-card-grid {
    grid-auto-rows: 1fr !important;
    align-items: stretch !important;
}

.work-hours-page .list-card {
    height: 100% !important;
    min-height: 360px !important;
    display: flex !important;
    flex-direction: column !important;
}

/* Form Submissions Page - Badges don't clip, footer actions align cleanly */
.submissions-page {
    --card-min-height: 380px;
    --card-body-overflow: visible;
    --body-align: flex-start;
    --card-badge-mb: 0.5rem;
}

/* SMTP Settings Page - Moderate height, large port value */
.smtp-settings-page {
    --card-min-height: 340px;
    --metric-font-size: 2.25rem;
    --metric-weight: 600;
}

/* User Management Page - Roles area + actions spacing */
.user-management-page {
    --card-min-height: 360px;
    --body-align: flex-start;
    --card-badge-mb: 0.5rem;
    --body-gap: 0.75rem;
}

/* Form Templates Page - Consistent height cards with proper content spacing */
.form-templates-page {
    --card-min-height: 320px;
    --card-body-overflow: hidden;
    --body-align: flex-start;
    --card-badge-mb: 0.25rem;
    --title-size: 1.1rem;
    --title-weight: 600;
    --metric-font-size: 1.5rem;
    --metric-weight: 600;
}

/* Form Settings Page - Consistent height with status badges and email notification info */
.form-settings-page {
    --card-min-height: 400px;
    --card-body-overflow: visible;
    --body-align: flex-start;
    --card-badge-mb: 0.5rem;
    --title-size: 1.25rem;
    --title-weight: 600;
    --body-gap: 0.75rem;
}

/* My Forms Page - Taller cards to accommodate two-row action footer */
.my-forms-page {
    --card-min-height: 420px;
    --card-body-overflow: visible;
    --body-align: flex-start;
    --card-badge-mb: 0.5rem;
    --title-size: 1.25rem;
    --title-weight: 600;
    --body-gap: 0.75rem;
}

/* Email Templates Page - Professional card layout with template details */
.email-templates-page {
    --card-min-height: 380px;
    --card-body-overflow: visible;
    --body-align: flex-start;
    --card-badge-mb: 0.5rem;
    --title-size: 1.125rem;
    --title-weight: 600;
    --body-gap: 0.75rem;
}

/* Enforce strict equal heights for email template cards */
.email-templates-page .list-card-grid {
    grid-auto-rows: 1fr !important;
    align-items: stretch !important;
}

.email-templates-page .list-card {
    height: 100% !important;
    min-height: 380px !important;
    display: flex !important;
    flex-direction: column !important;
}

/* Enforce strict equal heights for my forms cards */
.my-forms-page .list-card-grid {
    grid-auto-rows: 1fr !important;
    align-items: stretch !important;
}

.my-forms-page .list-card {
    height: 100% !important;
    min-height: 420px !important;
    display: flex !important;
    flex-direction: column !important;
}

/* ===================================================
   MOBILE/TABLET SCROLLING ENHANCEMENTS
   =================================================== */

/* Ensure all list views support proper mobile scrolling */
@media (any-pointer: coarse), (pointer: coarse), (hover: none), screen and (max-width: 1024px) {
    
    /* Force touch scrolling on all list components */
    .list-view-container,
    .list-table-container,
    .list-card-grid,
    .list-filter-section {
        -webkit-overflow-scrolling: touch !important;
        touch-action: pan-y !important;
    }
    
    /* Table responsiveness improvements for mobile */
    .list-table-container {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        touch-action: pan-x pan-y !important;
        max-width: 100vw;
    }
    
    .list-table {
        min-width: fit-content;
        width: 100%;
    }
    
    /* Prevent table from breaking mobile layout */
    .list-table thead th,
    .list-table tbody td {
        white-space: nowrap;
        min-width: fit-content;
    }
    
    /* Card grid mobile optimizations */
    .list-card-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
        padding: 0.5rem;
    }
    
    .list-card {
        width: 100%;
        margin-bottom: 0.5rem;
        touch-action: manipulation;
    }
    
    /* Filter section mobile improvements */
    .list-filter-section {
        margin-bottom: 1rem;
        overflow: visible;
    }
    
    .list-filter-body {
        padding: 1rem 0.5rem;
    }
    
    .list-filter-controls {
        flex-direction: column;
        gap: 0.75rem;
        align-items: stretch;
    }
    
    /* Pagination mobile fixes */
    .list-pagination-container {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem 0.5rem;
    }
    
    /* Bulk actions mobile layout */
    .list-bulk-actions {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem 0.5rem;
    }
    
    .list-bulk-actions-group {
        justify-content: center;
        flex-wrap: wrap;
    }
    
    /* Loading and empty states mobile */
    .list-loading-container,
    .list-empty-state {
        padding: 2rem 1rem;
    }
    
    .list-empty-icon {
        font-size: 3rem;
    }
    
    .list-empty-actions {
        flex-direction: column;
        align-items: center;
        gap: 0.5rem;
    }
}

/* Mobile-specific table enhancements */
@media screen and (max-width: 768px) {
    
    /* Make tables horizontally scrollable */
    .list-table-container {
        overflow-x: auto;
        overflow-y: visible;
        -webkit-overflow-scrolling: touch;
        border-radius: 8px;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }
    
    /* Responsive table styling */
    .list-table {
        font-size: 0.75rem;
        min-width: 600px; /* Ensure table doesn't get too cramped */
    }
    
    .list-table thead th {
        padding: 0.5rem 0.25rem;
        font-size: 0.7rem;
        position: sticky;
        top: 0;
        background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
        z-index: 1;
    }
    
    .list-table tbody td {
        padding: 0.5rem 0.25rem;
        font-size: 0.75rem;
    }
    
    /* Action buttons in tables */
    .list-table .btn-group-sm .btn {
        font-size: 0.65rem;
        padding: 0.2rem 0.4rem;
        min-width: 32px;
        min-height: 32px;
    }
    
    .list-table .dropdown .btn.dropdown-toggle {
        min-width: 32px !important;
        min-height: 32px !important;
        padding: 0.2rem 0.4rem !important;
    }
    
    /* Status badges in mobile tables */
    .list-status-badge {
        font-size: 0.6rem;
        padding: 0.25rem 0.5rem;
    }
}

/* Tablet-specific optimizations */
@media screen and (min-width: 769px) and (max-width: 1024px) and (any-pointer: coarse) {
    
    /* Tablet card grid - 2 columns */
    .list-card-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.25rem;
    }
    
    /* Tablet table optimizations */
    .list-table {
        font-size: 0.8rem;
    }
    
    .list-table thead th,
    .list-table tbody td {
        padding: 0.75rem 0.5rem;
    }
    
    /* Larger touch targets for tablet */
    .list-table .btn {
        min-width: 36px;
        min-height: 36px;
    }
    
    .list-table .dropdown .btn.dropdown-toggle {
        min-width: 36px !important;
        min-height: 36px !important;
    }
}

/* Horizontal scrolling table indicator */
.list-table-container::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 20px;
    background: linear-gradient(90deg, transparent, rgba(0,0,0,0.1));
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.list-table-container.has-horizontal-scroll::after {
    opacity: 1;
}

/* Enhanced touch scrolling for nested containers */
.list-view-container .modal-body,
.list-view-container .dropdown-menu,
.list-view-container .tooltip-inner {
    -webkit-overflow-scrolling: touch !important;
    touch-action: pan-y !important;
}

/* ===================================================
   SUBMISSION CARD SPECIFIC STYLING
   =================================================== */

/* Ensure submission cards have minimum height and proper spacing */
.submission-card {
    min-height: 280px;
    position: relative;
}

/* Submission card actions - prevent overlap and ensure proper spacing */
.submission-card .list-card-footer {
    padding: 0.75rem 1.25rem 1rem 1.25rem;
}

/* Primary actions row - ensure buttons don't overflow */
.submission-card .list-card-footer .d-flex.flex-wrap {
    min-height: 32px;
    align-items: center;
}

/* Secondary actions row - ensure proper spacing */
.submission-card .list-card-footer .d-flex.justify-content-center {
    margin-top: 0.5rem;
    min-height: 32px;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* Ensure action buttons have consistent sizing */
.submission-card .btn-sm {
    min-width: 32px;
    min-height: 32px;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

/* Mobile-specific submission card adjustments */
@media (max-width: 768px) {
    .submission-card {
        min-height: 320px; /* Extra height for mobile to accommodate wrapped buttons */
    }
    
    .submission-card .list-card-footer {
        padding: 0.75rem 1rem 1rem 1rem;
    }
    
    /* Ensure buttons wrap properly on mobile */
    .submission-card .list-card-footer .d-flex.flex-wrap {
        justify-content: center;
        gap: 0.25rem;
    }
    
    /* Secondary actions - full width buttons on mobile */
    .submission-card .list-card-footer .d-flex.justify-content-center {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .submission-card .list-card-footer .d-flex.justify-content-center .btn {
        width: 100%;
        max-width: 200px;
        margin: 0 auto;
    }
    
    /* Reduce button sizes slightly for mobile */
    .submission-card .btn-sm {
        min-width: 28px;
        min-height: 28px;
        padding: 0.2rem 0.4rem;
        font-size: 0.7rem;
    }
}

/* Tablet-specific adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
    .submission-card .list-card-footer .d-flex.flex-wrap {
        justify-content: space-between;
    }
    
    .submission-card .btn-sm {
        min-width: 30px;
        min-height: 30px;
        padding: 0.2rem 0.4rem;
    }
}

/* Bulk actions mobile improvements */
@media (max-width: 768px) {
    .list-bulk-actions {
        padding: 1rem 0.5rem;
    }
    
    .list-bulk-actions-group {
        flex-direction: column;
        gap: 0.5rem;
        align-items: stretch;
    }
    
    .list-bulk-actions-group .btn {
        width: 100%;
        white-space: nowrap;
        text-align: center;
    }
}

/* Select all checkbox section mobile */
@media (max-width: 768px) {
    .list-view-container .mb-3.d-flex {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}

/* Prevent zoom on input focus (mobile Safari) */
@media screen and (max-width: 768px) {
    .list-filter-section input,
    .list-filter-section select,
    .list-filter-section textarea {
        font-size: 16px !important; /* Prevents iOS zoom */
        max-width: 100%;
        touch-action: manipulation;
    }
}

/* Performance optimizations for mobile scrolling */
.list-table-container,
.list-card-grid,
.list-card {
    contain: layout style;
    will-change: scroll-position;
}

/* Force hardware acceleration on mobile */
@media (any-pointer: coarse) {
    .list-table-container,
    .list-card-grid {
        transform: translateZ(0);
        backface-visibility: hidden;
    }
}

/* Debug helper for scrolling issues (development only) */
.debug-scrolling .list-table-container {
    border: 2px solid red !important;
}

.debug-scrolling .list-table-container::before {
    content: 'SCROLLABLE TABLE';
    position: absolute;
    top: -20px;
    left: 0;
    background: red;
    color: white;
    font-size: 10px;
    padding: 2px 4px;
    z-index: 1000;
}