/* TDX Project Mobile Responsiveness Overrides */

/* Custom Bootstrap 5 touch target minimum sizes and spacing for mobile devices */
@media (max-width: 768px) {
    /* Touch target optimizations: minimum 44x44px for interaction elements */
    .btn, 
    button, 
    input[type="button"], 
    input[type="submit"], 
    input[type="text"], 
    input[type="password"], 
    input[type="email"], 
    input[type="number"], 
    select, 
    textarea,
    .kt-menu__link,
    .nav-link,
    .dropdown-item,
    a.btn {
        min-height: 44px !important;
        /* Padding adjustments for better touch areas without breaking layout */
        padding-top: 10px !important;
        padding-bottom: 10px !important;
    }

    /* Force all form controls inside input-groups to flex stretch to the same height */
    .input-group {
        align-items: stretch !important;
    }
    .input-group > .form-control {
        height: auto !important;
        min-height: 44px !important;
    }

    /* Revert touch targets for login screen to avoid breaking its unique enormous pill style */
    .kt-login .form-control,
    .kt-login .btn {
        min-height: 60px !important;
        border-radius: 60px !important;
        padding-top: 0 !important;
        padding-bottom: 0 !important;
    }

    /* Allow compact notification dropdown buttons to stay on one row */
    .kt-notification__custom .btn {
        min-height: unset !important;
        padding-top: 5px !important;
        padding-bottom: 5px !important;
    }

    /* Table text minimum 14px */
    table, 
    .table td, 
    .table th,
    .dataTables_wrapper .dataTables_paginate .paginate_button {
        font-size: 14px !important;
    }

    /* Prevent body horizontal scroll */
    body {
        overflow-x: hidden !important;
    }

    /* Ensure modals and dialogs fit */
    .modal-dialog {
        margin: .5rem;
        width: auto !important;
        max-width: 100% !important;
    }
    
    /* Enhance visibility of sticky actions on mobile */
    .kt-sticky-toolbar {
        right: 10px !important;
    }

    /* Force DataTables filters to be left/right side-by-side on mobile instead of stacked/centered */
    div.dataTables_wrapper div.dataTables_length {
        text-align: left !important;
    }
    div.dataTables_wrapper div.dataTables_filter {
        text-align: right !important;
    }
    .dataTables_wrapper > .row:first-child {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        justify-content: space-between !important;
        align-items: center !important;
    }
    .dataTables_wrapper > .row:first-child > div {
        width: auto !important;
        flex: 0 0 auto !important;
        max-width: 50% !important;
        padding: 0 5px !important;
    }
    .dataTables_wrapper div.dataTables_filter input {
        width: 100px !important; /* Prevent search input from overflowing if it's too wide */
    }
}

/* Base table adjustments to ensure they scroll properly horizontally */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch; /* Smoother scrolling on iOS */
    width: 100%;
    margin-bottom: 1rem;
}

/* Ensure data tables width is respected */
/* Ensure data tables width is respected on mobile/tablet screens */
@media (max-width: 1024px) {
    .dataTables_wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .dataTables_wrapper .table-responsive > .table,
    .dataTables_wrapper > table.dataTable {
        min-width: 600px; /* Force scroll if columns are too many */
    }
}

/* Any additional overrides needed for the old theme to look like Bootstrap 5 */
.btn {
    border-radius: 0.25rem; /* Bootstrap 5 default rounding, instead of fully pill sometimes */
}

/* -----------------------------------------
   5) MOBILE BOTTOM NAVIGATION & MEGA MENU
----------------------------------------- */
@media (max-width: 991.98px) {
    body {
        /* Add padding to body so the bottom nav doesn't hide content */
        padding-bottom: 52px !important;
    }

    .tdx-bottom-navbar {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        background-color: #ffffff;
        border-top: 1px solid #f0f3ff;
        box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.05);
        border-radius: 20px 20px 0 0;
        display: flex;
        justify-content: flex-start;
        align-items: stretch;
        z-index: 1000;
        padding: 6px 12px 12px 12px;
        padding-top: 18px; /* room for the toggle handle pill */
        transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
        overflow-x: auto;
        overflow-y: visible;
        flex-wrap: nowrap;
        gap: 10px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none; /* Firefox */
    }
    
    .tdx-bottom-navbar::-webkit-scrollbar {
        display: none; /* Safari and Chrome */
    }
    
    /* Hide: slide down leaving only the handle pill visible */
    .tdx-bottom-navbar.tdx-nav-hidden {
        transform: translateY(calc(100% - 22px));
    }

    /* Handle pill — centred at the very top of the navbar */
    .tdx-navbar-toggle-handle {
        position: absolute;
        top: 7px;
        left: 50%;
        transform: translateX(-50%);
        width: 44px;
        height: 5px;
        background: #ced4da;
        border-radius: 3px;
        cursor: pointer;
        z-index: 1002;
        transition: background 0.2s, width 0.2s;
        flex-shrink: 0;
    }
    .tdx-navbar-toggle-handle:hover,
    .tdx-navbar-toggle-handle:active {
        background: #adb5bd;
        width: 52px;
    }

    /* Hide the default desktop topbar on mobile */
    .kt-header__topbar {
        display: none !important;
    }

    /* Keep the pen circular icon intact inside widget containers */
    .btn.btn-icon.btn-circle {
        border-radius: 50% !important;
        aspect-ratio: 1/1 !important;
    }
    
    .tdx-bottom-navbar .nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: space-between; /* icon top, text bottom */
        text-decoration: none;
        color: #434349;
        font-weight: 500;
        transition: transform 0.2s ease;
        flex: 0 0 auto;
        min-width: 55px;
        max-width: 75px;
        min-height: 62px; /* keeps all items the same height */
    }
    
    .tdx-bottom-navbar .nav-item:active {
        transform: scale(0.92);
    }
    
    .tdx-bottom-navbar .nav-icon-wrapper {
        width: 43px;
        height: 43px;
        border-radius: 11px;
        display: flex;
        align-items: center;
        justify-content: center;
        margin-bottom: 0;
        overflow: hidden;
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
        flex-shrink: 0;
    }
    
    .tdx-bottom-navbar .nav-icon-wrapper i {
        font-size: 19px;
    }
    
    .tdx-bottom-navbar .nav-text {
        font-size: 10px;
        letter-spacing: 0.2px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        text-align: center;
        line-height: 1.2;
        width: 100%;
        max-width: 70px;
        margin-top: auto; /* push text to bottom */
    }
    
    /* --- Right Quick Action Drawer --- */
    .tdx-quick-drawer {
        position: fixed;
        right: 0;
        top: 50%;
        transform: translateY(-50%) translateX(calc(100% - 10px));
        background: #ffffff;
        border-radius: 15px 0 0 15px;
        box-shadow: -3px 0 15px rgba(0,0,0,0.06);
        display: flex;
        align-items: stretch;
        z-index: 999;
        transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    }
    
    .tdx-quick-drawer.active {
        transform: translateY(-50%) translateX(0);
    }
    
    .tdx-quick-drawer-handle {
        width: 14px;
        background: #f4f6f9;
        border-radius: 15px 0 0 15px;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        border-left: 1px solid #ebedf2;
    }
    
    .tdx-quick-drawer-handle::before {
        content: '';
        width: 4px;
        height: 35px;
        background: #ced4da;
        border-radius: 2px;
    }
    
    .tdx-quick-drawer-content {
        padding: 15px 12px;
        display: flex;
        flex-direction: column;
        align-items: center;
    }
    
    .tdx-quick-drawer-content .btn-icon {
        width: 42px !important;
        height: 42px !important;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .tdx-quick-drawer-content .btn-icon i {
        font-size: 20px;
    }

    /* Bottom Sheet Modal Styles */
    .tdx-bottom-sheet.modal.fade .modal-dialog {
        transform: translate(0, 100%);
        transition: transform 0.3s ease-out;
        margin: 0;
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-width: 100%;
    }
    .tdx-bottom-sheet.modal.show .modal-dialog {
        transform: translate(0, 0);
    }
    .tdx-bottom-sheet .modal-content {
        border-radius: 20px 20px 0 0;
        border: none;
        max-height: 85vh;
        height: auto;
    }
    .tdx-bottom-sheet .modal-body {
        overflow-y: auto;
        max-height: calc(85vh - 60px);
    }

    /* Mobile Accordion overrides */
    .tdx-mobile-accordion .card {
        border: none;
        border-bottom: 1px solid #f0f0f0;
        border-radius: 0;
    }
    .tdx-mobile-accordion .card-header {
        background: #fff;
        padding: 0;
        border-bottom: none;
    }
    .tdx-mobile-accordion .btn-link {
        width: 100%;
        text-align: left;
        color: #48465b;
        font-weight: 600;
        font-size: 15px;
        padding: 16px 20px;
        text-decoration: none;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    .tdx-mobile-accordion .btn-link:focus, .tdx-mobile-accordion .btn-link:hover {
        text-decoration: none;
        background-color: #fcfcfc;
    }
    .tdx-mobile-accordion .card-body {
        padding: 0 0 10px 20px;
        background-color: #fbfbfb;
    }
    
    /* Hide top header menu wrapper entirely on mobile to enforce new UI */
    #kt_header_menu_wrapper {
        display: none !important;
    }
}

/* Subheader / Tabs / 'Bugün' Alignments and Dashboard Card Spacing on Mobile */
@media (max-width: 1024px) {
    /* Force subheader to align items in a row instead of stacking */
    .kt-subheader {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        flex-wrap: nowrap !important;
        justify-content: space-between !important;
        padding-top: 5px !important;
        padding-bottom: 5px !important;
    }

    /* Reduce padding of portlet body wrapping the nav tabs inside subheader */
    .kt-subheader .kt-portlet__body {
        padding: 2px 0 !important;
    }

    /* Shrink the tab nav links height */
    .kt-subheader .nav-link {
        padding: 5px 10px !important;
        min-height: unset !important;
        font-size: 13px !important;
        line-height: 1.4 !important;
    }

    /* Remove extra bottom margin on tab list */
    .kt-subheader .nav-tabs {
        margin-bottom: 0 !important;
    }

    /* Reduce portlet head (İşlemler bar) height */
    .kt-portlet__head {
        min-height: 46px !important;
        padding-top: 4px !important;
        padding-bottom: 4px !important;
    }

    .kt-portlet__head-title {
        font-size: 14px !important;
    }
    /* Let the tabs container take available space and scroll horizontally if needed */
    .kt-subheader__main {
        flex: 1 1 auto;
        width: auto !important;
        overflow-x: auto;
        white-space: nowrap;
        margin-right: 10px;
    }
    .kt-subheader__main::-webkit-scrollbar {
        height: 0px; 
        background: transparent; /* hide scrollbar on mobile tabs */
    }
    /* Stop the toolbar from wrapping */
    .kt-subheader__toolbar {
        flex: 0 0 auto;
        width: auto !important;
        margin-top: 0 !important;
        padding-top: 0 !important;
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
    }
    .kt-subheader__wrapper {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: flex-end !important;
        gap: 5px;
        flex-wrap: nowrap !important;
    }
    
    /* Completely hide the Date range picker button (16 Mart) to save space */
    #kt_dashboard_daterangepicker {
        display: none !important;
    }
    
    /* Shrink the pencil/edit button slightly */
    .btn.btn-circle.btn-icon, .kt-subheader__toolbar .btn.btn-icon {
        width: 32px !important;
        height: 32px !important;
        min-height: 32px !important;
        padding: 0 !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    /* Reduce vertical gaps between Dashboard cards / Portlets heavily */
    .kt-portlet {
        margin-bottom: 3px !important;
    }
    .kt-widget14 {
        padding: 10px !important;
    }

    /* Override hardcoded inline heights (e.g. 350px) on widget column containers */
    div[class*="col-"][style*="height: 350px"],
    div[class*="col-"][style*="height:350px"] {
        height: auto !important;
        min-height: unset !important;
    }
    .kt-portlet--height-fluid {
        height: auto !important;
    }
}

/* -------------------------------------------------------
   Me.php subheader tab buttons — force single row, compact
   High-specificity rule overrides the global 44px touch target
------------------------------------------------------- */
ul.tdx-me-tabs {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    gap: 2px !important;
    margin: 0 !important;
    padding: 0 !important;
    border-bottom: none !important;
}

ul.tdx-me-tabs > li.nav-item {
    flex-shrink: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
}

ul.tdx-me-tabs > li.nav-item > button.tdx-me-tab-btn.nav-link {
    min-height: unset !important;
    height: auto !important;
    padding: 6px 10px !important;
    font-size: 13px !important;
    line-height: 1.3 !important;
    white-space: nowrap !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 4px !important;
}
