/* ============================================================================
   TICKET SYNC — MOBILE.CSS v3.0
   ============================================================================
   Loaded AFTER style.css and design-system.css from includes/header.php.

   v3.0 additions (over v1.0):
     §17 — Burger z-order fix + off-canvas safety net
     §18 — Floating sidebar toggle (#tsSidebarFloat) — always tappable,
           bottom-left, above everything, mirrors the burger on every page
           and every breakpoint.

   Sections:
     §1  Variables + safe-area helpers
     §2  Base body / horizontal-scroll guard
     §3  Navbar (burger, brand, bell, search, avatar)
     §4  Left sidebar → off-canvas drawer (mobile)
     §5  Overlay + body scroll lock
     §6  #content / .main-content / .page-content
     §7  Right sidebar → hidden on ALL sizes (rs-hidden switch)
     §8  Notification dropdown
     §9  Mobile search bar (#navbarSearchForm under navbar)
     §10 Tables — horizontal scroll fallback
     §11 Forms — 16px inputs, 44px touch targets, iOS zoom guard
     §12 Cards, stat grids, button groups, modals
     §13 Page headers with action buttons
     §14 Safe-area insets
     §15 Dark / light theme overrides
     §16 Print — leave alone
     §17 Burger z-order + off-canvas safety net
     §18 Floating sidebar toggle
   ============================================================================ */

/* ============================================================================
   §1 — VARIABLES
   ============================================================================ */
   :root {
    --ts-drawer-width:      min(85vw, 300px);
    --ts-overlay-bg:        rgba(0, 0, 0, 0.5);
    --ts-navbar-h-mobile:   56px;
    --ts-touch-target:      44px;
    --ts-input-font:        16px;
    --ts-mobile-gap:        0.75rem;
    --ts-radius:            0.5rem;
}

/* ============================================================================
   §2 — BASE BODY / GLOBAL HORIZONTAL-SCROLL GUARD
   ============================================================================ */
html, body {
    overflow-x: hidden;
    max-width: 100vw;
    width: 100%;
}
body {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}
img {
    max-width: 100%;
    height: auto;
}

/* ============================================================================
   §3 — NAVBAR (mobile)
   ============================================================================ */
@media (max-width: 991.98px) {

    .navbar {
        height: var(--ts-navbar-h-mobile);
        min-height: var(--ts-navbar-h-mobile);
        padding: 0 0.75rem;
        padding-top:    env(safe-area-inset-top, 0);
        padding-left:   max(0.75rem, env(safe-area-inset-left, 0));
        padding-right:  max(0.75rem, env(safe-area-inset-right, 0));
        flex-wrap: nowrap !important;
    }

    .navbar .container-fluid {
        flex-wrap: nowrap !important;
        gap: 0.5rem;
        align-items: center;
    }

    .navbar .d-flex.ms-auto {
        flex-shrink: 0;
        gap: 0.25rem;
        align-items: center;
    }

    #sidebarCollapse {
        width: var(--ts-touch-target);
        height: var(--ts-touch-target);
        min-width: var(--ts-touch-target);
        flex-shrink: 0;
        padding: 0;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    #sidebarCollapse i {
        font-size: 1.35rem;
    }

    .navbar-brand.d-lg-none,
    .navbar-brand.mb-0.h5.d-lg-none,
    .ts-header-brand {
        font-size: 1rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 40vw;
        color: var(--text-primary, #212529) !important;
    }

    .notification-bell-btn {
        width: var(--ts-touch-target);
        height: var(--ts-touch-target);
        padding: 0;
    }

    #userDropdown {
        padding: 0.25rem !important;
        gap: 0 !important;
        min-width: var(--ts-touch-target);
        height: var(--ts-touch-target);
        justify-content: center;
    }
    #userDropdown .navbar-avatar {
        width: 32px;
        height: 32px;
    }

    #userDropdown .user-name {
        display: none !important;
    }
}

@media (min-width: 768px) and (max-width: 991.98px) {
    #userDropdown .user-name {
        display: inline !important;
        font-size: 0.85rem;
        max-width: 120px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

/* ============================================================================
   §4 — LEFT SIDEBAR → OFF-CANVAS DRAWER (mobile)
   ============================================================================ */
@media (max-width: 991.98px) {

    .sidebar {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        bottom: 0 !important;
        height: 100vh !important;
        height: 100dvh !important;
        width: var(--ts-drawer-width) !important;
        max-width: 100vw;
        z-index: 1050;
        transform: translateX(-110%) !important;
        visibility: hidden !important;
        opacity: 0 !important;
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1), visibility 0s linear 0.28s, opacity 0.2s ease !important;
        box-shadow: none !important;
        padding-top: env(safe-area-inset-top, 0);
        padding-bottom: env(safe-area-inset-bottom, 0);
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        pointer-events: none !important;
    }

    .sidebar.sidebar-drawer-open {
        transform: translateX(0) !important;
        visibility: visible !important;
        opacity: 1 !important;
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1), visibility 0s linear 0s, opacity 0.2s ease !important;
        box-shadow: 2px 0 12px rgba(0, 0, 0, 0.25) !important;
        pointer-events: auto !important;
    }

    .sidebar.active {
        transform: translateX(-110%) !important;
        visibility: hidden !important;
        opacity: 0 !important;
    }
    .sidebar.active.sidebar-drawer-open {
        transform: translateX(0) !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    #content,
    #content.active,
    #content.expanded,
    #content.active.expanded {
        margin-left: 0 !important;
        margin-right: 0 !important;
        width: 100% !important;
    }

    .sidebar .nav-link {
        padding: 0.75rem 1rem !important;
        min-height: var(--ts-touch-target);
        display: flex;
        align-items: center;
    }
}

/* ============================================================================
   §5 — OVERLAY + BODY SCROLL LOCK
   ============================================================================ */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: var(--ts-overlay-bg);
    z-index: 1040;
    opacity: 0;
    visibility: hidden;
    /* A hidden overlay must never eat a tap. Without this, a leftover
       body.sidebar-open class left a full-screen layer over the page and
       every button underneath looked dead. */
    pointer-events: none;
    transition: opacity 0.25s ease, visibility 0.25s ease;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

body.sidebar-open {
    overflow: hidden !important;
    position: fixed;
    width: 100%;
    left: 0;
    right: 0;
}

@media (max-width: 991.98px) {
    body.sidebar-open .sidebar-overlay {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }
}

/* ============================================================================
   §6 — #CONTENT / .MAIN-CONTENT / .PAGE-CONTENT
   ============================================================================ */
@media (max-width: 991.98px) {
    .main-content {
        padding: 0.5rem !important;
    }
    .main-content-inner {
        gap: 0 !important;
    }
    .page-content,
    #page-content {
        overflow-x: hidden;
        max-width: 100%;
        width: 100%;
    }
    .page-content-inner {
        padding: 0 !important;
    }
}

@media (max-width: 575.98px) {
    .main-content {
        padding: 0.25rem !important;
    }
}

/* ============================================================================
   §7 — RIGHT SIDEBAR → HIDDEN ON ALL SIZES (rs-hidden)
   ============================================================================ */
body.rs-hidden .right-sidebar,
body.rs-hidden #rightSidebar,
body.rs-hidden #rightSidebarToggle,
body.rs-hidden #sidebarOverlay--right {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

body.rs-hidden #content,
body.rs-hidden #content.active,
body.rs-hidden #content.expanded,
body.rs-hidden #content.active.expanded {
    margin-right: 0 !important;
    width: auto;
}

@media (min-width: 992px) {
    body.rs-hidden #content {
        width: calc(100% - var(--sidebar-width));
    }
    body.rs-hidden #content.active {
        width: 100%;
    }
}

@media (max-width: 991.98px) {
    body.rs-hidden #content,
    body.rs-hidden #content.active,
    body.rs-hidden #content.expanded,
    body.rs-hidden #content.active.expanded {
        width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
}

/* ============================================================================
   §8 — NOTIFICATION DROPDOWN (fits viewport)
   ============================================================================ */
@media (max-width: 991.98px) {
    .notification-dropdown {
        min-width: 0 !important;
        width: calc(100vw - 16px) !important;
        max-width: 400px;
        margin-left: 0 !important;
        margin-right: 0 !important;
        right: 0 !important;
        left: auto !important;
    }
    .notification-dropdown.show {
        position: absolute !important;
        top: calc(100% + 6px) !important;
    }
    .notification-dropdown .notif-list {
        max-height: 65vh;
        overflow-y: auto;
    }
    #userDropdown + .dropdown-menu {
        min-width: 0 !important;
        width: calc(100vw - 16px) !important;
        max-width: 300px;
        right: 0 !important;
        left: auto !important;
    }
}

@media (max-width: 575.98px) {
    .notification-dropdown {
        width: calc(100vw - 12px) !important;
        max-width: none;
        margin-left: 6px !important;
        margin-right: 6px !important;
        right: 0 !important;
        left: -0.5rem !important;
    }
}

/* ============================================================================
   §9 — MOBILE SEARCH BAR
   ============================================================================ */
@media (max-width: 991.98px) {
    #navbarSearchForm.navbar-search-form {
        position: absolute !important;
        top: var(--ts-navbar-h-mobile);
        left: 0;
        right: 0;
        max-width: none !important;
        min-width: 0 !important;
        width: auto !important;
        height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        background: transparent !important;
        border: 0 !important;
        overflow: hidden !important;
        z-index: 1045;
        display: none !important;
        visibility: hidden !important;
        pointer-events: none !important;
    }
    body.ts-mobile-search-open #navbarSearchForm.navbar-search-form {
        display: flex !important;
        visibility: visible !important;
        pointer-events: auto !important;
        height: auto !important;
        padding: 8px 12px !important;
        background: var(--bg-white, #fff) !important;
        border-bottom: 1px solid var(--border-color, #dee2e6) !important;
        overflow: visible !important;
    }
    body.ts-mobile-search-open #navbarSearchForm.navbar-search-form.d-none {
        display: flex !important;
    }
    #navbarSearchForm .input-group {
        width: 100%;
    }
    #navbarSearchForm .form-control {
        height: var(--ts-touch-target);
        font-size: var(--ts-input-font);
    }
    #navbarSearchToggle {
        width: var(--ts-touch-target);
        height: var(--ts-touch-target);
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        border: none;
        background: transparent;
        color: var(--text-primary, #212529);
        padding: 0;
        text-decoration: none;
    }
    #navbarSearchToggle:focus {
        outline: none;
        box-shadow: 0 0 0 2px rgba(var(--accent-color-rgb, 13, 110, 253), 0.25);
        border-radius: 8px;
    }
    body.ts-mobile-search-open #content {
        padding-top: calc(var(--ts-navbar-h-mobile) + 56px);
        transition: padding-top 0.2s ease;
    }
}

@media (min-width: 992px) {
    #navbarSearchToggle {
        display: none !important;
    }
    #navbarSearchForm.navbar-search-form {
        position: static !important;
        height: auto !important;
        padding: 0 !important;
        overflow: visible !important;
        visibility: visible !important;
        pointer-events: auto !important;
    }
    body.ts-mobile-search-open #content {
        padding-top: 0 !important;
    }
}

/* ============================================================================
   §10 — TABLES
   ============================================================================ */
@media (max-width: 991.98px) {
    .table-responsive,
    .ts-table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
    }
    .page-content table:not(.no-scroll):not(.ts-keep-inline) {
        display: block;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter,
    .dataTables_wrapper .dataTables_info,
    .dataTables_wrapper .dataTables_paginate {
        font-size: 0.8rem;
        padding: 0.25rem 0.5rem;
    }
    .dataTables_wrapper .dataTables_filter input {
        min-height: 36px;
        font-size: var(--ts-input-font);
    }
}

/* ============================================================================
   §11 — FORMS
   ============================================================================ */
@media (max-width: 991.98px) {
    .form-control,
    .form-select,
    textarea.form-control,
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="tel"],
    input[type="number"],
    input[type="date"],
    input[type="time"],
    input[type="search"],
    input[type="url"],
    select {
        font-size: var(--ts-input-font) !important;
        min-height: var(--ts-touch-target);
        padding: 0.5rem 0.75rem;
        border-radius: var(--ts-radius);
    }
    .btn {
        min-height: var(--ts-touch-target);
        padding: 0.5rem 0.9rem;
        font-size: 0.9rem;
    }
    .btn-sm {
        min-height: 36px;
        padding: 0.35rem 0.7rem;
    }
    .input-group {
        flex-wrap: nowrap;
    }
    .form-check-label {
        min-height: var(--ts-touch-target);
        display: inline-flex;
        align-items: center;
    }
    .form-check-input {
        width: 1.25rem;
        height: 1.25rem;
        margin-top: 0;
    }
}

@media (max-width: 575.98px) {
    .row.g-3 > [class*="col-"] {
        flex: 0 0 100%;
        max-width: 100%;
    }
    .modal-dialog {
        margin: 0.5rem;
    }
    .modal-content {
        border-radius: var(--ts-radius);
    }
}

/* ============================================================================
   §12 — CARDS, STAT GRIDS, BUTTON GROUPS, MODALS
   ============================================================================ */
@media (max-width: 991.98px) {
    .row > .col-6.col-md-4.col-xl-2,
    .row > .col-6.col-md-3,
    .row > .col-6.col-md-4 {
        flex: 0 0 50%;
        max-width: 50%;
    }
    .ts-stat-strip {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    }
    .card {
        border-radius: var(--ts-radius);
    }
    .card-header,
    .card-body {
        padding: 0.75rem 1rem;
    }
    .btn-group {
        flex-wrap: wrap;
    }
    .d-flex.gap-2.flex-wrap,
    .ts-header-actions {
        flex-wrap: wrap !important;
        gap: 0.4rem !important;
    }
}

@media (max-width: 575.98px) {
    .row > .col-6.col-md-4.col-xl-2,
    .row > .col-6.col-md-3,
    .row > .col-6.col-md-4,
    .row > .col-6.col-md-4.col-xl-2 {
        flex: 0 0 100%;
        max-width: 100%;
    }
    .ts-stat-strip {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    .ts-stat {
        border-right: 1px solid var(--border-color);
        border-bottom: 1px solid var(--border-color);
    }
    .ts-stat:nth-child(even) {
        border-right: none;
    }
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100vw - 1rem);
    }
    .dropdown-menu {
        max-width: calc(100vw - 16px);
    }
}

/* ============================================================================
   §13 — PAGE HEADERS WITH ACTION BUTTONS
   ============================================================================ */
@media (max-width: 991.98px) {
    .d-flex.justify-content-between.align-items-center.flex-wrap,
    .d-flex.justify-content-between.align-items-center.mb-4 {
        gap: 0.5rem;
        align-items: flex-start !important;
    }
    .d-flex.justify-content-between.align-items-center.flex-wrap > h2,
    .d-flex.justify-content-between.align-items-center.mb-4 > h2 {
        font-size: 1.15rem;
        margin-bottom: 0;
    }
    .d-flex.justify-content-between.align-items-center.flex-wrap > .d-flex.gap-2,
    .d-flex.justify-content-between.align-items-center.mb-4 > .d-flex.gap-2 {
        width: 100%;
        flex-wrap: wrap;
    }
    .ts-page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    /* In column direction `flex: 1 1 240px` on .ts-header-title becomes a
       240px-tall empty box, pushing the stat chips far below the heading.
       Reset the basis so the title only takes its content height. */
    .ts-header-title {
        flex: 0 0 auto;
        width: 100%;
    }
    .ts-header-actions {
        width: 100%;
    }
}

/* ============================================================================
   §13b — PHONE HEADERS: ICON ON TOP, EVERYTHING CENTRED
   ----------------------------------------------------------------------------
   On a phone the page header kept its desktop shape: the icon stayed inline
   with the title and the block stayed left-aligned, so the title, subtitle and
   count chips were squeezed into a narrow column while the rest of the header
   sat empty on the right. Below 768px every page-level header now becomes a
   centred stack:

       [ icon tile ]
          Title
        subtitle
      count chips
        buttons

   Applies to the shared header (.ts-page-header, most pages), the ticket
   details header (.td-header) and the asset details header (.ad-header) so all
   three read the same way on a phone.
   ============================================================================ */
@media (max-width: 767.98px) {
    .ts-page-header,
    .td-header,
    .ad-header {
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-align: center;
        gap: 0.7rem;
    }

    /* The title block is the only full-width child; everything else sizes to
       its content so the stack stays visually centred. */
    .ts-page-header .ts-header-title,
    .td-header > .flex-grow-1,
    .ad-header > .flex-grow-1 {
        flex: 0 0 auto;
        width: 100%;
        min-width: 0;
        text-align: center;
    }

    /* Icon, then the words underneath it. A text node inside a column flex
       container becomes its own anonymous item, so the title line breaks
       below the icon automatically. */
    .ts-page-header .ts-header-title h2,
    .td-header h2,
    .ad-header h2 {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0.4rem;
        margin: 0;
        /* !important: ticket-details.css / asset-details.css are linked after
           this file, and each page's own <style> block comes later still, so a
           plain declaration would lose to their desktop sizes. */
        font-size: 1.02rem !important;
        line-height: 1.32 !important;
        letter-spacing: 0 !important;
        font-weight: 700 !important;
    }

    .ts-page-header .ts-header-title h2 > i,
    .td-header h2 > i,
    .ad-header h2 > i {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 60px;
        height: 60px;
        margin: 0;
        border-radius: 18px;
        font-size: 1.7rem;
        line-height: 1;
        color: var(--accent-color);
        background: rgba(13, 110, 253, 0.11);
        background: color-mix(in srgb, var(--accent-color) 14%, transparent);
        border: 1px solid rgba(13, 110, 253, 0.16);
        border: 1px solid color-mix(in srgb, var(--accent-color) 22%, transparent);
    }

    .ts-page-header .ts-header-sub,
    .td-header .small.text-muted,
    .ad-header .small.text-muted {
        margin-left: auto;
        margin-right: auto;
        max-width: 40ch;
        font-size: 0.76rem !important;
        line-height: 1.55 !important;
    }

    /* Counts read as quiet metadata next to the bigger icon. */
    .ts-page-header .ts-chip-num {
        font-size: 0.92rem;
    }
    .ts-page-header .ts-chip-label {
        font-size: 0.64rem;
    }

    /* Count chips: one centred row instead of a left column. */
    .ts-page-header .ts-header-badges,
    .td-header-badges,
    .ad-header-badges {
        width: 100%;
        justify-content: center;
        row-gap: 4px;
    }

    /* Three ticket badges (status, priority, SLA) fit one phone row at this
       size; at .fs-6 the SLA badge dropped to a line of its own. */
    .td-header-badges {
        gap: 5px;
    }
    .td-header-badges .badge {
        font-size: 0.7rem !important;
        padding: 0.32em 0.6em;
        white-space: nowrap;
    }

    /* Action buttons: centred, and evenly split once they have to wrap. */
    .ts-page-header .ts-header-actions,
    .td-header-actions,
    .ad-header-actions {
        width: 100%;
        justify-content: center;
    }
    .ts-page-header .ts-header-actions > .btn,
    .td-header-actions > .btn,
    .ad-header-actions > .btn {
        flex: 1 1 auto;
    }

    /* ------------------------------------------------------------------
       The three dashboards and the notifications page build their own hero
       header instead of ts_page_header(). Same phone treatment: centred
       stack, icon tile on top, meta line and buttons underneath.
       ------------------------------------------------------------------ */
    .admin-hero,
    .personnel-hero,
    .client-hero,
    .container-fluid > .d-flex.justify-content-between.align-items-center.mb-4 {
        flex-direction: column;
        align-items: center !important;
        text-align: center;
        gap: 0.6rem;
    }
    .admin-hero > div,
    .personnel-hero > div,
    .client-hero > div,
    .container-fluid > .d-flex.justify-content-between.align-items-center.mb-4 > h2 {
        width: 100%;
    }

    .admin-hero h2,
    .personnel-hero h2,
    .client-hero h2,
    .container-fluid > .d-flex.justify-content-between.align-items-center.mb-4 > h2 {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0.4rem;
        margin: 0;
        font-size: 1rem !important;
        line-height: 1.32 !important;
        letter-spacing: 0 !important;
        font-weight: 700 !important;
    }

    .admin-hero h2 > i,
    .personnel-hero h2 > i,
    .client-hero h2 > i,
    .container-fluid > .d-flex.justify-content-between.align-items-center.mb-4 > h2 > i {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 60px;
        height: 60px;
        margin: 0;
        border-radius: 18px;
        font-size: 1.65rem;
        line-height: 1;
        background: rgba(13, 110, 253, 0.11);
        background: color-mix(in srgb, var(--accent-color) 14%, transparent);
        border: 1px solid rgba(13, 110, 253, 0.16);
        border: 1px solid color-mix(in srgb, var(--accent-color) 22%, transparent);
    }

    /* Meta line (“November 25, 2026 · System overview”) and the hero buttons. */
    .admin-hero .hero-meta,
    .personnel-hero .hero-meta,
    .client-hero .hero-meta {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: center;
        row-gap: 2px;
        font-size: 0.74rem !important;
    }
    .admin-hero > .d-flex,
    .personnel-hero > .d-flex,
    .client-hero > .d-flex,
    .container-fluid > .d-flex.justify-content-between.align-items-center.mb-4 > .d-flex {
        width: 100%;
        justify-content: center !important;
        flex-wrap: wrap;
    }

    /* ------------------------------------------------------------------
       My Queue — the Critical banner pairs a long sentence with a button on
       the same row, which squeezed both on a phone. Stack and centre it, and
       let the buttons take the row. Same for the High-priority banner.
       ------------------------------------------------------------------ */
    .ts-q-page .ts-q-banner-head {
        flex-direction: column;
        align-items: center !important;
        justify-content: center !important;
        text-align: center;
        gap: 0.5rem;
    }
    .ts-q-page .ts-q-banner-head > div {
        justify-content: center;
        flex-wrap: wrap;
    }
    .ts-q-page .ts-q-banner-head .btn {
        width: 100%;
    }

    /* Three tabs on a narrow screen: scroll sideways instead of wrapping into
       a ragged two-line block. */
    .ts-q-page .nav-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .ts-q-page .nav-tabs::-webkit-scrollbar {
        display: none;
    }
    .ts-q-page .nav-tabs .nav-link {
        white-space: nowrap;
        padding: 0.5rem 0.55rem;
        font-size: 0.8rem;
    }
}

/* ============================================================================
   §13c — CLIENT DASHBOARD: RECENT TICKET ROWS
   ----------------------------------------------------------------------------
   Each row is priority rail + title block + status/actions. On a phone the
   action group (status badge + rate + view) pushed past the card edge, so the
   view button was clipped. The row now wraps: title block on the first line,
   actions right-aligned on the second, with the coloured rail running down
   both.
   ============================================================================ */
@media (max-width: 575.98px) {
    .client-ticket-row {
        flex-wrap: wrap;
        row-gap: 8px;
        gap: 10px;
        padding: 12px 12px;
    }
    .ctr-body {
        flex: 1 1 calc(100% - 25px);
    }
    .ctr-actions {
        flex: 1 1 100%;
        justify-content: flex-end;
        padding-left: 15px;
    }
    .ctr-actions .badge {
        margin-right: auto;
    }
}

/* Very narrow phones: let the buttons fill the row instead of shrinking to
   unreadable two-word labels. */
@media (max-width: 420px) {
    .ts-page-header .ts-header-actions > .btn,
    .td-header-actions > .btn,
    .ad-header-actions > .btn {
        flex: 1 1 100%;
    }
}

/* ============================================================================
   §14 — SAFE AREAS
   ============================================================================ */
@supports (padding: max(0px)) {
    body {
        padding-left:  env(safe-area-inset-left, 0);
        padding-right: env(safe-area-inset-right, 0);
    }
    .sidebar {
        padding-bottom: env(safe-area-inset-bottom, 0);
    }
}

/* ============================================================================
   §15 — DARK / LIGHT THEME OVERRIDES
   ============================================================================ */
[data-theme="dark"] body,
[data-bs-theme="dark"] body {
    background: var(--bg-body);
}
[data-theme="dark"] #navbarSearchForm.navbar-search-form,
[data-bs-theme="dark"] #navbarSearchForm.navbar-search-form {
    background: var(--bg-card, #161b22);
    border-bottom-color: var(--border-color, #30363d);
}
[data-theme="dark"] #navbarSearchForm .form-control,
[data-bs-theme="dark"] #navbarSearchForm .form-control {
    background: var(--bg-input, #0d1117);
    color: var(--text-primary, #f0f6fc);
    border-color: var(--border-color, #30363d);
}
[data-theme="dark"] #navbarSearchToggle,
[data-bs-theme="dark"] #navbarSearchToggle {
    color: var(--text-primary, #f0f6fc);
}
[data-theme="dark"] .sidebar-overlay,
[data-bs-theme="dark"] .sidebar-overlay {
    background: rgba(0, 0, 0, 0.65);
}

/* ============================================================================
   §16 — PRINT
   ============================================================================ */
@media print {
    #sidebarOverlay,
    .sidebar-overlay,
    #navbarSearchToggle,
    #navbarSearchForm,
    #tsSidebarFloat {
        display: none !important;
    }
    body.sidebar-open {
        position: static !important;
        overflow: visible !important;
    }
    #content {
        padding-top: 0 !important;
        margin: 0 !important;
        width: 100% !important;
    }
}

/* ============================================================================
   §17 — BURGER Z-ORDER + OFF-CANVAS SAFETY NET
   ============================================================================ */
#sidebarCollapse {
    position: relative;
    z-index: 1060;
    pointer-events: auto !important;
}

@media (min-width: 992px) {
    #content #sidebarCollapse {
        position: relative;
        z-index: 1060;
    }
}

@media (max-width: 991.98px) {
    #sidebarCollapse {
        z-index: 1060;
    }
    #sidebar:not(.sidebar-drawer-open) {
        transform: translateX(-100%) !important;
        pointer-events: none !important;
    }
    #sidebar.sidebar-drawer-open {
        transform: translateX(0) !important;
        pointer-events: auto !important;
    }
}

/* ============================================================================
   §18 — FLOATING SIDEBAR TOGGLE (#tsSidebarFloat)
   ----------------------------------------------------------------------------
   Always-visible circular button, bottom-left, above every other element.
   Works on every page and every breakpoint. On desktop toggles the sidebar
   collapse; on mobile opens/closes the drawer. Uses the theme accent color.
   ============================================================================ */
#tsSidebarFloat {
    position: fixed;
    left: 16px;
    bottom: 88px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: none;
    background: var(--accent-color, #0d6efd);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
    z-index: 1061;
    cursor: pointer;
    transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    padding: 0;
    line-height: 1;
}

#tsSidebarFloat:hover {
    background: var(--accent-color-dark, #0a58ca);
    transform: scale(1.06);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.32);
}

#tsSidebarFloat:active {
    transform: scale(0.95);
}

#tsSidebarFloat:focus {
    outline: none;
    box-shadow: 0 0 0 4px rgba(var(--accent-color-rgb, 13, 110, 253), 0.35),
                0 6px 18px rgba(0, 0, 0, 0.28);
}

#tsSidebarFloat i {
    transition: transform 0.2s ease;
    pointer-events: none;
}

#tsSidebarFloat.is-open i {
    transform: rotate(90deg);
}

#tsSidebarFloat .ts-float-tooltip {
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    font-size: 0.7rem;
    padding: 4px 10px;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
}

#tsSidebarFloat:hover .ts-float-tooltip {
    opacity: 1;
}

@media (max-width: 991.98px) {
    #tsSidebarFloat {
        left: 14px;
        bottom: 84px;
        width: 56px;
        height: 56px;
        font-size: 1.3rem;
    }
    #tsSidebarFloat .ts-float-tooltip {
        display: none;
    }
}

@supports (padding: env(safe-area-inset-bottom)) {
    #tsSidebarFloat {
        bottom: calc(88px + env(safe-area-inset-bottom, 0));
    }
    @media (max-width: 991.98px) {
        #tsSidebarFloat {
            bottom: calc(84px + env(safe-area-inset-bottom, 0));
        }
    }
}

/* ============================================================================
   §19 — MOBILE BURGER HARD-KILL Z-ORDER FIX
   ----------------------------------------------------------------------------
   On mobile the left sidebar is position:fixed at left:0 with z-index:1040.
   The navbar (Bootstrap) is z-index:1030. The burger sits inside the navbar.
   Even when the drawer is CLOSED and off-screen, the sidebar's stacking
   context can still intercept taps on the burger.

   Fix:
     - Raise the navbar (and everything inside it) to z-index 1055 on mobile
     - Raise the burger itself to 1060 on mobile
     - Force the closed drawer to pointer-events:none AND visibility:visible
       so no invisible hit-area remains
     - Force the drawer contents to pointer-events:none when closed
   ============================================================================ */
   @media (max-width: 991.98px) {

    /* Raise the whole navbar above the sidebar */
    #content > .navbar,
    .navbar.navbar-expand-lg {
        position: relative !important;
        z-index: 1055 !important;
    }

    /* Raise the burger above the navbar */
    #sidebarCollapse {
        position: relative !important;
        z-index: 1060 !important;
        pointer-events: auto !important;
        cursor: pointer !important;
        isolation: isolate;
    }
    #sidebarCollapse,
    #sidebarCollapse * {
        pointer-events: auto !important;
    }

    /* The closed drawer is INERT: nothing inside it can receive taps.
       It only becomes interactive when .sidebar-drawer-open is added. */
    #sidebar:not(.sidebar-drawer-open) {
        pointer-events: none !important;
    }
    #sidebar:not(.sidebar-drawer-open) * {
        pointer-events: none !important;
    }

    #sidebar.sidebar-drawer-open {
        pointer-events: auto !important;
    }
    #sidebar.sidebar-drawer-open * {
        pointer-events: auto !important;
    }

    /* Floating toggle: make sure it is above everything */
    #tsSidebarFloat {
        z-index: 1062 !important;
        pointer-events: auto !important;
    }
}
