@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* 
* ClearSurvey Pro - Professional Style Sheet
* Clean, government-ready design
* Updated color palette:
* - Primary Blue: #0360a8
* - Secondary Blue: #0360a8  
* - Accent Yellow: #FFD200
* - Dark Gray: #333333
* - Light Gray: #f8f9fa
* - Border: #dee2e6
* - White: #FFFFFF
*/

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Reset body margins for full-width header */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: #333333;
    font-size: 14px;
    background: #f8f9fa;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Ensure all text elements use Inter */
button, input, select, textarea, .btn {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* App Header - Full width background, content positioned properly */
.app-header {
    background-color: #ffffff;
    border-bottom: 1px solid #dee2e6;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    width: 100%;
    margin-bottom: 0;
    padding: 1rem 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Create a centered container for header content */
.app-header-container {
    max-width: 1200px;
    width: 100%;
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Apply container styling to direct children */
.app-header {
    justify-content: center;
}

.app-header > * {
    max-width: 1200px;
    width: 100%;
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Header Navigation */
.header-nav {
    display: flex;
    align-items: center;
    margin-left: auto; /* Pushes nav to the right */
    padding-right: 1.5rem; /* Match logo container padding */
    width: auto; /* Override parent's width if necessary */
    max-width: none; /* Override parent's max-width */
    justify-content: flex-end; /* Align items to the end */
}

.header-nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 0.75rem; /* Slightly reduced gap between nav items */
}

.header-nav li a {
    text-decoration: none;
    color: #0360a8; /* Primary Blue */
    font-weight: 500;
    font-size: 0.9rem;
    padding: 0.5rem 1rem; /* Increased horizontal padding */
    border-radius: 4px;
    transition: all 0.2s ease;
    display: inline-block;
}

.header-nav li a:hover,
.header-nav li a:focus {
    background-color: rgba(3, 96, 168, 0.1);
    text-decoration: none;
}

/* Logo positioning */
.app-header .logo-container {
    padding: 0 1.5rem; /* Match container padding on both sides */
    display: flex;
    align-items: center;
    justify-content: flex-start;
    flex-grow: 1;
}

.app-header .header-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-container {
    display: flex;
    align-items: center;
}

.logo {
    height: 48px;
    max-width: 280px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Typography - Clean and Readable */
h1 {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #333333;
    font-family: 'Inter', sans-serif;
}

h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    font-weight: 600;
    color: #333333;
    font-family: 'Inter', sans-serif;
}

h3, .section-title {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    font-weight: 600;
    color: #333333;
    font-family: 'Inter', sans-serif;
}

.subtitle {
    color: #6c757d;
    margin-bottom: 2rem;
    font-size: 1rem;
}

/* Main Layout */
.main-content {
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
    background: #f8f9fa;
    min-height: calc(100vh - 140px);
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 0;
    background: transparent;
}

/* Upload Section - Clean and Modern */
.upload-container {
    background: #ffffff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 3rem 2rem;
    margin-bottom: 2rem;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.upload-area {
    border: 2px dashed #ced4da;
    border-radius: 8px;
    padding: 3rem 2rem;
    background: #f8f9fa;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.upload-area:hover {
    border-color: #0072CE;
    background: #f0f8ff;
}

.upload-area.dragover {
    border-color: #0360a8;
    background: #e6f3ff;
    transform: scale(1.01);
}

.upload-icon {
    font-size: 3rem;
    color: #6c757d;
    margin-bottom: 1rem;
}

.upload-text {
    color: #333333;
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.upload-subtext {
    color: #6c757d;
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

#id_excel_file {
    display: none;
}

/* Table Preview on File Detail Page */
table#data-table td,
table#data-table th {
    font-size: 0.8rem; /* Smaller font for table cells */
    padding: 0.2rem; /* Adjust padding for smaller font */
}

/* File list on upload page */
.scrollable-file-list {
    max-height: 400px; /* Adjust as needed */
    overflow-y: auto;
    border: 1px solid #ddd;
    padding: 10px;
    margin-bottom: 20px;
}

.file-list .file-item .file-title {
    font-size: 0.9rem; /* Smaller font size for file names */
    font-weight: 500;
}

/* File Info Display */
.file-info {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 1rem;
    margin: 1rem 0;
    text-align: left;
}

.file-name {
    font-weight: 600;
    color: #333333;
    margin-bottom: 0.25rem;
}

.file-size {
    color: #6c757d;
    font-size: 0.85rem;
}

/* Buttons - Professional and Clean */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    border: 1px solid #dee2e6;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
}

/* Base button styles */
.btn, .btn-primary, .btn-success, .btn-danger, .upload-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    line-height: 1.5;
    border-radius: 4px;
    height: 38px;
    min-width: 100px;
    text-align: center;
    vertical-align: middle;
    cursor: pointer;
    user-select: none;
    transition: all 0.15s ease-in-out;
}

.btn-primary, .upload-btn {
    background-color: #0072CE;
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(3, 96, 168, 0.2);
}

.btn-primary:hover, .upload-btn:hover, .file-actions .btn-primary:hover,
#apply-rules-btn:hover, #add-rule-btn:hover, #submit-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(3, 96, 168, 0.4);
}

/* Success Button - Green */
.btn-success, .download-btn, #download-themed-csv, #download-full-excel, .download-cleared {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(5, 150, 105, 0.2);
}

.btn-success:hover, .download-btn:hover, #download-themed-csv:hover, 
#download-full-excel:hover, .download-cleared:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.4);
}

/* Danger Button - Red */
.btn-danger, .delete-btn, #clear-rules-btn, .file-actions .btn-danger {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(220, 38, 38, 0.2);
}

.btn-danger:hover, .delete-btn:hover, .file-actions .btn-danger:hover,
#clear-rules-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.4);
}

/* Base button styles */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.65rem 1.5rem;
    font-size: 0.95rem;
    line-height: 1.5;
    font-weight: 500;
    text-align: center;
    text-decoration: none;
    white-space: nowrap;
    vertical-align: middle;
    cursor: pointer;
    user-select: none;
    border: none;
    border-radius: 8px;
    min-height: 42px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    box-sizing: border-box;
    min-width: 120px;
    position: relative;
    overflow: hidden;
}

.btn::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(rgba(255, 255, 255, 0.2), transparent);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.btn:hover::after {
    opacity: 1;
}

.btn:active {
    transform: translateY(0) !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2) !important;
}

/* Secondary Button */
.btn-secondary {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    color: #4B5563;
    border: 1px solid #E5E7EB;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.btn-secondary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    background: #ffffff;
    color: #1F2937;
}

.btn-secondary:active {
    transform: translateY(0);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}



/* Danger Button - Red */
.btn-danger, .delete-btn, #clear-rules-btn, .file-actions .btn-danger {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    color: #ffffff;
}

.btn-danger:hover, .delete-btn:hover, .file-actions .btn-danger:hover,
#clear-rules-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
}

.btn-danger:active, .delete-btn:active, .file-actions .btn-danger:active,
#clear-rules-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(220, 38, 38, 0.2);
}

/* Rule Builder Column List */
.columns-list {
    max-height: 200px; /* Adjust height as needed */
    overflow-y: auto;
    border: 1px solid #dee2e6; /* Matches form-control border */
    border-radius: 6px; /* Matches form-control border-radius */
    padding: 0.5rem;
    background-color: #ffffff; /* White background */
    margin-top: 0.5rem;
}

.column-checkbox {
    display: block; /* Each checkbox on its own line */
    padding: 0.25rem 0.5rem;
}

.column-checkbox label {
    display: block;
    cursor: pointer;
    font-weight: normal; /* Override any bolding */
}

.column-checkbox:hover {
    background-color: #f8f9fa; /* Light hover effect */
}

/* Action buttons container */
.action-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
    align-items: center;
}

/* Apply button wrapper */
.apply-button-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center; /* Center the button and spinner horizontally */
    gap: 0.5rem; /* Space between button and spinner */
}

/* Overriding spinner style for this context */
.rules-list-container .spinner {
    margin-left: 0; /* Remove the left margin */
    vertical-align: unset; /* Remove vertical alignment */
}

/* Messages and Alerts */
.messages {
    margin-bottom: 1.5rem;
}

.alert {
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-weight: 500;
    border-left: 4px solid;
}

.alert-success {
    background-color: #d1ecf1;
    color: #0c5460;
    border-left-color: #0360a8;
}

.alert-error {
    background-color: #f8d7da;
    color: #721c24;
    border-left-color: #dc3545;
}

/* Pagination - Clean and Simple */
.pagination {
    margin-top: 1.5rem;
    text-align: center;
}

.pagination .step-links {
    display: inline-block;
}

.pagination .pagination-link,
.pagination .current-page {
    padding: 0.5rem 0.75rem;
    margin: 0 0.125rem;
    border: 1px solid #dee2e6;
    text-decoration: none;
    color: #0264af;
    border-radius: 4px;
    transition: all 0.2s ease;
    font-size: 0.9rem;
}

.pagination .pagination-link:hover {
    background-color: #f8f9fa;
}

.pagination .current-page {
    background-color: #0072CE;
    color: #ffffff;
    border-color: #0072CE;
}

/* Spinner - Clean Animation */
.spinner-container {
    text-align: center;
    margin: 1rem 0;
}

.spinner {
    border: 3px solid #f8f9fa;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border-left-color: #0360a8;
    margin: 0 auto 0.5rem;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* No Files State */
.no-files {
    text-align: center;
    color: #6c757d;
    font-style: italic;
    padding: 3rem;
    background-color: #ffffff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
}

/* File Detail Page Styles */
.file-detail-body {
    background: #f8f9fa;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #dee2e6;
}

.back-link {
    color: #0264af;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
}

.back-link:hover {
    color: #0056A0;
    text-decoration: underline;
}

.file-info {
    background-color: #ffffff;
    border-radius: 8px;
    border: 1px solid #dee2e6;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
    border-top: 3px solid #FFD200;
}

.file-info .d-flex {
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-start;
}

.file-info .file-actions {
    margin-left: auto;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .file-info {
        padding: 1rem;
    }
    
    .file-info .d-flex {
        flex-direction: column;
        gap: 1rem;
    }
    
    .file-info .file-actions {
        width: 100%;
        margin-left: 0;
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .file-info .btn,
    .action-buttons .btn,
    #apply-rules-btn,
    #clear-rules-btn,
    #download-cleared-btn {
        width: 100%;
        margin-top: 0;
        height: 38px;
        min-width: 100%;
    }
    
    .action-buttons {
        gap: 0.5rem;
    }
    
    .apply-button-wrapper {
        width: 100%;
    }
    
    .file-meta {
        font-size: 0.85rem;
    }
}

.file-title {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: #333333;
    font-weight: 600;
}

.file-meta {
    color: #6c757d;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

/* Card Components */
.card, .section {
    background: #ffffff;
    border: 1px solid #dee2e6;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Table Styles - Clean and Readable */
.table-container {
    width: 100%;
    overflow-x: auto;
    margin-bottom: 1.5rem;
    height: 500px !important;
    min-height: 500px !important;
    overflow-y: scroll !important;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    background: #ffffff;
    position: relative;
    display: block;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
    background: #ffffff;
}

table td, table th {
    border: 1px solid #dee2e6;
    padding: 0.5rem;
    min-width: 120px;
    max-width: 250px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.85rem;
}

table th {
    position: sticky;
    top: 0;
    background-color: #f8f9fa;
    z-index: 10;
    font-weight: 600;
    text-align: left;
    border-bottom: 2px solid #dee2e6;
}

tr:hover {
    background-color: #f8f9fa;
}

/* Transformation Rules */
.transformation-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    max-width: 100%;
}

.rule-builder, .rules-list-container {
    background-color: #ffffff;
    border-radius: 8px;
    padding: 1.5rem;
    border: 1px solid #dee2e6;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #333333;
}

.form-control {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: 'Inter', sans-serif;
}

.form-control:focus {
    border-color: #0072CE;
    box-shadow: 0 0 0 0.2rem rgba(3, 96, 168, 0.25);
    outline: 0;
}

/* Ensure select dropdowns with long options don't overflow their containers */
select.form-control {
    max-width: 100%;
}

/* Rules List */
.rules-list {
    margin-bottom: 1.5rem;
    max-height: 300px;
    overflow-y: auto;
}

.rule-item {
    background-color: #ffffff;
    border-left: 3px solid #FFD200;
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 1rem;
    position: relative;
    border: 1px solid #dee2e6;
}

.rule-header {
    font-weight: 600;
    margin-bottom: 0.5rem;
    padding-right: 2rem;
}

.rule-content {
    color: #6c757d;
    font-size: 0.85rem;
}

.delete-rule {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    color: #dc3545;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.25rem;
}

/* Footer */
.app-footer {
    background-color: #ffffff;
    color: #6c757d;
    padding: 1.5rem 2rem;
    margin-top: 2rem;
    text-align: center;
    border-top: 1px solid #dee2e6;
    font-size: 0.85rem;
}

/* AI Analysis Section */
.ai-analysis-container .card-header {
    background-color: #e9ecef; /* Light gray, similar to other headers */
    border-bottom: 1px solid #dee2e6;
}

.ai-analysis-container .section-title i {
    color: #0264af; /* Accent color for the icon */
}

.ai-analysis-container .form-select {
    border-radius: 6px;
}



.ai-analysis-container .section-title i {
    color: #0264af; /* Accent color for the icon */
}

.ai-analysis-container .form-select {
    border-radius: 6px;
}

.ai-analysis-container .ai-results-placeholder {
    background-color: #f8f9fa; /* Very light gray for the placeholder */
    border: 1px dashed #ced4da; /* Dashed border to indicate placeholder */
    color: #6c757d; /* Muted text color */
    display: flex;
    align-items: center;
    justify-content: center;
    font-style: italic;
    min-height: 150px;
}

/* Responsive Design */
@media (max-width: 768px) {
    /* Mobile Button Styles */
    .btn, .btn-primary, .btn-secondary, .btn-success, .btn-danger,
    .upload-btn, .download-btn, .delete-btn,
    #download-themed-csv, #download-full-excel, #clear-rules-btn, #apply-rules-btn,
    .file-actions .btn {
        min-height: 44px;
        padding: 0.8rem 1rem;
        font-size: 0.95rem;
        border-radius: 8px;
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
        white-space: nowrap;
        text-align: center;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        margin: 0.25rem 0;
    }
    
    /* File actions container for mobile */
    .file-actions {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        width: 100%;
        margin-top: 0.75rem;
    }
    
    /* Ensure form buttons take full width */
    .file-actions form {
        width: 100%;
        display: flex;
    }

    /* Disable hover effects on mobile */
    .btn:hover, .btn:active, .btn:focus,
    .btn-primary:hover, .btn-primary:active, .btn-primary:focus,
    .btn-secondary:hover, .btn-secondary:active, .btn-secondary:focus,
    .btn-success:hover, .btn-success:active, .btn-success:focus,
    .btn-danger:hover, .btn-danger:active, .btn-danger:focus {
        transform: none;
        box-shadow: none;
    }

    /* Mobile Header Optimization */
    .app-header {
        padding: 0.75rem 0;
    }
    
    .app-header > * {
        padding: 0 1rem;
    }
    
    .logo {
        height: 36px;
        max-width: 200px;
    }
    
    .header-actions {
        gap: 0.5rem;
    }
    
    .back-link {
        font-size: 0.9rem;
        padding: 0.5rem;
    }

    /* Mobile Container and Layout */
    .container {
        padding: 1rem;
        max-width: none;
    }
    
    .main-content {
        padding: 1rem;
    }

    /* Mobile Typography */
    h1 {
        font-size: 1.5rem;
        margin-bottom: 0.75rem;
    }
    
    h2, .section-title {
        font-size: 1.25rem;
        margin-bottom: 0.75rem;
    }
    
    .subtitle {
        font-size: 0.9rem;
        margin-bottom: 1.5rem;
    }

    /* Mobile Upload Section */
    .upload-container {
        padding: 1.5rem 1rem;
        margin-bottom: 1.5rem;
    }
    
    .upload-area {
        padding: 2rem 1rem;
    }
    
    .upload-icon {
        font-size: 2.5rem;
        margin-bottom: 0.75rem;
    }
    
    .upload-text {
        font-size: 1.1rem;
        margin-bottom: 0.5rem;
    }
    
    .upload-subtext {
        font-size: 0.85rem;
        margin-bottom: 1rem;
    }

    /* Mobile File Lists */
    .file-item {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
        padding: 1rem;
    }
    
    .file-details {
        order: 1;
        width: 100%;
        max-width: 100%;
        margin-bottom: 0.5rem;
    }
    
    .file-actions {
        order: 2;
        width: 100%;
        display: flex;
        gap: 0.75rem;
        margin: 0.75rem 0 0 0;
        padding: 0;
        flex-wrap: wrap;
    }
    
    .file-actions .btn {
        flex: 1 1 calc(50% - 0.375rem);
        min-width: 0;
        padding: 0.6rem 0.75rem;
        font-size: 0.9rem;
        min-height: 42px;
    }
    
    .file-actions {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr 1fr; /* Two equal columns */
        gap: 0.75rem;
        margin: 0;
        padding: 0;
    }
    
    .file-actions .btn {
        width: 100%;
        margin: 0;
        padding: 0.5rem 0.5rem;
        font-size: 0.9rem;
        height: 42px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        box-sizing: border-box;
    }
    
    .file-actions .btn i {
        margin-right: 0.3rem;
        font-size: 1rem;
        flex-shrink: 0;
    }
    
    .action-btn, .download-btn, .delete-btn {
        width: 100%;
        text-align: center;
        padding: 0.75rem;
        font-size: 0.9rem;
    }

    /* Mobile Table Optimization */
    .table-container {
        height: 400px !important;
        min-height: 400px !important;
        margin-bottom: 1rem;
    }
    
    table td, table th {
        padding: 0.5rem 0.25rem;
        font-size: 0.75rem;
        min-width: 100px;
        max-width: 150px;
    }
    
    table th {
        font-size: 0.75rem;
        padding: 0.5rem 0.25rem;
    }

    /* Mobile Forms and Inputs */
    .form-control {
        padding: 0.75rem;
        font-size: 1rem; /* Prevent zoom on iOS */
        border-radius: 8px;
        width: 100%;
        box-sizing: border-box;
    }
    
    .btn {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
        min-height: 44px; /* Touch target size */
        border-radius: 8px;
        width: 100%;
        box-sizing: border-box;
    }

    /* Mobile Transformation Rules */
    .transformation-container {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .rule-builder, .rules-list-container {
        padding: 1rem;
    }
    
    .form-group {
        margin-bottom: 1.5rem;
        clear: both;
        overflow: hidden;
    }
    
    .form-group label {
        margin-bottom: 0.75rem;
        font-size: 0.9rem;
        display: block;
        width: 100%;
        clear: both;
    }

    /* Mobile Checkboxes and Target Columns */
    .target-columns-container {
        max-height: 300px;
        padding: 1rem;
        margin-top: 0.75rem;
    }
    
    .columns-list {
        grid-template-columns: 1fr;
        gap: 0.75rem;
        max-height: 200px;
        overflow-y: auto;
    }
    
    .column-checkbox {
        margin-bottom: 0.5rem;
        clear: both;
    }
    
    .column-checkbox label {
        padding: 0.75rem;
        background: #f8f9fa;
        border-radius: 8px;
        margin-bottom: 0;
        min-height: 48px;
        display: flex;
        align-items: flex-start;
        line-height: 1.4;
        word-break: break-word;
        hyphens: auto;
        gap: 0.75rem;
    }
    
    .column-checkbox input[type="checkbox"] {
        width: 20px;
        height: 20px;
        margin: 0;
        flex-shrink: 0;
        margin-top: 2px;
    }
    
    .column-checkbox label span,
    .column-checkbox label {
        font-size: 0.85rem;
        flex: 1;
    }

    /* Fix select all container */
    .select-all-container {
        margin-bottom: 1rem;
        padding-bottom: 1rem;
        border-bottom: 1px solid #dee2e6;
    }
    
    .select-all-container label {
        background: #e9ecef !important;
        font-weight: 600;
        padding: 0.75rem !important;
        border-radius: 8px;
        display: flex !important;
        align-items: center;
        gap: 0.75rem;
        min-height: 48px;
    }

    /* Mobile Action Field Fixes */
    .form-group:has(#action-type) {
        margin-bottom: 2rem;
    }
    
    #action-value-container,
    #source-column-container {
        margin-top: 1rem;
        clear: both;
    }

    /* Mobile Rules List */
    .rule-item {
        padding: 0.75rem;
        margin-bottom: 0.75rem;
    }
    
    .rule-header {
        font-size: 0.9rem;
        margin-bottom: 0.5rem;
        padding-right: 1.5rem;
    }
    
    .rule-content {
        font-size: 0.8rem;
    }
    
    .delete-rule {
        top: 0.5rem;
        right: 0.5rem;
        font-size: 1.1rem;
        padding: 0.25rem;
        min-width: 32px;
        min-height: 32px;
    }

    /* Mobile Action Buttons */
    .action-buttons {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .action-buttons button {
        width: 100%;
        padding: 0.75rem;
        font-size: 0.9rem;
    }

    /* Mobile Pagination */
    .pagination {
        margin-top: 1rem;
    }
    
    .pagination .pagination-link,
    .pagination .current-page {
        padding: 0.5rem 0.75rem;
        margin: 0 0.125rem;
        font-size: 0.85rem;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* Mobile Messages and Alerts */
    .alert {
        padding: 0.75rem;
        margin-bottom: 0.75rem;
        font-size: 0.9rem;
    }
    
    .messages {
        margin-bottom: 1rem;
    }

    /* Mobile File Info */
    .file-info {
        padding: 1rem;
        margin-bottom: 1rem;
    }
    
    .file-title {
        font-size: 1.25rem;
        margin-bottom: 0.5rem;
        word-break: break-word;
    }
    
    .file-meta {
        font-size: 0.8rem;
        line-height: 1.4;
    }

    /* Mobile Sections */
    .section, .card {
        padding: 1rem;
        margin-bottom: 1rem;
    }

    /* Mobile Footer */
    .app-footer {
        padding: 1rem;
        font-size: 0.8rem;
    }

    /* Mobile Spinner */
    .spinner-container {
        margin: 0.75rem 0;
    }
    
    .spinner {
        width: 28px;
        height: 28px;
        border-width: 3px;
    }

    /* Mobile File Name Display */
    .file-name {
        word-break: break-word;
        hyphens: auto;
    }
    
    .file-title a {
        word-break: break-word;
        hyphens: auto;
    }

    /* AI Analysis Section */
    .ai-analysis-container .card-header {
        background-color: #e9ecef; /* Light gray, similar to other headers */
        border-bottom: 1px solid #dee2e6;
    }
    
    .transformation-container {
        gap: 1.5rem;
    }
    
    .table-container {
        height: 450px !important;
    }
}

/* Very small mobile devices */
@media (max-width: 480px) {
    .app-header > * {
        padding: 0 0.75rem;
    }
    
    .container {
        padding: 0.75rem;
    }
    
    .upload-container {
        padding: 1rem 0.75rem;
    }
    
    .upload-area {
        padding: 1.5rem 0.75rem;
    }
    
    .file-item {
        padding: 0.75rem;
    }
    
    .section, .card {
        padding: 0.75rem;
    }
    
    .rule-builder, .rules-list-container {
        padding: 0.75rem;
    }
    
    h1 {
        font-size: 1.375rem;
    }
    
    .logo {
        height: 32px;
        max-width: 180px;
    }
}

/* Additional utility classes for better spacing */
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.mb-5 { margin-bottom: 3rem; }

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.mt-5 { margin-top: 3rem; }
