/* SkillsCharts Mobile Responsive Overrides */

/* ── General layout ── */
@media (max-width: 1024px) {
    /* Prevent horizontal overflow */
    body {
        overflow-x: hidden;
    }

    /* Subheader height: don't fix it on mobile */
    #kt_subheader {
        height: auto !important;
        padding: 8px 15px !important;
    }

    /* Content padding */
    .kt-content {
        padding: 15px 10px !important;
    }

    .kt-container {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }

    /* Page wrapper adjustment for mobile header */
    .kt-wrapper {
        padding-top: 55px !important;
    }
}

/* ── Tables ── */
@media (max-width: 1024px) {
    /* Wrap all dataTable/regular tables in scrollable container */
    .table-responsive,
    .dataTables_wrapper {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    /* Ensure table containers scroll on mobile */
    .kt-portlet__body .table-responsive {
        overflow-x: auto !important;
    }

    /* Make all tables in content area scroll */
    .kt-content table,
    #kt_content table {
        min-width: 600px;
    }

    /* Reduce table row height on mobile */
    table.dataTable tr {
        height: auto !important;
        min-height: 48px;
    }

    table.dataTable td,
    table.dataTable th {
        padding: 8px 6px !important;
        font-size: 12px !important;
    }
}

/* ── Cards / Portlets ── */
@media (max-width: 1024px) {
    .kt-portlet {
        margin-bottom: 10px !important;
    }

    .kt-portlet__head {
        padding: 0 15px !important;
        min-height: 50px !important;
        flex-wrap: wrap;
    }

    .kt-portlet__head-label {
        flex-wrap: wrap;
    }

    .kt-portlet__head-toolbar {
        flex-wrap: wrap;
        gap: 6px;
    }
}

/* ── Filters / Button rows ── */
@media (max-width: 768px) {
    .row.align-items-center {
        flex-wrap: wrap;
    }

    /* Stack filter controls vertically */
    .filter-bar,
    .filters-row {
        flex-direction: column !important;
    }

    /* Full-width buttons on small screens */
    .btn-mobile-full {
        width: 100% !important;
        margin-bottom: 5px;
    }
}

/* ── Forms ── */
@media (max-width: 1024px) {
    .form-group {
        margin-bottom: 8px;
    }

    /* Ensure form inputs don't overflow */
    .form-control,
    .select2-container {
        max-width: 100% !important;
    }

    /* Stack form rows on mobile */
    .form-row > .col,
    .form-row > [class*="col-"] {
        margin-bottom: 8px;
    }
}

/* ── Tabs ── */
@media (max-width: 768px) {
    /* Scroll tabs horizontally instead of wrapping */
    .nav-tabs {
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    .nav-tabs .nav-item {
        flex-shrink: 0;
    }

    .nav-tabs .nav-link {
        white-space: nowrap;
        padding: 8px 12px;
        font-size: 13px;
    }
}

/* ── Dashboard cards ── */
@media (max-width: 768px) {
    .col-md-3,
    .col-md-4,
    .col-md-6 {
        margin-bottom: 10px;
    }
}

/* ── Modals ── */
@media (max-width: 768px) {
    .modal-dialog {
        margin: 10px !important;
        max-width: calc(100vw - 20px) !important;
    }

    .modal-body {
        padding: 15px !important;
    }
}

/* ── Breadcrumb subheader ── */
@media (max-width: 1024px) {
    .kt-subheader__main {
        flex-wrap: wrap;
    }

    .kt-subheader__breadcrumbs-link {
        font-size: 18px !important;
    }

    .kt-subheader__toolbar {
        margin-top: 5px;
    }
}

/* ── Aside / sidebar overlay on mobile ── */
@media (max-width: 1024px) {
    .kt-aside--on .kt-aside-overlay {
        background: rgba(0, 0, 0, 0.3) !important;
        display: block !important;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1000;
    }

    /* Make aside appear on top as overlay */
    .kt-aside--on .kt-aside {
        z-index: 1001;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        height: 100vh !important;
        overflow-y: auto;
    }

    /* Mobile header adjustments */
    .kt-header-mobile {
        padding: 0 10px !important;
    }
}

/* ── Scrollable containers for Kanban/Project views ── */
@media (max-width: 1024px) {
    .kanban-container,
    [class*="kanban"] {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }
}

/* ── Touch-friendly buttons ── */
@media (max-width: 1024px) {
    .btn {
        min-height: 36px;
    }

    /* Action buttons in tables */
    .btn.btn-icon {
        height: 36px !important;
        width: 36px !important;
    }
}

/* ── Login page mobile ── */
@media (max-width: 768px) {
    /* Hide aside panel on login on very small screens */
    .kt-login__aside {
        display: none !important;
    }

    .kt-login__wrapper {
        width: 100% !important;
        padding: 20px !important;
    }

    .kt-login__form {
        max-width: 100% !important;
        padding: 0 10px !important;
    }
}

/* ── DataTable search + length controls ── */
@media (max-width: 768px) {
    #clients-table_wrapper,
    [id$="-table_wrapper"] {
        flex-direction: column;
    }

    .dataTables_filter,
    .dataTables_length {
        width: 100%;
        text-align: left !important;
    }

    .dataTables_filter input {
        width: 100% !important;
        max-width: 100% !important;
    }

    #table_pagination_container {
        flex-direction: column;
        gap: 8px;
    }
}

/* ── Users / People cards ── */
@media (max-width: 768px) {
    .kt-widget.kt-widget--user-profile-1 .kt-widget__head {
        flex-direction: column;
        align-items: center;
    }
}

/* ── Buildings / Assets map/grid ── */
@media (max-width: 768px) {
    .floor-full-image {
        width: 100% !important;
        height: auto !important;
    }
}

/* ── Fix .d-grid on mobile ── */
@media (max-width: 768px) {
    .d-grid.grid-columns-2 {
        grid-template-columns: 1fr !important;
    }
}

/* ── Subheader action buttons ── */
@media (max-width: 768px) {
    .kt-subheader__toolbar .btn {
        padding: 6px 12px !important;
        font-size: 12px !important;
    }
}
