/* assets/css/app-mobile.css - makes the portal feel like a phone app (only on small screens) */
#sqTabbar { display: none; }

@media (max-width: 991.98px) {
    html { -webkit-tap-highlight-color: transparent; }
    body { padding-bottom: calc(78px + env(safe-area-inset-bottom)); background: #f4f6f9; }

    /* ---------- Top app bar ---------- */
    nav.navbar { position: sticky; top: 0; z-index: 1030; padding: 8px 0 !important; box-shadow: 0 2px 12px rgba(0,0,0,.18); }
    nav.navbar .container { flex-wrap: nowrap; padding-left: 14px; padding-right: 14px; }
    nav.navbar .navbar-brand img { height: 34px !important; width: auto; }
    nav.navbar .navbar-toggler { display: none !important; }
    #navbarNav { display: flex !important; flex-basis: auto; flex-grow: 0; }
    #navbarNav .navbar-nav { flex-direction: row; align-items: center; gap: 12px; margin: 0 !important; }
    #navbarNav .navbar-nav > li { margin: 0 !important; padding: 0 !important; }
    #navbarNav .navbar-nav > li:has(#headerClock),
    #navbarNav .navbar-nav > li:has(#thumbScanner),
    #navbarNav .navbar-nav > li:has(#header-status-text) { display: none !important; }
    html, body { overflow-x: hidden; max-width: 100%; }
    #notifMenu { position: fixed !important; left: 10px !important; right: 10px !important; top: 62px !important; width: auto !important; max-width: none !important; transform: none !important; max-height: 70vh; overflow: auto; border-radius: 16px; }

    /* ---------- Bottom tab bar ---------- */
    #sqTabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1040; background: #0f1628; padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
        box-shadow: 0 -6px 24px rgba(15,22,40,.25); border-top-left-radius: 18px; border-top-right-radius: 18px; align-items: flex-end; justify-content: space-around; }
    #sqTabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; color: #94a3b8; text-decoration: none; font-size: .66rem; font-weight: 700; padding: 6px 0; border-radius: 12px; user-select: none; }
    #sqTabbar a i { font-size: 1.25rem; line-height: 1; }
    #sqTabbar a.active { color: #fcb900; }
    #sqTabbar .sq-tab-center { flex: 1.2; display: flex; flex-direction: column; align-items: center; margin-top: -26px; }
    #sqTabbar .sq-tab-center .sq-tab-clock { width: 62px; height: 62px; border-radius: 50%; background: #0f1628; border: 4px solid #f4f6f9; display: flex; align-items: center; justify-content: center; box-shadow: 0 6px 18px rgba(0,0,0,.25); overflow: hidden; }
    #sqTabbar .sq-tab-center .sq-tab-clock > * { transform: scale(.95); }
    #sqTabbar .sq-tab-center small { color: #94a3b8; font-size: .62rem; font-weight: 800; margin-top: 2px; text-align: center; line-height: 1.1; max-width: 90px; }
    #sqTabbar #header-status-text { display: none !important; }

    footer { display: none !important; }
    #sqOnline { bottom: calc(88px + env(safe-area-inset-bottom)) !important; left: 12px !important; z-index: 1035 !important; }
    #sqOnline .sq-pill { padding: 6px 10px 6px 8px; font-size: .74rem; opacity: .95; }
    #sqOnline .sq-pill small, #sqOnline .sq-stack { display: none; }

    /* ---------- General spacing ---------- */
    .container.py-5, .container.py-4 { padding-top: 18px !important; padding-bottom: 18px !important; }
    h2.fw-bold { font-size: 1.35rem; }

    /* Modals open as full-screen sheets */
    .modal-dialog { margin: 0; max-width: 100%; min-height: 100%; display: flex; align-items: flex-end; }
    .modal-content { border-radius: 20px 20px 0 0 !important; max-height: 94vh; overflow-y: auto; width: 100%; }
    .modal.fade .modal-dialog { transform: translateY(40px); }
    .modal.show .modal-dialog { transform: none; }
}

@media (max-width: 767.98px) {
    /* ---------- Task list as cards ---------- */
    #tasksTable thead { display: none; }
    #tasksTable, #tasksTable tbody { display: block; width: 100%; }
    .table-responsive:has(#tasksTable) { overflow: visible; }
    #tasksTable tr.task-row { display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: "id client action" "status status status" "desc desc desc" "date assignee assignee";
        gap: 6px 10px; padding: 14px 14px; margin: 0 0 10px; background: #fff; border-radius: 16px; box-shadow: 0 1px 3px rgba(15,22,40,.06), 0 4px 14px rgba(15,22,40,.05); align-items: center; }
    #tasksTable tr.task-row[style*="display: none"] { display: none !important; }
    #tasksTable tr.task-row > td { display: block; border: 0 !important; padding: 0 !important; background: transparent !important; }
    #tasksTable tr.task-row > td:nth-child(1) { grid-area: id; }
    #tasksTable tr.task-row > td:nth-child(2) { grid-area: date; font-size: .72rem !important; }
    #tasksTable tr.task-row > td:nth-child(2) br { display: none; }
    #tasksTable tr.task-row > td:nth-child(3) { grid-area: client; font-size: .95rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    #tasksTable tr.task-row > td:nth-child(4) { grid-area: status; }
    #tasksTable tr.task-row > td:nth-child(4) br { display: none; }
    #tasksTable tr.task-row > td:nth-child(4) .mt-1, #tasksTable tr.task-row > td:nth-child(4) > div { display: inline-block; margin: 0 4px 0 0 !important; }
    #tasksTable tr.task-row > td:nth-child(5) { grid-area: desc; font-size: .88rem; color: #334155; }
    #tasksTable tr.task-row > td:nth-child(6) { grid-area: assignee; text-align: right; font-size: .75rem; color: #64748b; }
    #tasksTable tr.task-row > td:nth-child(7) { grid-area: action; text-align: right; }
    #tasksTable tr.task-row > td:nth-child(7) .btn { padding: 4px 8px; }
    #tasksTable #noTasksMsg td { display: block; background: #fff; border-radius: 16px; }
    #taskTabs { flex-wrap: nowrap; overflow-x: auto; gap: 6px; scrollbar-width: none; }
    #taskTabs::-webkit-scrollbar { display: none; }
    #taskTabs .nav-link { white-space: nowrap; padding: 8px 14px; }

    /* ---------- Profile page ---------- */
    body[data-page="profile"] .row.g-4 { --bs-gutter-x: 10px; --bs-gutter-y: 10px; }
    body[data-page="profile"] .row.g-4 > .col-md-4 { width: 33.333%; }
    body[data-page="profile"] .row.g-4 > .col-md-4 .card { padding: 14px 6px !important; text-align: center; }
    body[data-page="profile"] .row.g-4 > .col-md-4 .fs-1 { font-size: 1.3rem !important; margin-bottom: 2px !important; }
    body[data-page="profile"] .row.g-4 > .col-md-4 h1 { font-size: 1.35rem !important; margin: 0 0 2px; }
    body[data-page="profile"] .row.g-4 > .col-md-4 p { font-size: .68rem; line-height: 1.2; }
    body[data-page="profile"] .row.g-4 > .col-md-4 a { font-size: .66rem; }
    body[data-page="profile"] .col-12 > .card.bg-brand-navy { padding: 16px !important; flex-direction: row; align-items: center; }
    body[data-page="profile"] .col-12 > .card.bg-brand-navy .user-avatar { width: 58px !important; height: 58px !important; font-size: 1.5rem !important; flex: none; }
    body[data-page="profile"] .col-12 > .card.bg-brand-navy .ms-4 { margin-left: 14px !important; }
    body[data-page="profile"] .col-12.mt-4 .card { padding: 16px !important; }
    body[data-page="profile"] canvas { max-height: 240px; }
}

/* ===== Every page on phones (v4) ===== */
@media (max-width: 767.98px) {
    /* task cards: keep the #id badge narrow so the client name gets the room */
    #tasksTable tr.task-row { grid-template-columns: max-content minmax(0, 1fr) max-content !important; grid-template-areas: "id client action" "status status status" "desc desc desc" "date date assignee" !important; }
    #tasksTable tr.task-row > td:nth-child(3) { white-space: normal !important; overflow: hidden; text-overflow: clip; display: -webkit-box !important; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.25; align-self: center; }

    main .container, main .container-fluid { padding-left: 14px; padding-right: 14px; padding-top: 1rem !important; }
    main h2 { font-size: 1.35rem; }
    /* page headers: title on top, buttons wrap underneath */
    main .d-flex.justify-content-between:has(> h1, > h2, > h3, > div > h1, > div > h2) { flex-wrap: wrap; gap: .6rem; align-items: flex-start !important; }
    main .d-flex.justify-content-between:has(> h1, > h2, > h3) > div:last-child { display: flex; flex-wrap: wrap; gap: .4rem; }
    main .d-flex.justify-content-between:has(> h1, > h2, > h3) > div:last-child .btn { margin: 0 !important; font-size: .8rem; padding: .35rem .7rem; }
    main a.btn[href="/dashboard"], main a.btn[href="dashboard"] { display: none !important; } /* the tab bar already goes home */
    main .btn { white-space: nowrap; }

    /* stat tiles two per row */
    .ts-cards { display: grid !important; grid-template-columns: 1fr 1fr !important; gap: 10px !important; }
    .ts-cards .ts-card { margin: 0 !important; min-width: 0; padding: 12px !important; }

    /* data tables become cards */
    .table-responsive:has(table.sq-cards) { overflow: visible !important; border: 0 !important; }
    *:has(> .table-responsive > table.sq-cards), *:has(> table.sq-cards) { background: transparent !important; box-shadow: none !important; border: 0 !important; padding: 0 !important; }
    table.sq-cards { border: 0 !important; min-width: 0 !important; width: 100% !important; }
    table.sq-cards thead { display: none; }
    table.sq-cards, table.sq-cards tbody, table.sq-cards tr, table.sq-cards td { display: block; width: 100% !important; }
    table.sq-cards tr { background: #fff; border: 1px solid #e9ecef; border-radius: 14px; margin: 0 0 10px; padding: 8px 14px; box-shadow: 0 1px 3px rgba(16,24,40,.05); }
    table.sq-cards tr[style*="display: none"] { display: none !important; }
    table.sq-cards > :not(caption) > * > * { background: transparent !important; box-shadow: none !important; border: 0 !important; }
    table.sq-cards td { display: flex !important; justify-content: space-between; align-items: center; gap: 12px; padding: 6px 0 !important; text-align: right; min-height: 0; white-space: normal !important; }
    table.sq-cards td + td { border-top: 1px dashed #eef0f2 !important; }
    table.sq-cards td::before { content: attr(data-label); flex: 0 0 38%; text-align: left; font-size: .68rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: #8a94a3; }
    table.sq-cards td[data-label=""]::before { display: none; }
    table.sq-cards tr { display: flex !important; flex-direction: column; position: relative; }
    table.sq-cards td.sq-title { order: -1; font-weight: 700; font-size: .95rem; text-align: left; justify-content: flex-start; padding: 2px 44px 8px 0 !important; border-top: 0 !important; }
    table.sq-cards td.sq-title + td { border-top: 0 !important; }
    table.sq-cards td.sq-title::before, table.sq-cards td.sq-num::before { display: none; }
    table.sq-cards td.sq-num { position: absolute; top: 9px; right: 14px; width: auto !important; padding: 0 !important; border: 0 !important; font-size: .7rem; font-weight: 600; color: #8a94a3; }
    table.sq-cards td.sq-num::after { content: ""; }
    table.sq-cards td > .sq-v { min-width: 0; max-width: 62%; overflow-wrap: anywhere; }
    table.sq-cards td.sq-title > .sq-v { max-width: 100%; }
    table.sq-cards td > .sq-v .text-muted, table.sq-cards td > .sq-v small { display: block; }
    table.sq-cards td .btn-group, table.sq-cards td .d-flex { flex-wrap: wrap; justify-content: flex-end; gap: 4px; }
    table.sq-cards tr.sq-full { text-align: center; }
    table.sq-cards tr.sq-full td { justify-content: center; text-align: center; }
    table.sq-cards tr.sq-full td::before { display: none; }

    /* settings: hide tab scrollbars, keep switches beside their text */
    .nav, .nav-tabs, .nav-pills, .st2-nav { scrollbar-width: none; }
    .nav::-webkit-scrollbar, .st2-nav::-webkit-scrollbar { display: none; }
    .cs-sheet { flex-wrap: wrap !important; row-gap: 8px !important; }
    .cs-sheet > :nth-child(2) { flex: 1 1 calc(100% - 56px) !important; min-width: 0; }
    .cs-sheet > :nth-child(3) { margin-left: 46px !important; }
    .su-sites { max-height: 260px !important; }
    main .nav-pills, main .nav-tabs { flex-wrap: nowrap !important; overflow-x: auto; white-space: nowrap; }
    main .nav-pills .nav-link, main .nav-tabs .nav-link { white-space: nowrap; }
    .st2-row { flex-wrap: nowrap !important; align-items: center !important; gap: 12px; }
    .st2-row > .st2-text { flex: 1 1 auto; min-width: 0; }
    .st2-row > .st2-ctl { flex: 0 0 auto; margin-left: auto; }
}