﻿/*
    TotalFinance2026.Core.CSS
    Author: Wilson TS Teo
    Date Created: 2025-08-01
    Update History:
    -2025-08-01 Wilson Teo Initial creation 
    -2025-08-24 Wilson Teo add Media control  
*/

/*BEGIN: Redefine Page Body
    We want to prevent scrolling on the body and ensure it takes the full height of the viewport
*/
:root {
    /*Some default variables are from KTTheme*/
    --bs-body-line-height: 1 !important;
    --bs-app-sidebar-width: 0px !important; 
    --font-size-base: 12px;
    --grid-offset-300: 300px;
    --grid-offset-350: 350px;
    --grid-line-height: 14px;
    --bs-font-sans-serif: Inter, Helvetica, "sans-serif"; /* unicode fonts, default: "Inter" */
    --bs-app-header-height: 50px !important;
    --bs-app-toolbar-height: 60px !important;
    --bs-app-footer-height: 50px;
}

html, body {
    height: 100%;
    margin: 0px;
    padding: 0px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-size: var(--font-size-base) !important;
    font-family: var(--bs-font-sans-serif) !important; /* unicode fonts, default: "Inter" */
    font-weight: 400;
    font-family: Inter, Helvetica, "sans-serif";
}
/*END: Redefine Page Body*/
.auth-logo-tbssb {
    height: 70px !important; /* adjust as needed */
    width: 80px !important;
    filter: drop-shadow(0 0 2px rgba(255,255,255,.9)) drop-shadow(0 0 8px rgba(255,255,255,.7));
}
/* BEGIN: Customize Syncfusion Grid */
.e-grid .e-rowcell {
    border-style: solid;
    border-width: 1px 0 0;
    display: table-cell;
    font-size: var(--font-size-base);
    font-family: var(--bs-font-sans-serif) !important;
    line-height: var(--grid-line-height) !important;
    padding: 6px 8px;
    overflow: hidden;
    vertical-align: middle;
    white-space: nowrap;
    width: auto;
}

/* Prevent aggressive wrapping in header cells; keep them compact */
.e-grid .e-headercell, .e-grid .e-headercelldiv {
    white-space: nowrap !important;
}

.e-grid {
    font-family: var(--bs-font-sans-serif) !important;
    font-size: var(--font-size-base) !important;
    overflow-x: auto; /* enable horizontal scroll when total columns exceed viewport */
}

    /* Header cells */
    .e-grid .e-headercelldiv {
        font-family: var(--bs-font-sans-serif) !important;
        font-size: var(--font-size-base) !important;
        font-style: italic;
        font-weight: 700;
    }

    .e-grid .e-headercell {
        font-family: var(--bs-font-sans-serif) !important;
        background-color: #f8f9fa !important; /* Light gray */
        color: #000000 !important; /* Optional: black text */
    }

    /*Grid cells*/
    .e-grid .e-rowcell {
        font-family: var(--bs-font-sans-serif) !important;
        font-size: var(--font-size-base) !important;
    }

/*Grid pager*/
.e-gridfooter, .e-pager {
    font-family: var(--bs-font-sans-serif) !important;
    font-size: var(--font-size-base) !important;
}

/*Grid Toolbar*/
.e-toolbar .e-toolbar-items {
    background: #f8f9fa;
}
.e-toolbar .e-toolbar-item .e-tbar-btn .e-tbar-btn-text {
    font-size: var(--font-size-base) !important;
    font-style: italic;
    padding: 4px;
}
.e-toolbar .e-toolbar-item .e-tbar-btn .e-icons.e-btn-icon {
    margin: 0;
    min-width: 12px;
    width: auto;
    font-size: var(--font-size-base) !important;
    line-height: 10px !important;
}
/*  END: Customize Syncfusion Grid*/

/* BEGIN: control like Grid Toolbar's buttons*/
.e-control, .e-css, .e-error {
    font-family: var(--bs-font-sans-serif) !important;
    font-size: var(--font-size-base) !important;
    font-weight: 400;
}
/* END: control like buttons*/

 /*BEGIN: Grid container
    This is used in: Synfusion Grid component in this project
    We want the grid to take the full height of the viewport minus some offset for header/footer/toolbars
     Also, across all screen sizes it is responsive and fit onto same screen
*/
 /*Divider of grid in all Pages*/
.grid-wrapper-90 .e-grid {
    position: sticky !important;
    height: 100% !important;
}
.grid-wrapper-90 {
    position: sticky !important;
    height: calc(100vh - var(--bs-app-header-height) - var(--bs-app-toolbar-height) - var(--bs-app-footer-height) - 90px) !important;
}
/*CssClass for Syncfusion Grid. This makes grid header sticky*/
.custom-grid .e-grid {
    height: 100%;
    overflow-y: auto;
    overflow-x: auto;
}
/*END: Grid container
 
/* BEGIN: Media and controls settings */
@media (min-width: 992px) and (max-width: 1400px) {
    body {
        overflow: hidden !important;
        height: 100vh;
    }

    #kt_appUI_Toolbar {
        top: 20px !important;
        z-index: 102;
    }

    .grid-wrapper-90 {
        height: calc(100vh - var(--bs-app-header-height) - var(--bs-app-toolbar-height) - var(--bs-app-footer-height) - 90px) !important;
    }
}

@media (min-width: 200px) and (max-width: 991px) {

    body {
        overflow: auto !important;
        height: 100vh;
    }

    .grid-wrapper-90 {
        height: 650px !important;
    }

    #kt_appUI_Header {
        position: sticky !important;
        top: 0 !important;
        z-index: 102;
    }

    #kt_appUI_Toolbar {
        position: sticky !important;
         top: 3px !important;
        z-index: 102;
    }

    .custom-grid .e-grid {
        height: 100%;
        overflow-y: auto;
    }

    .e-toast-container {
        right: 0.5rem !important;
        top: 0.5rem !important;
        width: 90% !important;
    }

    .my-toast-style {
        font-size: 0.9rem;
    }

}
/* BEGIN: Media and controls settings */

  
/*BEGIN: Custom validation styles  */
/*.validation-message {
    color: Red;
    font-size: 0.7rem;
}*/

/* adjust top pos of Validation Message form input-group*/
.customvalidationmessage {
    margin-top: -15px;
}
/*END: Custom validation styles  */

/*BEGIN: Custom Synfusion component styles  */
/*APPLIED IN:
    Cmp_DateDropdown.razor
    - DatePicker
    - DateRangePicker
    - DateTimePicker
    - TimePicker
*/
.e-custom-datepicker {
    width: 100%;
    font-size: 1rem;
}
/*END: Custom Synfusion component styles  */

/* Ensure Syncfusion date/time pickers' popup match input width */
.e-datepicker .e-date-wrapper,
.e-datetimepicker .e-datetime-wrapper,
.e-timepicker .e-time-wrapper,
.e-daterangepicker .e-daterange-wrapper { width: 100% !important; }
.e-datepicker .e-popup-wrapper,
.e-datetimepicker .e-popup-wrapper,
.e-timepicker .e-popup-wrapper,
.e-daterangepicker .e-popup-wrapper { min-width: 100% !important; }

/*BEGIN: Sweet Alert Customization
    We want to customize the appearance of SweetAlert to match our application's theme
    This is used in Cmp_SweetAlert.razor
*/
.sweet-alert-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.sweet-alert-box {
    background-color: #fff;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.3);
    text-align: center;
    max-width: 400px;
    width: 90%;
    animation: fadeIn 0.3s ease-in-out;
}

.sweet-alert-button {
    background-color: #3085d6;
    color: white;
    border: none;
    padding: 0.6rem 1.2rem;
    font-size: 1rem;
    border-radius: 5px;
    cursor: pointer;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}
/*END: Sweet Alert Customization*/

/* BEGIN: For Cmp_GridSerachSmart to highlight search match character in the grid*/
.highlight-char {
    background-color: #ffe066;
    padding: 0 2px;
    border-radius: 3px;
}
/* Adjust input group styles for better appearance*/
.input-group .btn-outline-secondary {
    border-left: none;
    border-radius: 0 0.375rem 0.375rem 0;
}
button .clear-icon {
    font-size: 1.2rem;
    color: #dc3545; /* Bootstrap danger red */
}

/* END: For Cmp_GridSerachSmart to highlight search match character in the grid*/

/*BEGIN: Form-edit input field */

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

    .form-grid label {
        font-weight: 600;
        margin-bottom: 4px;
        display: block;
    }

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 1rem;
    justify-content: flex-end;
}

.form-row {
    display: flex;
    align-items: center;
    margin-bottom: 0.75rem;
    gap: 1rem;
}

.form-label {
    width: 140px;
    font-weight: 500;
}

.form-input {
    flex: 1;
    min-width: 0;
}

.validation-message {
    display: block;
    margin-top: 2px;
    color: red;
    font-size: 11px !important;
}

    .validation-message::before {
        content: '* ';
    }

.has-error {
    background-color: #fff5f5;
    border-radius: 4px;
    padding: .25rem .5rem;
}

/*END: Form-edit input field */

/*BEGIN: Custom styles for Cmp_GridSerachSmart Toast*/
.toast-body-wrapper {
    background-color: white !important;
    padding: 0.75rem !important;
    border-radius: 6px !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15) !important;
}

.e-toast-info {
    background-color: #d1e7dd !important; /* soft green */
    color: #0f5132 !important;
}

.e-toast-container {
    top: 1rem !important;
    right: 1rem !important;
    left: auto !important;
    bottom: auto !important;
    z-index: 9999;
}
/*END: Custom styles for Cmp_GridSerachSmart Toast */

/*BEGIN: Custom styles for GlobalEditForm pops up */
/* === Modal Fix for Blazor === */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%; /* ✅ full screen backdrop */
    background: rgba(0,0,0,0.5);
    z-index: 1040; /* ✅ lower than modal */
}

.modal-dialog {
    z-index: 1050; /* ✅ ensure form is above backdrop */
    max-height: 90vh; /* so it never grows taller than viewport */
    overflow-y: auto;
}

/* GlobalEditForm header improvements */
.modal-header {
    padding: 1.2rem 1rem;
    border-bottom: 1px solid #000000 !important;
    position: sticky;
    top: 0;
    background: #f9f9f917 !important;
    z-index: 1;
}
 
/*modal-footer-custom {
    border-top: 1px solid #000000 !important;
    padding: 10px 18px 5px;
    margin-top: 18px;
    justify-content: flex-end;
    display: flex;
    gap: 5px;
}*/
.modal-title {
    font-size: 1.25rem; /* 20px @ base 16px */
    font-weight: 700;
    line-height: 1.4;
    margin: 0;
}
  
.btn-close {
    transform: scale(1.1);
    opacity: .85;
}

.modal-body {
    border-top-color: black;
    max-height: 70vh;
    overflow-y: auto;
    padding-bottom: 7.5px;
}

/*END: Custom styles for GlobalEditForm pops up */

/* Modal overlay (above grid, toolbars, and toasts) */
.tf-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 12000; /* higher than .e-toast-container (9999) */
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 5vh;
}

/* Dialog container */
.tf-modal-dialog {
  position:fixed;
  width: min(900px, 92vw);
  max-height: 90vh;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(0,0,0,.18);
  display: flex;
  flex-direction: column;
}

/* Header */
.tf-modal-header {
    position: fixed;
    display: flex;
   align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .9rem 1rem;
    border-bottom: 1px solid #e9ecef;
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 1;
}

.tf-modal-title {
  font-size: 1.5rem; /* scaled above 12px base */
  font-weight: 800;
  margin: 0;
  line-height: 1.3;
}

.tf-modal-body {
  padding: 1rem;
  overflow-y: auto;
  max-height: calc(90vh - 60px);
}

/* BEGIN: SweetAlert2 / Toast  */
 /* Keep SweetAlert2 toast above modals/backdrops */
.swal2-container {
    z-index: 200000 !important;
}
    
/* Auto width to content, not full screen; allow wrap; compact padding */
.swal2-popup.swal2-toast.tf-toast {
    width: auto !important;
    min-width: 0 !important; /* override SweetAlert2 min-width: 300px */
    max-width: 640px;
    padding: .5rem .75rem;
    word-break: break-word;
}

    /* Base toast look */
    .swal2-popup.swal2-toast.tf-toast .swal2-title {
        font-size: .95rem;
        font-weight: 500;
    }

/* Color variants */
.swal2-popup.swal2-toast.tf-toast-success {
    background-color: #198754; /* bootstrap success */
    color: #fff;
}

.swal2-popup.swal2-toast.tf-toast-error {
    background-color: #dc3545; /* bootstrap danger */
    color: #fff;
}

.swal2-popup.swal2-toast.tf-toast-info {
    background-color: #0dcaf0; /* bootstrap info */
    color: #111;
}

/* Make icon visible on colored bg */
.swal2-popup.swal2-toast.tf-toast .swal2-icon {
    filter: drop-shadow(0 0 0 rgba(0,0,0,0));
}

.swal2-popup.swal2-toast.tf-toast-success .swal2-icon,
.swal2-popup.swal2-toast.tf-toast-error .swal2-icon {
    color: #fff;
}

/* Make SweetAlert2 toast container non-modal (click-through), keep toast itself clickable */
.swal2-container.swal2-top,
.swal2-container.swal2-top-start,
.swal2-container.swal2-top-end,
.swal2-container.swal2-bottom,
.swal2-container.swal2-bottom-start,
.swal2-container.swal2-bottom-end {
  pointer-events: none !important; /* ensure it wins */
}
.swal2-container.swal2-top .swal2-popup,
.swal2-container.swal2-top-start .swal2-popup,
.swal2-container.swal2-top-end .swal2-popup,
.swal2-container.swal2-bottom .swal2-popup,
.swal2-container.swal2-bottom-start .swal2-popup,
.swal2-container.swal2-bottom-end .swal2-popup {
  pointer-events: auto !important; /* toast itself remains clickable */
}
/* END: SweetAlert2 / Toast  */

/* Syncfusion toast message with FA icon prefix */
.tf-toast-sf .e-toast-message {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .5rem .75rem;
}

/* Title styling */
.tf-toast-sf .e-toast-title {
  margin: 0;
  font-weight: 600;
  line-height: 1.2;
}

/* Icon before the title; larger and vertically centered */
.tf-toast-sf .e-toast-title::before {
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.4rem;
  height: 1.4rem;
  font-size: 1rem;          /* tweak size here */
  line-height: 1;           /* keeps it centered */
  margin-right: .4rem;
  border-radius: 50%;
  background: rgba(255,255,255,.15); /* subtle circle; optional */
  color: currentColor;
  content: "\f05a";         /* default info icon */
}

/* Override icon glyph by type */
.tf-toast-sf.e-toast-success .e-toast-title::before { content: "\f058"; } /* check-circle */
.tf-toast-sf.e-toast-danger  .e-toast-title::before { content: "\f06a"; } /* exclamation-triangle */
.tf-toast-sf.e-toast-warning .e-toast-title::before { content: "\f071"; } /* warning triangle */
.tf-toast-sf.e-toast-info    .e-toast-title::before { content: "\f05a"; } /* info-circle */

/* Ensure the toast container is above modals, non-blocking (you already added these) */
.e-toast-container { z-index: 200000 !important; pointer-events: none !important; }
.e-toast-container .e-toast { pointer-events: auto !important; }

/* Stronger visual for disabled/readonly controls */
.form-control:disabled,
.form-select:disabled,
textarea:disabled,
input[readonly],
textarea[readonly] {
    background-color: #f5f6f8 !important;
    color: #6c757d !important;
    cursor: not-allowed !important;
}

/* Prevent interaction with any controls inside a disabled group if needed */
fieldset:disabled,
[aria-readonly="true"] {
    pointer-events: none;
}


/* Container: fixed, draggable, no resize */
.tf-dialog{
  position: fixed;
  top: 10vh;
  left: 50%;
  transform: translateX(-50%);
  width: min(900px, 92vw);
  max-height: 80vh;
  background: var(--bs-body-bg, #fff);
  border: 1px solid rgba(0,0,0,.08);
  border-radius: 14px;
  z-index: 1055; /* above page content */
}
.tf-dialog-header{ cursor: move; }
.tf-dialog-body {
    overflow: auto;
    max-height: calc(80vh - 50px) !important;
    /* extra bottom padding so last controls never sit under sticky footer */
    padding: .5rem 0 72px 0 !important;
}

/* Light blue header as requested */
.tf-dialog-header {
    user-select: none;
    cursor: move;
    padding: 5px 14px;
    border-bottom: 1px solid rgba(0,0,0,.06);
    background: linear-gradient(180deg, #e9f3ff, #dcebff);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top-left-radius: 14px;
    border-top-right-radius: 14px;
}

.tf-title {
    font-size: 1.5rem;
    color: #1b3c74;
}

/* Scrollable body, no resize */
/*.tf-dialog-body {
    padding: 14px;
    overflow: auto;
    max-height: calc(80vh - 56px);*/ /* subtract header */
/*}*/

/* Footer inside your form: keep visible; subtle top border */
.modal-footer-custom {
    position: sticky;
    bottom: 0;
    /*background: linear-gradient(180deg, rgba(255,255,255,.95), rgba(255,255,255,1));*/
    border-top: 1px solid rgba(0,0,0,.06);
    padding-top: 12px;
    margin-top: 12px;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* Tighter group header look */
h6.text-muted {
    color: #6b7a90 !important;
}

/*Cmp_GridSearch*/
/* Make the Bootstrap input-group wrap on small screens */
/* Turn the input group into a 3-column grid: input | help | clear */
/* 3 fixed columns: 89% / 5% / 5% with no column gap (prevents overflow) */
.responsive-searchbar.input-group {
  display: grid !important;           /* override Bootstrap input-group flex */
  grid-template-columns: 89% 5% 5%;
  /*min-width: 70%;*/
  max-width: 100%;
  box-sizing: border-box;
  overflow-x: hidden;                 /* belt-and-suspenders */
}

/* Let the input shrink without forcing overflow */
.responsive-searchbar .form-control { min-width: 0; width: 100%; }

/* Buttons fill their 5% cells; keep text tidy */
.responsive-searchbar .btn {
  width: 60px !important;
  padding-inline: .5rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.responsive-searchbar .help-btn {
    width: fit-content !important;
    padding: 5px !important;
    text-align: left !important;
}

/* Make the "Clear All" text a bit tighter so it fits earlier */
/*.responsive-searchbar .clear-btn .clear-text { 
    font-size: .8rem !important; 
}*/
.responsive-searchbar .clear-btn {
    width: fit-content  !important;
    padding: 5px !important;
    text-align:left !important;
 }

/* Remove the default input-group tight edge behavior so the grid looks clean */
.responsive-searchbar.input-group > :not(:first-child) {
  margin-left: 0 !important;
  border-top-left-radius: .375rem !important;
  border-bottom-left-radius: .375rem !important;
}

/* Medium-and-down: let the layout breathe a bit */
@media (max-width: 768px) {
  /* Keep 3 columns, but slightly relax the split so text fits better */
  .responsive-searchbar.input-group {
    grid-template-columns: 1fr auto auto;   /* input grows, buttons size to content */
  }
}

/* Small screens: put Clear All on its own full-width row so the text never vanishes */
@media (max-width: 576px) {
  .responsive-searchbar.input-group {
    grid-template-columns: 1fr auto;        /* first row: input + help */
    grid-auto-rows: auto;
    row-gap: .5rem;                          /* vertical spacing only (no extra width) */
  }
  .responsive-searchbar .clear-btn {
    grid-column: 1 / -1;                     /* second row, full width */
    justify-self: start;                     /* left align text */
  }
}



/* END: TotalFinance2026_UI.css */
/* Auth wallpaper: taller with box shadow */
.auth-wallpaper {
  height: 300px !important; /* adjust as needed or use max-height */
  width: auto !important;
  display: block;

  box-shadow: 0 20px 50px rgba(0,0,0,.35), 0 8px 20px rgba(0,0,0,.2);
  border-radius: 12px;
}
@media (max-width: 992px){
  .auth-wallpaper { height: 300px; }
}

/*BEGIN: Date picker width sync (CSS-only; no logic changes) */
/* Ensure Syncfusion input wrappers fill their container and provide positioning context */
.e-datepicker .e-date-wrapper,
.e-datetimepicker .e-datetime-wrapper,
.e-timepicker .e-time-wrapper,
.e-daterangepicker .e-daterange-wrapper,
.e-date-wrapper,
.e-datetime-wrapper,
.e-time-wrapper,
.e-daterange-wrapper {
    width: 100% !important;
    max-width: 100% !important;
    position: relative !important; /* if popup is rendered inside wrapper */
}

/* If Syncfusion renders the popup INSIDE the wrapper, make it match the trigger width */
.e-date-wrapper .e-popup,
.e-datetime-wrapper .e-popup,
.e-time-wrapper .e-popup,
.e-daterange-wrapper .e-popup {
    left: 0 !important;
    right: auto !important;
    width: 100% !important;
    min-width: 100% !important;
    box-sizing: border-box !important;
}

/* If Syncfusion renders the popup at body level, keep a sane min-width while
   allowing the existing helper to set exact px width (we are not changing JS) */
.e-popup.e-datepicker,
.e-popup.e-datetimepicker,
.e-popup.e-timepicker,
.e-popup.e-daterangepicker {
    width: auto !important;
    min-width: 16rem; /* fallback so content doesn’t collapse; helper will resize to input width */
    box-sizing: border-box !important;
}

/* Flatpickr: make generated alt input fill the container when used */
.flatpickr-input.form-control,
input.form-control + .flatpickr-input.form-control {
    width: 100% !important;
}
/*END: Date picker width sync */

/*BEGIN: Syncfusion Grid Sort Indicator Fix */
/* Position sort number ABOVE the header text to prevent overlap in narrow columns */
.e-grid.e-wrap .e-gridheader .e-sortnumber {
    position: absolute !important;
    top: 2px !important;
    right: 4px !important;
    margin: 0 !important;
    padding: 1px 4px !important;
    font-size: 10px !important;
    line-height: 1 !important;
    background: rgba(0, 123, 255, 0.1) !important;
    border-radius: 3px !important;
    min-width: 14px !important;
    text-align: center !important;
    z-index: 1 !important;
}

/* Make header cell position relative to contain the sort number */
.e-grid .e-headercell {
    position: relative !important;
    padding-top: 18px !important; /* Extra space for sort number above text */
}

/* Keep sort icon visible */
.e-grid .e-sortfilterdiv {
    display: inline-flex !important;
    align-items: center !important;
    gap: 4px !important;
}

/* Ensure header text doesn't overlap with sort number */
.e-grid .e-headercelldiv {
    padding-top: 2px !important;
    display: block !important;
}
/*END: Syncfusion Grid Sort Indicator Fix */

/* ===================================================================
   RESPONSIVE / MOBILE-FIRST LAYOUT CSS
   Added: Full mobile responsiveness pass
   Covers: Layout, header, toolbar, sidebar, grids, forms, modals,
           dialogs, footer – pure visual/layout, zero logic changes.
   =================================================================== */

/* ---------------------------------------------------------------
   1. Prevent horizontal overflow on every viewport
   --------------------------------------------------------------- */
html, body,
.app-root, .app-page, .app-wrapper, .app-main, .app-content,
#kt_app_root, #kt_app_page, #kt_app_wrapper, #kt_app_main,
#kt_app_content, #kt_app_content_container {
    max-width: 100%;
    box-sizing: border-box;
}

@media (max-width: 991.98px) {
    html, body {
        overflow-x: hidden !important;
    }
}

/* ---------------------------------------------------------------
   2. page-sticky-scope and sticky-above-grid
      (these class names are used on every data page but had no CSS)
   --------------------------------------------------------------- */
.page-sticky-scope {
    width: 100%;
    /* 'clip' clips horizontal overflow WITHOUT creating a new scroll container.
       'hidden' would create one, causing position:sticky inside to calculate
       top: relative to THIS box instead of the viewport — the 120px header+toolbar
       offset was added twice, pushing the filter toggle and selection card
       120px below the toolbar on every small-screen data page. */
    overflow-x: clip;
}

/* Issue 4: KT menu-drawer overlay must sit ABOVE sticky header/toolbar (z:102)
   but BELOW the drawer panel itself (z:110) on mobile, otherwise the overlay
   looks like it is blocking the menu and tapping it does not close the drawer. */
@media (max-width: 991.98px) {
    .drawer-overlay {
        z-index: 2100 !important;
    }
}

/* Stick below BOTH the app header and the app toolbar.
   Every data page already sets --above-grid-top:120px on the parent
   .page-sticky-scope via an inline style; that value is inherited here.
   The 120px fallback matches mobile layout (header ≈60px + toolbar ≈60px). */
.sticky-above-grid {
    position: sticky;
    top: var(--above-grid-top, 120px);
    z-index: 2;
    background-color: var(--bs-body-bg, #fff);
    padding-bottom: 2px;
    /* Issue 2: allow the expanded filter/selection card body to paint OVER the
       grid content below without being clipped by the sticky container. */
    overflow: visible !important;
}

.page-sticky-scope > .sticky-above-grid + div,
.page-sticky-scope > .sticky-above-grid + section {
    margin-top: 0 !important;
}

/* Issue 2: .card inside sticky-above-grid (selection card on enquiry pages,
   collapsible filter card on master-detail pages) must form its own stacking
   context so Syncfusion date-picker popups inside it appear above any
   Syncfusion toolbar that follows in the same sticky zone. */
.sticky-above-grid .card {
    position: relative;
    z-index: 5;
}

/* Issue 1: 2 rem breathing-room between the sticky toolbar/filter zone and
   the first content block that follows (result grid, master grid, etc.).
   Covers GL / AR / AP enquiry pages AND single-column pages.
   The :not(.page-sticky-scope) guard prevents this rule from firing on
   the nested inner scopes used inside GridTemplate_MasterDetail, which
   manage their own spacing via inline styles. */
.page-sticky-scope:not(.page-sticky-scope .page-sticky-scope) > div:not(.sticky-above-grid) {
    margin-top: 0.2rem;
}

/* ---------------------------------------------------------------
   3. Application wrapper – top margin / padding
   --------------------------------------------------------------- */

/* KT dark-sidebar layout with data-kt-app-toolbar-enabled="true" injects
   ~55 px padding-top on .app-content to reserve space for a "fixed" toolbar.
   Our #kt_appUI_Toolbar uses position:sticky (in the normal document flow),
   so the content area already starts below the toolbar naturally.
   The KT-generated padding creates a double-gap between the toolbar and the
   first page content element (search bar / sticky-above-grid).
   Override to 0 to remove the gap on all viewport sizes. */
#kt_app_content {
    padding-top: 0 !important;
}

@media (max-width: 991.98px) {
    #kt_app_content_container.app-container {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }
}

@media (max-width: 575.98px) {
    #kt_app_content_container.app-container {
        padding-left: 6px !important;
        padding-right: 6px !important;
    }
}

/* ---------------------------------------------------------------
   4. Toolbar container – wrap on small screens
   --------------------------------------------------------------- */
#kt_appUI_Toolbar_container {
    flex-wrap: wrap;
    row-gap: 4px;
}

@media (max-width: 575.98px) {
    #kt_appUI_Toolbar_container {
        gap: 4px !important;
        padding: 4px 6px !important;
    }
    #kt_appUI_Toolbar_container > .btn {
        font-size: 0.78rem;
        padding: 0.2rem 0.45rem;
    }
}

/* ---------------------------------------------------------------
   5. GlobalToolbar buttons – wrap on small screens
   --------------------------------------------------------------- */
@media (max-width: 767.98px) {
    .d-flex.flex-wrap.align-items-center.gap-2.py-2.px-4.border-bottom {
        gap: 4px !important;
        padding: 6px 8px !important;
    }
    .btn-toolbarcustom {
        font-size: 0.75rem !important;
        padding: 0.15rem 0.4rem !important;
        height: auto !important;
    }
}

/* ---------------------------------------------------------------
   6. form-grid – collapse to 1 column on mobile
   --------------------------------------------------------------- */
@media (max-width: 767.98px) {
    .form-grid {
        grid-template-columns: 1fr !important;
        gap: 0.5rem;
    }
}

/* ---------------------------------------------------------------
   7. form-row – stack label above input on mobile
   --------------------------------------------------------------- */
@media (max-width: 575.98px) {
    .form-row {
        flex-direction: column;
        gap: 0.2rem;
        margin-bottom: 0.5rem;
    }
    .form-label {
        width: 100% !important;
        min-width: 0 !important;
    }
    .form-input {
        width: 100% !important;
    }
}

/* ---------------------------------------------------------------
   8. Bootstrap modal – full width on phones
   --------------------------------------------------------------- */
@media (max-width: 767.98px) {
    .modal-dialog {
        margin: 0.4rem auto !important;
        max-width: 96vw !important;
        width: 96vw !important;
    }
    .modal-body {
        max-height: 62vh !important;
    }
    .modal-header {
        padding: 0.75rem !important;
    }
    .modal-footer-custom {
        padding-top: 8px;
        gap: 6px;
    }
}

/* ---------------------------------------------------------------
   9. tf-dialog (draggable panel) – full width on phones
   --------------------------------------------------------------- */
@media (max-width: 767.98px) {
    .tf-dialog {
        top: 4vh !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        width: min(96vw, 600px) !important;
        max-width: 96vw !important;
        max-height: 90vh !important;
    }
    .tf-dialog-body {
        max-height: calc(90vh - 50px) !important;
    }
}

/* ---------------------------------------------------------------
   10. tf-modal-overlay / tf-modal-dialog – full width on phones
   --------------------------------------------------------------- */
@media (max-width: 767.98px) {
    .tf-modal-dialog {
        width: 96vw !important;
        max-height: 90vh !important;
    }
    .tf-modal-body {
        max-height: calc(90vh - 60px) !important;
    }
    .tf-modal-overlay {
        padding-top: 2vh;
        padding-left: 2vw;
        padding-right: 2vw;
    }
}

/* ---------------------------------------------------------------
   11. Syncfusion Grid – heights and horizontal scroll on mobile
   --------------------------------------------------------------- */
@media (max-width: 991.98px) {
    .e-grid {
        overflow-x: auto !important;
    }
    /* allow grid to scroll horizontally inside its card */
    .e-gridcontent,
    .e-table-container {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }
}

/* Shrink grid-wrapper-90 height on small phones */
@media (max-width: 575.98px) {
    .grid-wrapper-90 {
        height: 420px !important;
    }
}

@media (max-width: 360px) {
    .grid-wrapper-90 {
        height: 360px !important;
    }
}

/* ---------------------------------------------------------------
   12. Syncfusion sticky grid header – disable on mobile
       On desktop the header sticks correctly inside #kt_app_main.
       On mobile the body is the scroll container and the sticky grid
       header (top:0) would slide behind the sticky filter card that
       lives inside .sticky-above-grid (which itself sticks at ~120px
       and can be 300-400px tall on journal pages).
       Disabling it on mobile prevents the column header from being
       hidden; users scroll up to see column names (standard mobile UX).
   --------------------------------------------------------------- */
@media (max-width: 991.98px) {
    .e-grid.e-stickyheader .e-gridheader {
        position: relative !important;
        top: auto !important;
        z-index: auto !important;
    }
}

/* ---------------------------------------------------------------
   12b. Syncfusion toolbar / pager – wrap on mobile
   --------------------------------------------------------------- */
@media (max-width: 767.98px) {
    .e-toolbar .e-toolbar-items {
        flex-wrap: wrap !important;
    }
    .e-pager {
        flex-wrap: wrap;
        gap: 4px;
    }
}

/* ---------------------------------------------------------------
   13. Header – tighten text on very small phones
   --------------------------------------------------------------- */
@media (max-width: 360px) {
    .app-header-pro .fw-bold.fs-3 {
        font-size: 0.9rem !important;
    }
    .app-header-pro .text-muted.fs-7 {
        display: none !important;
    }
    .app-header-pro .h-40px {
        height: 26px !important;
    }
}

/* ---------------------------------------------------------------
   14. Footer – compact on phones
   --------------------------------------------------------------- */
@media (max-width: 575.98px) {
    .app-footer .app-container {
        flex-direction: column !important;
        align-items: flex-start !important;
        font-size: 0.72rem;
        padding: 4px 10px !important;
    }
}

/* ---------------------------------------------------------------
   15. SystemLayout card (login / error pages) – fill width on phones
   --------------------------------------------------------------- */
@media (max-width: 767.98px) {
    .w-lg-650px {
        width: 100% !important;
        max-width: 100% !important;
    }
}

/* ---------------------------------------------------------------
   16. Card body padding reduction on phones
   --------------------------------------------------------------- */
@media (max-width: 575.98px) {
    .card-body {
        padding: 0.75rem !important;
    }
    .card {
        border-radius: 0.4rem !important;
    }
}

/* ---------------------------------------------------------------
   17. Opening-balance mode header – stack vertically on phones
   --------------------------------------------------------------- */
@media (max-width: 767.98px) {
    .card .d-flex.flex-wrap.align-items-center.gap-3 {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.5rem !important;
    }
    .card .d-flex.flex-wrap.align-items-center.gap-3 > div,
    .card .d-flex.flex-wrap.align-items-center.gap-3 > .ms-auto {
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        margin-left: 0 !important;
    }
    .card .d-flex.flex-wrap.align-items-center.gap-3 > div[style*="display:flex"],
    .card .d-flex.flex-wrap.align-items-center.gap-3 > div[style*="display: flex"] {
        justify-content: flex-start;
    }
}

/* ---------------------------------------------------------------
   18. SweetAlert / toast – phone-safe sizing
   --------------------------------------------------------------- */
@media (max-width: 575.98px) {
    .swal2-popup:not(.swal2-toast) {
        width: 90vw !important;
        font-size: 0.85rem !important;
    }
    .sweet-alert-box {
        width: 90% !important;
        max-width: 90vw !important;
    }
}

/* ---------------------------------------------------------------
   19. Search-help dialog in Cmp_GridSearchSmart – phone width
   --------------------------------------------------------------- */
@media (max-width: 767.98px) {
    .search-help-dialog,
    .modal.show .modal-dialog.modal-lg {
        max-width: 96vw !important;
        width: 96vw !important;
        margin: 0.4rem auto !important;
    }
}

/* ---------------------------------------------------------------
   20. Input group – prevent overflow on phones
   --------------------------------------------------------------- */
@media (max-width: 575.98px) {
    .input-group:not(.responsive-searchbar) {
        flex-wrap: wrap !important;
    }
}

/* ---------------------------------------------------------------
   21. Ensure all images are responsive
   --------------------------------------------------------------- */
img {
    max-width: 100%;
    height: auto;
}

/* ---------------------------------------------------------------
   22. Ensure tables inside cards have horizontal scroll
   --------------------------------------------------------------- */
.card-body table:not(.e-table) {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
}

/* ---------------------------------------------------------------
   23. Print: hide non-essential chrome
   --------------------------------------------------------------- */
@media print {
    #kt_appUI_Header,
    #kt_appUI_Toolbar,
    #kt_app_footer,
    .app-sidebar,
    .sticky-above-grid,
    .btn-toolbarcustom {
        display: none !important;
    }
    .app-content {
        padding: 0 !important;
    }
    .grid-wrapper-90 {
        height: auto !important;
        overflow: visible !important;
    }
}

/* END: Responsive / Mobile-First additions */