/* ========================================
   RESPONSIVE LAYOUT ADJUSTMENTS FOR COMPACT VIEW
   Make UI fit all controls on screen without scrolling
   ======================================== */

/* Extra Small Screens (Mobile - 320px to 575px) */
@media (max-width: 575.98px) {
    body {
        --form-font-size: 0.65rem;
        --form-control-height: 1.6rem;
        --card-padding: 0.3rem;
        --form-gap: 0.1rem;
        --button-height: 1.6rem;
    }

    body .rz-card.rz-variant-flat {
        padding: 0.3rem !important;
        margin-bottom: 0.15rem !important;
    }

    body .rz-card.rz-variant-outlined {
        padding: 0.25rem !important;
        margin-top: 0.1rem !important;
    }

    body .rz-button {
        height: 1.6rem !important;
        min-height: 1.6rem !important;
        font-size: 0.65rem !important;
        padding: 0.2rem 0.4rem !important;
    }

    body .rz-grid-table thead th {
        padding: 0.15rem 0.15rem !important;
        font-size: 0.65rem !important;
    }

    body .rz-data-row td {
        padding: 0.25rem 0.35rem !important;
        font-size: 0.65rem !important;
    }

    .modern-enterprise-grid .rz-grid-table thead th {
        padding: 0.15rem 0.15rem !important;
        font-size: 0.65rem !important;
    }

    .modern-enterprise-grid .rz-data-row td {
        padding: 0.25rem 0.35rem !important;
        font-size: 0.65rem !important;
    }

    body .rz-form-field-label {
        font-size: 0.65rem !important;
    }

    body .rz-content {
        padding: 0.1rem !important;
    }

    body .rz-templateform .rz-row,
    body .form-row-gap {
        gap: 0.08rem !important;
        column-gap: 0.2rem !important;
    }

    body .form-stack-gap {
        gap: 0.08rem !important;
    }
}

/* Small Screens (Tablets Portrait - 576px to 767px) */
@media (min-width: 576px) and (max-width: 767.98px) {
    body {
        --form-font-size: 0.68rem;
        --form-control-height: 1.65rem;
        --card-padding: 0.5rem;
        --form-gap: 0.22rem;
        --button-height: 1.65rem;
    }

    body .rz-card.rz-variant-flat {
        padding: 0.5rem !important;
        margin-bottom: 0.35rem !important;
    }

    body .rz-card.rz-variant-outlined {
        padding: 0.4rem !important;
    }

    body .rz-button {
        height: 1.65rem !important;
        min-height: 1.65rem !important;
        font-size: 0.68rem !important;
    }

    body .rz-grid-table thead th,
    body .rz-data-row td {
        font-size: 0.68rem !important;
    }
}

/* Medium Screens (Tablets Landscape - 768px to 991px) */
@media (min-width: 768px) and (max-width: 991.98px) {
    body {
        --form-font-size: 0.70rem;
        --form-control-height: 1.70rem;
        --card-padding: 0.6rem;
        --form-gap: 0.25rem;
        --button-height: 1.70rem;
    }

    body .rz-card.rz-variant-flat {
        padding: 0.6rem !important;
        margin-bottom: 0.4rem !important;
    }

    body .rz-card.rz-variant-outlined {
        padding: 0.5rem !important;
    }

    body .rz-button {
        height: 1.70rem !important;
        min-height: 1.70rem !important;
        font-size: 0.70rem !important;
    }
}

/* Large Screens (Desktops - 992px to 1199px) */
@media (min-width: 992px) and (max-width: 1199.98px) {
    body {
        --form-font-size: 0.72rem;
        --form-control-height: 1.75rem;
        --card-padding: 0.65rem;
        --form-gap: 0.25rem;
        --button-height: 1.75rem;
    }

    body .rz-card.rz-variant-flat {
        padding: 0.65rem !important;
    }

    body .rz-button {
        height: 1.75rem !important;
        min-height: 1.75rem !important;
        font-size: 0.72rem !important;
    }
}

/* Extra Large Screens (Large Desktops - 1200px to 1399px) */
@media (min-width: 1200px) and (max-width: 1399.98px) {
    body {
        --form-font-size: 0.75rem;
        --form-control-height: 1.80rem;
        --card-padding: 0.75rem;
        --form-gap: 0.25rem;
        --button-height: 1.80rem;
    }

    body .rz-button {
        height: 1.80rem !important;
        min-height: 1.80rem !important;
        font-size: 0.75rem !important;
    }
}

/* XXL Screens (Very Large Desktops - 1400px and up) */
@media (min-width: 1400px) {
    body {
        --form-font-size: 0.78rem;
        --form-control-height: 1.85rem;
        --card-padding: 0.8rem;
        --form-gap: 0.30rem;
        --button-height: 1.85rem;
    }

    body .rz-button {
        height: 1.85rem !important;
        min-height: 1.85rem !important;
        font-size: 0.78rem !important;
    }
}

/* Scale down specific card margins and padding for all smaller screens */
@media (max-width: 1199.98px) {
    body .rz-main,
    body .rz-body {
        padding-top: 0 !important;
    }

    body .rz-content {
        padding: 0.25rem !important;
    }

    body .rz-card.rz-variant-flat:first-of-type {
        margin-top: 0 !important;
        padding-top: 0.2rem !important;
    }

    .master-header-wrapper {
        margin-bottom: 0.3rem !important;
    }

    /* Reduce button gaps for smaller screens */
    body .rz-stack.rz-horizontal {
        gap: 0.3rem !important;
    }

    /* Tighter form field spacing */
    body .rz-templateform .rz-row,
    body .form-row-gap,
    body .form-stack-gap {
        gap: 0.2rem !important;
        column-gap: 0.4rem !important;
    }
}

/* Special optimization for very compact screens (under 768px) */
@media (max-width: 767.98px) {
    /* Make grids scrollable horizontally if needed */
    .modern-grid-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Hide less critical columns on mobile if grid is too wide */
    body .rz-grid-table th:nth-child(n+6),
    body .rz-grid-table td:nth-child(n+6) {
        display: none;
    }

    /* Stack buttons vertically on very small screens */
    body .rz-stack.rz-horizontal {
        flex-direction: column !important;
        align-items: stretch !important;
    }

    body .rz-stack.rz-horizontal .rz-button {
        width: 100% !important;
    }

    /* Reduce icon sizes */
    body .rz-form-field .rz-icon,
    body .rz-form-field .rzi {
        font-size: 0.85rem !important;
        width: 1.3rem !important;
        height: 1.3rem !important;
    }
}

/* Optimize grid cell heights for all screen sizes */
@media (max-width: 991.98px) {
    body .modern-enterprise-grid .rz-data-row td,
    body .rz-data-row td {
        line-height: 1.1 !important;
    }
}

/* Ensure all content fits without scrolling on typical laptop screens */
@media (min-width: 768px) and (max-width: 1366px) {
    /* This is the sweet spot for most users - very compact */
    :root {
        --form-font-size: 0.68rem;
        --form-control-height: 1.65rem;
        --card-padding: 0.4rem;
        --form-gap: 0.1rem;
        --button-height: 1.65rem;
    }

    body .rz-card.rz-variant-flat {
        padding: 0.4rem !important;
        margin-bottom: 0.15rem !important;
    }

    body .rz-card.rz-variant-outlined {
        padding: 0.35rem !important;
        margin-top: 0.1rem !important;
    }

    body .rz-grid-table thead th {
        padding: 0.20rem 0.30rem !important;
        font-size: 0.68rem !important;
    }

    body .rz-data-row td {
        padding: 0.3rem 0.4rem !important;
        font-size: 0.68rem !important;
    }

    .modern-enterprise-grid .rz-grid-table thead th {
        padding: 0.25rem 0.20rem !important;
        font-size: 0.68rem !important;
    }

    .modern-enterprise-grid .rz-data-row td {
        padding: 0.3rem 0.4rem !important;
        font-size: 0.68rem !important;
    }

    body .rz-button {
        height: 1.65rem !important;
        min-height: 1.65rem !important;
        font-size: 0.68rem !important;
        padding: 0.2rem 0.5rem !important;
    }

    body .rz-tabview-panel {
        padding: 0.2rem !important;
    }

    body .rz-form-field-label {
        font-size: 0.68rem !important;
        margin-bottom: 0.08rem !important;
    }

    body .rz-form-field input,
    body .rz-form-field textarea,
    body .rz-form-field .rz-inputtext {
        padding: 0.2rem 0.4rem !important;
    }

    body .rz-stack:has(> .rz-chkbox):has(> .rz-label) {
        padding: 0.0rem 0.0rem !important;
        /*gap: 0.05rem !important;*/
    }

    .master-form-action-bar .master-header-layout {
        padding: 0.15rem 0.25rem !important;
    }

    .action-btn-modern {
        height: 1.65rem !important;
        padding: 0 0.6rem !important;
    }

    .action-btn-icon {
        font-size: 0.85rem !important;
    }

    body .rz-templateform .rz-row,
    body .form-row-gap {
        gap: 0.08rem !important;
        column-gap: 0.3rem !important;
    }

    body .form-stack-gap {
        gap: 0.08rem !important;
    }

    body .rz-content {
        padding-top: 0.15rem !important;
    }

    hr {
        margin: 0.3rem 0 !important;
    }

    .modern-grid-container,
    .modern-enterprise-grid {
        margin-top: 0.2rem !important;
    }
}

/* Force compact view - Universal override for consistency */
body {
    font-size: var(--form-font-size) !important;
    line-height: 1.3 !important;
}

/* Remove excessive whitespace from all containers */
body * {
    box-sizing: border-box;
}

/* Ensure no overflow causes hidden content */
body .rz-layout {
    overflow-y: auto;
    height: 100vh;
}

/* Make sure grids are visible and not pushed down */
.modern-grid-container,
.modern-enterprise-grid {
    margin-top: 0.3rem !important;
    max-height: calc(100vh - 450px);
    overflow-y: auto;
}

/* Compact pager at bottom of grids */
body .rz-pager {
    padding: 0.35rem 0.6rem !important;
    font-size: var(--form-font-size) !important;
}

/* Reduce spacing in filtration criteria section */
body .rz-card.rz-variant-outlined [style*="border: 1px solid"] {
    padding: 0.3rem !important;
    margin: 0.2rem 0 !important;
}

/* Make date pickers and dropdowns more compact */
body .rz-datepicker-calendar,
body .rz-dropdown-panel {
    font-size: var(--form-font-size) !important;
}

body .rz-dropdown-item,
body .rz-autocomplete-item {
    padding: 0.35rem 0.6rem !important;
    font-size: var(--form-font-size) !important;
}

/* Compact alerts and notifications */
body .rz-alert {
    padding: 0.5rem !important;
    font-size: var(--form-font-size) !important;
    margin-bottom: 0.3rem !important;
}

/* Ensure Process button and action buttons are visible */
body .rz-button-info,
body .rz-button-primary,
body .rz-button-success {
    min-width: auto !important;
}
