﻿
/* Tablet adjustments */
@media (max-width: 991px) {
    /* Auto-collapse sidebar on tablet */
    .sidebar {
        width: 230px;
    }

        .sidebar .nav-text {
            display: none;
        }

        .sidebar .sidebar-logo {
            display: none;
        }

        .sidebar .sidebar-logo-icon {
            display: block;
        }

    .main-content {
        margin-left: 70px;
    }

    .dashboard-header {
        width: calc(100% - 70px);
    }
}

/* Mobile adjustments */
@media (max-width: 767px) {
    /* Mobile sidebar becomes overlay */
    .sidebar {
        width: 230px;
        transform: translateX(-100%);
        z-index: 1050;
    }

        .sidebar.mobile-visible {
            width: 230px;
            transform: translateX(0);
            box-shadow: 0 0 15px rgba(0, 0, 0, 0.15);
        }

            .sidebar.mobile-visible .nav-text {
                display: inline-block;
            }

            .sidebar.mobile-visible .sidebar-logo {
                display: block;
            }

            .sidebar.mobile-visible .sidebar-logo-icon {
                display: none;
            }

    .main-content {
        margin-left: 0;
    }

    .dashboard-header {
        width: 100%;
    }

    /* Sidebar overlay background */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1040;
    }

        .sidebar-overlay.active {
            display: block;
        }
    .chartView .d-flex.align-items-center.gap-3 {
        flex-wrap: wrap;
    }
}

@media (max-width: 991px) {
    .dashboard-header {
        padding: 12px 20px;
    }

    .dashboard-title {
        font-size: 16px;
        padding-right: 10px;
    }
}

@media (max-width: 767px) {
    .dashboard-header .d-flex.justify-content-between {
        flex-wrap: wrap;
    }

    .dashboard-header .d-flex.align-items-center {
        gap: 8px !important;
    }

    .dashboard-title {
        border-right: none;
        padding-right: 0;
        margin-right: 5px;
        display:none
    }
    .px-4 {
        padding-right: 1rem !important;
        padding-left: 1rem !important;
    }
    .topBarcheck {
        margin-left: auto;
    }

    .dashboard-header .d-flex.align-items-center.gap-4 {
        justify-content: flex-end;
    }

    .dashboard-header .text-muted {
        font-size: 11px;
    }
}

@media (max-width: 480px) {
    .dashboard-header {
        padding: 10px 15px;
    }

        .dashboard-header .text-muted {
            display: none;
        }

    .topBarcheck .form-check {
        padding-left: 2.5em;
    }

    .topBarcheck .form-check-label {
        font-size: 12px;
    }
}

/* ======= Main Content Area Responsive Styles - FIXED ======= */
.main-content .p-4 {
    padding-top: 80px !important; /* Space for fixed header */
}

@media (max-width: 991px) {
    .main-content .p-4 {
        padding: 70px 15px 15px !important;
    }
}

@media (max-width: 767px) {
    .main-content .p-4 {
        padding: 70px 12px 12px !important;
    }

    /* Adjust spacing for mobile */
    .card-wrap, .status-card-wrap, .chart-card, .filters-section {
        margin-bottom: 15px;
        padding: 15px;
    }
}

@media (max-width: 480px) {
    .main-content .p-4 {
        padding: 65px 10px 10px !important;
    }

    /* Further reduce padding on very small screens */
    .card-wrap, .status-card-wrap, .chart-card, .filters-section {
        padding: 12px;
    }
}

/* ======= Status Cards Responsive Grid ======= */
.status-cards-container {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 16px;
}

@media (max-width: 1199px) {
    .status-cards-container {
        grid-template-columns: repeat(3, 1fr);
        gap: 15px;
    }

    .status-card.approved-rejected {
        grid-column: span 3;
    }
}

@media (max-width: 991px) {
    .status-cards-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .status-card.approved-rejected {
        grid-column: span 2;
    }
}

@media (max-width: 767px) {
    /* Keep 2 columns on regular mobile */
    .status-cards-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .status-title h6 {
        font-size: 14px;
    }

    .status-subtitle {
        font-size: 12px;
    }

    .status-card {
        padding: 12px;
    }

    .metric-value {
        font-size: 16px;
    }

    .metric-label {
        font-size: 11px;
    }
}

@media (max-width: 480px) {
    /* Stack cards on small mobile */
    .status-cards-container {
        grid-template-columns: 1fr;
    }

    .status-card.approved-rejected {
        grid-column: span 1;
    }

    /* Adjust metrics to show side by side on small screens */
    .metrics-container {
        display: flex;
        justify-content: space-around;
    }
}

/* ======= Chart Responsiveness ======= */
.chart-container {
    position: relative;
    height: 350px;
    width: 100%;
}

@media (max-width: 991px) {
    .chart-container {
        height: 300px;
    }

    .chart-title {
        font-size: 15px;
        margin-bottom: 15px;
    }
}

@media (max-width: 767px) {
    .chart-container {
        height: 250px;
    }

    .chart-title {
        font-size: 14px;
        margin-bottom: 12px;
    }

    /* Make legends more compact */
    .legend-item {
        margin-bottom: 5px !important;
    }

    .legend-color {
        width: 10px !important;
        height: 10px !important;
    }

    .legend-item span {
        font-size: 11px;
    }
}

/* ======= Filters Section Responsive ======= */
@media (max-width: 991px) {
    .filters-section {
        gap: 10px;
    }

    .filters-label {
        font-size: 13px;
    }

    .form-select, .date-input {
        min-width: 150px;
    }
}

@media (max-width: 767px) {
    .filters-section {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

        .filters-section .form-select,
        .filters-section .date-input,
        .filters-section .generate-btn {
            width: 100%;
            min-width: 0;
        }

    .generate-btn {
        margin-top: 5px;
        padding: 8px 12px;
    }

    /* Reset width of SumoSelect */
    .SumoSelect {
        width: 100% !important;
    }

        .SumoSelect > .CaptionCont {
            width: 100% !important;
        }
}

/* ======= Table Responsive Styles ======= */
/* Responsive table wrapper */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 15px;
}

@media (max-width: 991px) {
    .table > :not(caption) > * > *,
    table.dataTable thead th,
    table.dataTable thead td,
    table.dataTable tbody th,
    table.dataTable tbody td {
        padding: 12px;
    }

    div#queTrackerPendingNBFC_info {
        font-size: 11px;
    }

    .dataTables_wrapper .dataTables_paginate .paginate_button {
        padding: 0.3em 0.7em;
    }
}

@media (max-width: 767px) {
    /* Card view for tables on mobile */
    table.dataTable.responsive-card thead {
        display: none;
    }

    table.dataTable.responsive-card tbody tr {
        display: block;
        margin-bottom: 15px;
        border: 1px solid #e5e7eb;
        border-radius: 8px;
        box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    }

    table.dataTable.responsive-card tbody td {
        display: flex;
        padding: 10px 15px !important;
        border: none;
        border-bottom: 1px solid #f0f0f0;
        text-align: left !important;
        min-height: 42px;
        align-items: center;
    }

        table.dataTable.responsive-card tbody td:last-child {
            border-bottom: none;
        }

        table.dataTable.responsive-card tbody td:before {
            content: attr(data-title);
            font-weight: 600;
            color: #00194c;
            width: 40%;
            margin-right: 10px;
        }

    /* Ensure buttons and status boxes are properly sized for touch */
    table.dataTable.responsive-card .status-box,
    table.dataTable.responsive-card .btn-icon {
        margin: 2px;
        padding: 8px 12px;
    }

    /* Adjust action buttons container */
    table.dataTable.responsive-card td:last-child {
        display: flex;
        flex-wrap: wrap;
        justify-content: flex-start;
        gap: 8px;
    }

    /* Table controls on mobile */
    .table-controls {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        padding: 12px;
    }

        .search-container, .table-controls .search-box {
            width: 100% !important;
        }

    .export-dropdown {
        width: 100%;
    }

        .export-dropdown button {
            width: 100%;
            text-align: left;
            justify-content: space-between;
            display: flex;
            align-items: center;
        }

    /* Pagination controls */
    .dataTables_wrapper .dataTables_paginate,
    .dataTables_wrapper .dataTables_info {
        text-align: center;
        float: none !important;
        width: 100%;
    }

    .dataTables_wrapper .dataTables_paginate {
        margin-top: 10px;
    }

        .dataTables_wrapper .dataTables_paginate .paginate_button {
            padding: 0.25em 0.5em;
            font-size: 11px;
        }
}

/* ======= Form Element Responsive Styles ======= */
@media (max-width: 767px) {
    /* Make form controls larger for touch */
    .form-control, .form-select, .date-input,
    .btn, .SumoSelect > .CaptionCont,
    input.dateRangePicker.flatpickr-input {
        min-height: 38px;
        font-size: 13px;
    }

    /* Remove fixed width constraints */
    .form-control, .form-select, .date-input, .btn {
        width: 100%;
        min-width: 0 !important;
    }

    /* Improve form layout on mobile */
    .form-group {
        margin-bottom: 15px;
    }

    label {
        margin-bottom: 5px;
        display: block;
    }
}

/* ======= Responsive Tab Navigation ======= */
@media (max-width: 767px) {
    .nav-tabs, .orange-tabs, #businessInfoTabs, #pills-QueryApplications {
        display: flex;
        overflow-x: auto;
        white-space: nowrap;
        padding-bottom: 5px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none; /* Firefox */
        -ms-overflow-style: none; /* IE and Edge */
    }

        .nav-tabs::-webkit-scrollbar,
        .orange-tabs::-webkit-scrollbar,
        #businessInfoTabs::-webkit-scrollbar,
        #pills-QueryApplications::-webkit-scrollbar {
            display: none; /* Chrome, Safari, Opera */
        }

        .nav-tabs .nav-link,
        .orange-tabs .nav-link,
        #businessInfoTabs .nav-link,
        #pills-QueryApplications .nav-link {
            flex: 0 0 auto;
            padding: 8px 15px;
            font-size: 13px;
        }

    /* Ensure proper spacing in tab content */
    .tab-content > .tab-pane {
        padding: 15px 0;
    }
}

/* ======= POS Section Responsive Styles ======= */
@media (max-width: 767px) {
    .pos-section {
        flex-direction: column;
    }

    .pos-col {
        flex: 1;
        padding: 12px 0;
        border-right: 0;
        border-bottom: 1px solid #f0f0f0;
    }

        .pos-col:last-child {
            border-bottom: none;
        }

    .pos-label {
        margin-bottom: 5px;
    }
}

/* ======= Document Section Responsive ======= */
@media (max-width: 767px) {
    .document-search-bar {
        flex-direction: column;
        align-items: flex-start;
    }

        .document-search-bar .search-container {
            width: 100%;
            margin-bottom: 10px;
        }

    .document-item {
        flex-direction: column;
        align-items: flex-start;
    }

        .document-item .d-flex {
            margin-top: 10px;
            width: 100%;
            justify-content: flex-start;
            gap: 10px;
        }

        /* Make buttons more tappable */
        .document-item .btn-icon {
            padding: 8px;
            margin-right: 5px;
        }

    /* Accordion headers */
    .accordion-button {
        padding: 12px;
    }
}

/* ======= Tracker Steps Responsive ======= */
@media (max-width: 991px) {
    .tracker-steps {
        min-width: auto;
    }

    .step {
        padding: 25px;
    }

    .step-label {
        font-size: 11px;
    }
}

@media (max-width: 767px) {
    .step {
        padding: 20px;
    }

    .step-dot {
        width: 16px;
        height: 16px;
    }

        .step-dot.active::after {
            width: 18px;
            height: 18px;
            top: -5.5px;
            left: -5.5px;
        }

    .tracker-title {
        font-size: 14px;
    }

    .nav-button {
        width: 28px;
        height: 28px;
    }
}

/* ======= Audit Trail Table Responsive ======= */
@media (max-width: 767px) {
    .audit-table th, .audit-table td {
        padding: 8px;
        font-size: 12px;
    }

    .audit-title {
        font-size: 14px;
    }
}

/* ======= Modal Responsive Styles ======= */
@media (max-width: 991px) {
    .modal-dialog {
        max-width: 90%;
        margin: 10px auto;
    }
}

@media (max-width: 767px) {
    .modal-dialog {
        max-width: 95%;
        margin: 10px auto;
    }

    .modal-title {
        font-size: 16px;
    }

    .modal-body {
        padding: 15px;
        max-height: 60vh;
        overflow-y: auto;
    }

    .modal-footer {
        padding: 10px 15px;
        flex-wrap: wrap;
        justify-content: center;
    }

        .modal-footer .btn {
            margin: 5px;
            min-width: 100px;
        }

    /* Upload modal */
    .file-upload-action {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    /* Custom modal wrapper from your code */
    .modal-wrapper {
        width: 90% !important;
        padding: 15px;
    }
}

/* ======= Context Menu Responsive ======= */
@media (max-width: 767px) {
    .context-menu {
        width: 200px;
    }

    .menu-item {
        padding: 12px 15px;
    }
}

/* ======= Reports Page Responsive ======= */
@media (max-width: 991px) {
    .report-card {
        margin-bottom: 15px;
    }

    .report-info h5 {
        font-size: 13px;
    }
}

@media (max-width: 767px) {
    #viewDropdown {
        width: 100%;
        text-align: left;
        margin-bottom: 10px;
    }

    .sample-btn {
        width: 100%;
        justify-content: center;
        margin-top: 10px;
    }

    .report-icon {
        width: 40px;
        height: 40px;
    }
}

/* ======= Create Applications Responsive ======= */
@media (max-width: 767px) {
    .createApplications .card-body {
        padding: 1.5rem;
    }

    .createApplications .icon-container {
        width: 50px;
        height: 50px;
        margin-bottom: 1rem;
    }

    .createApplications .card-title {
        font-size: 14px;
    }

    .divider {
        width: 100%;
        height: 1px;
        margin: 15px 0;
    }
}

/* ======= Pool Buyout Responsive ======= */
@media (max-width: 767px) {
    .status-number {
        font-size: 2rem;
    }

    .status-text {
        font-size: 0.85rem;
    }

    .icon-circle {
        width: 35px;
        height: 35px;
    }
}

/* ======= Status Boxes Responsive ======= */
@media (max-width: 767px) {
    .status-box {
        padding: 8px 12px;
        margin: 3px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
}

/* ======= Toast Notification Responsive ======= */
@media (max-width: 767px) {
    .toast {
        max-width: 90%;
        left: 5%;
        right: 5%;
    }
}

/* ======= Enhance Print Styles ======= */
@media print {
    .sidebar, .dashboard-header, .filters-section,
    .btn, button, .noprint, .table-controls {
        display: none !important;
    }

    .main-content {
        margin-left: 0 !important;
        padding: 0 !important;
    }

    .card-wrap, .status-card-wrap, .chart-card {
        border: 1px solid #ddd;
        box-shadow: none !important;
        break-inside: avoid;
    }

    body {
        font-size: 12pt;
        background: white !important;
        color: black !important;
    }

    a {
        text-decoration: none !important;
        color: #000 !important;
    }

    table {
        width: 100% !important;
        page-break-inside: auto;
    }

    tr {
        page-break-inside: avoid;
        page-break-after: auto;
    }

    thead {
        display: table-header-group;
    }

    tfoot {
        display: table-footer-group;
    }
}

/* ======= Redirect Progress Bar ======= */
.redirect-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 4px;
    background: #ff8500;
    width: 0%;
    transition: width 3s linear;
}

/* ======= Loading Indicator ======= */
.loading-indicator {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 15px 20px;
    border-radius: 5px;
    z-index: 9999;
    font-size: 14px;
}

/* ======= Fix for SumoSelect on Mobile ======= */
@media (max-width: 767px) {
    /* Make dropdown wider on mobile */
    .SumoSelect > .optWrapper {
        width: 100%;
        max-width: 100vw;
        left: 0;
    }

        /* Increase option height for better touch */
        .SumoSelect > .optWrapper > .options li.opt {
            padding: 12px 10px;
        }

    /* Make select all more tappable */
    .SumoSelect .select-all {
        padding: 12px 10px 12px 35px;
        height: auto;
    }
}

/* ======= Flatpickr Calendar Mobile Optimizations ======= */
@media (max-width: 767px) {
    .flatpickr-calendar {
        width: 100% !important;
        max-width: 307px;
    }

    .flatpickr-days {
        width: 100% !important;
    }

    .dayContainer {
        width: 100% !important;
        min-width: 0 !important;
    }

    .flatpickr-day {
        max-width: 40px;
        height: 40px;
        line-height: 40px;
    }
}

/* ======= Status Icons And Colors on Mobile ======= */
@media (max-width: 767px) {
    .status-icon {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
}

/* ======= Fix for fixed position elements on iOS ======= */
@supports (-webkit-overflow-scrolling: touch) {
    .sidebar, .dashboard-header, .sidebar-overlay,
    .toast, .loading-indicator {
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }
}

/* ======= Animation Optimizations for Mobile ======= */
@media (max-width: 767px) {
    /* Reduce or disable animations on mobile for better performance */
    .sidebar, .main-content, .dashboard-header,
    .status-card:hover, .report-card:hover,
    .btn:hover, .nav-link:hover {
        transition-duration: 0.2s;
    }

        /* Use transform for animations where possible */
        .sidebar.mobile-visible {
            transform: translateX(0);
        }
}

/* ======= Fix for notched displays (iPhone X and newer) ======= */
@media (max-width: 767px) {
    @supports (padding-top: env(safe-area-inset-top)) {
        .dashboard-header {
            padding-top: calc(12px + env(safe-area-inset-top));
            padding-left: calc(15px + env(safe-area-inset-left));
            padding-right: calc(15px + env(safe-area-inset-right));
        }

        .sidebar {
            padding-top: env(safe-area-inset-top);
            padding-left: env(safe-area-inset-left);
            min-height: calc(100vh - env(safe-area-inset-bottom));
        }

        .main-content .p-4 {
            padding-bottom: calc(15px + env(safe-area-inset-bottom)) !important;
        }
    }
}
