/* Global Scrolling Fixes for WordWorks AI Lead Engine */

/* Fix main content area scrolling */
.main-content-scrollable {
    height: calc(100vh - 200px) !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    position: relative !important;
}

/* Force scrolling for flex containers */
.flex-1.main-content-scrollable {
    flex: 1 1 auto !important;
    min-height: 0 !important;
}

/* Mobile responsive fixes */
@media (max-width: 768px) {

    /* Fix main content containers */
    .flex-1 {
        height: auto !important;
        max-height: calc(100vh - 150px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Fix table containers */
    .mobile-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: calc(100vw - 40px);
    }

    /* Fix sidebar overlay issues */
    .sidebar {
        z-index: 1050;
    }

    /* Ensure body doesn't scroll when content should */
    body {
        overflow-x: hidden;
    }

    /* Fix modal scrolling */
    .modal-body {
        max-height: 60vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* Tablet fixes */
@media (min-width: 769px) and (max-width: 1024px) {
    .main-content-scrollable {
        height: calc(100vh - 180px);
    }
}

/* Desktop fixes */
@media (min-width: 1025px) {
    .main-content-scrollable {
        height: calc(100vh - 200px);
    }
}

/* Table specific fixes */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-responsive table {
    min-width: 800px;
}

/* Chart container fixes */
.chart-container {
    position: relative;
    height: 300px;
    overflow: hidden;
}

/* Fix for analytics charts */
.analytics-chart {
    max-height: 400px;
    overflow: hidden;
}

/* Admin panel specific fixes */
.admin-content {
    max-height: calc(100vh - 220px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Contact page specific fixes */
.contacts-table-wrapper {
    max-height: calc(100vh - 300px) !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
}

/* Force table container scrolling */
.mobile-table-container {
    overflow: auto !important;
    -webkit-overflow-scrolling: touch !important;
}

/* Ensure table wrapper has proper height */
.contacts-table-wrapper.mobile-table-container {
    height: calc(100vh - 350px) !important;
    overflow-y: auto !important;
}

/* Ensure buttons remain clickable */
.btn,
.button {
    position: relative;
    z-index: 1;
}

/* Fix for dropdown menus */
.dropdown-menu {
    max-height: 300px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Smooth scrolling for all elements */
* {
    scroll-behavior: smooth;
}

/* Fix for iOS Safari bounce scrolling */
html,
body {
    height: 100%;
    overflow-x: hidden;
}

/* Prevent horizontal scrolling issues */
.container-fluid,
.container {
    overflow-x: hidden;
}

/* Fi
nal override for all scrollable areas */
.main-content-scrollable,
.flex-1.main-content-scrollable,
.mobile-table-container,
.contacts-table-wrapper,
.admin-content {
    height: calc(100vh - 200px) !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    position: relative !important;
}

/* Mobile final override */
@media (max-width: 768px) {

    .main-content-scrollable,
    .flex-1.main-content-scrollable {
        height: calc(100vh - 150px) !important;
    }

    .mobile-table-container,
    .contacts-table-wrapper {
        height: calc(100vh - 250px) !important;
    }
}

/* Ensure tables are scrollable */
table {
    width: 100% !important;
    table-layout: fixed !important;
}