/*
   Global responsive polish for Razor views.
   Loaded after page-specific styles so mobile arrangement stays consistent
   without changing desktop layouts or print media.
*/

:root {
    --mobile-surface: rgba(255, 255, 255, 0.94);
    --mobile-border: rgba(148, 163, 184, 0.22);
    --mobile-ink: #122033;
    --mobile-muted: #64748b;
    --mobile-accent: #0ea5e9;
    --mobile-accent-2: #22c55e;
    --mobile-shadow: 0 16px 38px rgba(15, 23, 42, 0.08);
    --mobile-radius: 8px;
}

@media screen and (max-width: 991.98px) {
    html {
        scroll-padding-top: calc(var(--header-offset, 0px) + 0.75rem);
    }

    body {
        color: var(--mobile-ink);
        background:
            linear-gradient(135deg, #f8fbff 0%, #eef7ff 48%, #f7fbf8 100%) !important;
        overflow-x: hidden;
    }

    body > .container-xl.flex-grow-1 {
        width: 100%;
        max-width: none;
        padding-inline: clamp(0.65rem, 3vw, 1rem);
    }

    body > .container-xl.flex-grow-1 > main {
        width: 100%;
        min-width: 0;
        padding-bottom: 1.25rem !important;
    }

    img,
    svg,
    video,
    canvas {
        max-width: 100%;
    }

    body > header .navbar {
        min-height: auto !important;
        padding: 0.72rem 0.85rem !important;
        box-shadow: 0 12px 34px rgba(15, 23, 42, 0.08);
    }

    body > header .navbar-brand {
        min-width: 0;
    }

    body > header .navbar-brand img {
        height: 46px !important;
        width: auto;
    }

    #mainNav {
        width: 100%;
    }

    #mainNav .navbar-nav {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.45rem;
        padding-top: 0.7rem;
        width: 100%;
    }

    #mainNav .nav-item {
        border: 1px solid rgba(148, 163, 184, 0.18);
        border-radius: var(--mobile-radius);
        background: rgba(248, 250, 252, 0.86);
    }

    #mainNav .nav-link {
        align-items: center !important;
        flex-direction: row !important;
        justify-content: flex-start !important;
        min-height: 2.9rem;
        min-width: 0 !important;
        gap: 0.55rem !important;
        padding: 0.65rem 0.78rem !important;
        text-align: left !important;
        white-space: normal;
    }

    #mainNav .notification-trigger {
        flex-direction: row;
    }

    #mainNav .notification-dropdown {
        inset: auto !important;
        left: 0.5rem !important;
        right: 0.5rem !important;
        width: auto !important;
        max-width: none;
    }

    :where(h1, h2, h3, h4, h5, h6) {
        letter-spacing: 0 !important;
    }

    :where(.container, .container-fluid, [class$="-shell"], [class*="-shell "], [class$="-page"], [class*="-page "]) {
        max-width: 100%;
    }

    :where([class$="-hero"], [class*="-hero "]) {
        min-height: 0 !important;
        gap: 1rem;
        border-radius: var(--mobile-radius) !important;
    }

    :where([class$="-hero"], [class*="-hero "], [class$="-panel"], [class*="-panel "], [class$="-card"], [class*="-card "]) {
        background-clip: padding-box;
    }

    :where([class$="-toolbar"], [class*="-toolbar "], [class$="-filter"], [class*="-filter "], [class$="-actions"], [class*="-actions "], [class$="-header"], [class*="-header "]) {
        min-width: 0;
        flex-wrap: wrap;
        gap: 0.75rem !important;
    }

    :where(.row) {
        --bs-gutter-x: 1rem;
        --bs-gutter-y: 1rem;
    }

    :where(.table-responsive, [class$="-table-wrap"], [class*="-table-wrap "], [class$="-table-shell"], [class*="-table-shell "]) {
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: var(--mobile-radius);
    }

    :where(.table-responsive) {
        border: 1px solid rgba(148, 163, 184, 0.18);
        background: rgba(255, 255, 255, 0.72);
    }

    :where(.table-responsive) > .table {
        margin-bottom: 0;
        min-width: 720px;
    }

    :where(.table) {
        font-size: 0.86rem;
    }

    :where(.table th, .table td) {
        padding: 0.55rem 0.62rem;
        white-space: nowrap;
    }

    :where(.form-control, .form-select, .input-group-text) {
        min-height: 2.65rem;
        font-size: 1rem;
        border-radius: var(--mobile-radius);
    }

    :where(textarea.form-control) {
        min-height: 6rem;
    }

    :where(.form-label, label) {
        line-height: 1.25;
    }

    :where(.btn) {
        border-radius: var(--mobile-radius);
        min-height: 2.45rem;
    }

    :where(.card) {
        border-radius: var(--mobile-radius);
    }

    :where(.card:hover, .info-card:hover) {
        transform: none;
    }

    :where(.pagination) {
        flex-wrap: wrap;
        gap: 0.28rem;
    }

    :where(.page-link) {
        border-radius: var(--mobile-radius) !important;
    }

    :where(.modal-dialog) {
        width: calc(100vw - 1rem);
        max-width: calc(100vw - 1rem);
        margin: 0.5rem auto;
    }

    :where(.modal-content) {
        border-radius: var(--mobile-radius) !important;
        max-height: calc(100dvh - 1rem);
        overflow: hidden;
    }

    :where(.modal-header, .modal-body, .modal-footer) {
        padding-inline: 1rem !important;
    }

    :where(.modal-body) {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    :where(.modal-footer) {
        align-items: stretch;
        gap: 0.5rem;
    }
}

@media screen and (max-width: 767.98px) {
    body > .container-xl.flex-grow-1 {
        padding-inline: 0.62rem;
    }

    :where(.container, .container-fluid) {
        padding-inline: 0.62rem;
    }

    :where([class$="-shell"], [class*="-shell "], [class$="-page"], [class*="-page "]) {
        margin-inline: auto;
        padding-inline: 0 !important;
    }

    :where([class$="-hero"], [class*="-hero "]) {
        display: flex;
        flex-direction: column;
        align-items: stretch !important;
        padding: 1rem !important;
    }

    :where([class$="-hero"], [class*="-hero "]) :where(h1, h2, h3) {
        font-size: clamp(1.24rem, 6vw, 1.65rem) !important;
        line-height: 1.12 !important;
    }

    :where([class$="-hero"], [class*="-hero "]) :where(p) {
        font-size: 0.9rem !important;
        line-height: 1.42 !important;
    }

    :where(
        [class$="-grid"]:not(.leave-calendar-grid):not(.calendar-grid):not(.time-grid):not(.dtr-5row):not(.leave-weekdays),
        [class*="-grid "]:not(.leave-calendar-grid):not(.calendar-grid):not(.time-grid):not(.dtr-5row):not(.leave-weekdays),
        [class$="-summary-row"],
        [class*="-summary-row "],
        [class$="-metrics-grid"],
        [class*="-metrics-grid "]
    ) {
        grid-template-columns: 1fr !important;
    }

    :where([class$="-panel"], [class*="-panel "], [class$="-card"], [class*="-card "], .card) {
        border-radius: var(--mobile-radius) !important;
    }

    :where(.card-body) {
        padding: 1rem !important;
    }

    :where(.btn-toolbar, .btn-group, [class$="-actions"], [class*="-actions "], [class$="-controls"], [class*="-controls "]) {
        width: 100%;
    }

    :where([class$="-actions"], [class*="-actions "], [class$="-controls"], [class*="-controls "]) > :where(.btn, a.btn, button.btn) {
        flex: 1 1 auto;
    }

    :where(.modal-footer) {
        flex-direction: column;
    }

    :where(.modal-footer) > :where(.btn, button, a.btn) {
        width: 100%;
    }

    :where(.input-group) {
        flex-wrap: nowrap;
    }

    :where(.badge, [class$="-badge"], [class*="-badge "], [class$="-pill"], [class*="-pill "]) {
        white-space: normal;
    }
}

@media screen and (max-width: 575.98px) {
    body > header .navbar {
        padding-inline: 0.65rem !important;
    }

    body > header .navbar-brand img {
        height: 40px !important;
    }

    #mainNav .navbar-nav {
        grid-template-columns: 1fr;
    }

    :where(.container, .container-fluid, body > .container-xl.flex-grow-1) {
        padding-inline: 0.5rem;
    }

    :where(.mt-5) {
        margin-top: 1.25rem !important;
    }

    :where(.mb-5) {
        margin-bottom: 1.25rem !important;
    }

    :where(.p-5) {
        padding: 1rem !important;
    }

    :where(.p-4) {
        padding: 0.9rem !important;
    }

    :where(.px-4, .px-5) {
        padding-inline: 0.9rem !important;
    }

    :where(.py-4, .py-5) {
        padding-block: 0.9rem !important;
    }

    :where(.table-responsive) > .table {
        min-width: 640px;
    }

    :where(.table) {
        font-size: 0.82rem;
    }

    :where(.form-control, .form-select, .input-group-text) {
        min-height: 2.55rem;
    }

    :where(.btn) {
        min-height: 2.4rem;
    }

    :where(.modal-dialog) {
        width: calc(100vw - 0.7rem);
        max-width: calc(100vw - 0.7rem);
        margin: 0.35rem auto;
    }
}

@media screen and (hover: none) and (pointer: coarse) {
    :where(.card:hover, [class$="-card"]:hover, [class*="-card "]:hover) {
        transform: none !important;
    }
}
