/*
 * mobile.css - phone and tablet shell (v10.48.0)
 *
 * Loaded on every signed-in page after the layout's own inline styles.
 * Everything in here sits inside max-width media queries: at 1024px and
 * wider this file changes nothing, so the desktop is untouched.
 *
 * Plain CSS on purpose. The prebuilt Tailwind file is fixed (v2.2.19) and
 * the CDN script is only a fallback, so nothing here may depend on either.
 * Where a rule has to beat a Tailwind utility (single class, 0,1,0) it uses
 * an id or two classes; !important only where a later stylesheet (chat.css)
 * would otherwise win.
 *
 * Pieces:
 *   1. shared variables (bottom inset = tab bar height + phone safe area)
 *   2. tablets and phones (< 1024px): menu button, drawer, tab bar, room
 *      for the bar, floating things lifted above it
 *   3. phones (< 768px): compact header, 16px inputs, scrolling Quill
 *      toolbars, header panels no wider than the screen
 */

:root {
    --ws-tabbar-h: 60px;
    --ws-bottom-inset: 0px;
}

/* ------------------------------------------------------------------ */
/* Menu button, drawer, tab bar: defined at every width, shown < 1024   */
/* ------------------------------------------------------------------ */

.wsp-menu-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin-right: 6px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: #4b5563;
    cursor: pointer;
    flex: none;
    -webkit-tap-highlight-color: transparent;
}
.wsp-menu-btn:hover { background: #f3f4f6; color: #111827; }
.wsp-menu-btn:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }
.wsp-menu-btn svg { width: 24px; height: 24px; }

.wsp-drawer-root { position: fixed; inset: 0; z-index: 70; }
.wsp-drawer-root[hidden] { display: none; }
.wsp-drawer-backdrop { position: absolute; inset: 0; background: rgba(17, 24, 39, .45); }
.wsp-drawer {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(320px, 86vw);
    background: #ffffff;
    box-shadow: 0 10px 40px rgba(0, 0, 0, .25);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    outline: 0;
}
@media (prefers-reduced-motion: no-preference) {
    .wsp-drawer { animation: wsp-drawer-in .18s ease-out; }
    @keyframes wsp-drawer-in { from { opacity: .5; translate: -24px 0; } to { opacity: 1; translate: 0 0; } }
}
.wsp-drawer-head { display: flex; align-items: center; gap: 12px; padding: 14px 12px 12px 16px; border-bottom: 1px solid #e5e7eb; }
.wsp-drawer-avatar { width: 40px; height: 40px; border-radius: 50%; background: #2563eb; color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 16px; flex: none; }
.wsp-drawer-who { min-width: 0; flex: 1; }
.wsp-drawer-name { font-weight: 600; color: #111827; font-size: 15px; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wsp-drawer-role { font-size: 12px; color: #6b7280; line-height: 1.3; }
.wsp-drawer-close { width: 40px; height: 40px; border: 0; background: transparent; border-radius: 10px; color: #6b7280; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.wsp-drawer-close svg { width: 22px; height: 22px; }
.wsp-drawer-close:hover { background: #f3f4f6; color: #111827; }

/* Work session (Check In / Working) moved in from the header on phones.
   Its own markup is untouched; only its placement changes: full width,
   and the check-out panel opens inline instead of as a dropdown. */
.wsp-drawer-session { padding: 10px 16px 12px; border-bottom: 1px solid #e5e7eb; }
.wsp-drawer-session-label { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: #9ca3af; margin-bottom: 8px; }
.wsp-drawer-session #wspWorkSession { display: block; }
.wsp-drawer-session .mr-3 { margin-right: 0 !important; }
.wsp-drawer-session button[style] { width: 100%; justify-content: center; min-height: 44px; }
.wsp-drawer-session .absolute.right-0 {
    position: static !important;
    width: 100% !important;
    margin-top: 8px;
    box-shadow: none;
    border: 1px solid #e5e7eb;
}

.wsp-drawer-nav { padding: 6px 8px 8px; flex: 1; }
.wsp-drawer-group { padding: 12px 10px 4px; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: #9ca3af; }
.wsp-drawer-link {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 44px;
    padding: 8px 10px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: #1f2937;
    text-decoration: none;
    font: inherit;
    font-size: 15px;
    text-align: left;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.wsp-drawer-link svg { width: 20px; height: 20px; color: #6b7280; flex: none; }
.wsp-drawer-link:hover, .wsp-drawer-link:active { background: #f3f4f6; }
.wsp-drawer-link:focus-visible { outline: 2px solid #2563eb; outline-offset: -2px; }
.wsp-drawer-link.is-active { background: #eff6ff; color: #1d4ed8; font-weight: 600; }
.wsp-drawer-link.is-active svg { color: #1d4ed8; }
.wsp-drawer-link.is-sub { padding-left: 42px; min-height: 40px; font-size: 14px; }
.wsp-drawer-foot { border-top: 1px solid #e5e7eb; padding: 8px; }
.wsp-drawer-foot form { margin: 0; }
.wsp-drawer-version { padding: 6px 10px 4px; font-size: 11px; color: #9ca3af; }
html.wsp-drawer-open { overflow: hidden; }

.wsp-tabbar { display: none; }

/* ------------------------------------------------------------------ */
/* Tablets and phones                                                   */
/* ------------------------------------------------------------------ */
@media (max-width: 1023px) {
    :root { --ws-bottom-inset: calc(var(--ws-tabbar-h) + env(safe-area-inset-bottom, 0px)); }
    html.wsp-kb-open, html.wsp-no-tabbar { --ws-bottom-inset: 0px; }

    /* The page never scrolls sideways. `clip` (not `hidden`) keeps
       position:sticky working on the header. */
    html, body { overflow-x: clip; }

    /* Header: the desktop menu becomes the drawer. */
    #mainNav .wsp-desktop-menu { display: none; }
    .wsp-menu-btn { display: inline-flex; }
    #mainNav > div { padding-left: 12px; padding-right: 12px; }

    /* Room for the tab bar under the page. */
    #wspMain { padding-bottom: calc(var(--ws-bottom-inset) + 16px); }

    /* Floating things sit above the bar instead of under it. */
    #scrollToTopBtn { bottom: calc(var(--ws-bottom-inset) + 12px); }
    #pushEnablePrompt { bottom: calc(var(--ws-bottom-inset) + 8px); }
    .wc-launch { bottom: calc(var(--ws-bottom-inset) + 12px) !important; }
    .wc-toast { bottom: calc(var(--ws-bottom-inset) + 12px) !important; }

    /* Full-height panes shrink by the bar so their bottom row stays reachable. */
    .wc-root:not(.wc-popup) { height: calc(100dvh - 12rem - var(--ws-bottom-inset)) !important; }
    .h-\[calc\(100vh-4rem\)\] { height: calc(100dvh - 4rem - var(--ws-bottom-inset)) !important; }

    /* Team Chat page (html.wsp-chat-page, set by chat/index.php): edge to edge
       between the header (64px) and the tab bar, no page padding, no footer. */
    html.wsp-chat-page #wspMain { padding: 0 !important; }
    html.wsp-chat-page .wsp-gutter { margin-top: 0 !important; }
    html.wsp-chat-page footer { display: none; }
    html.wsp-chat-page .wc-root:not(.wc-popup) {
        height: calc(100dvh - 64px - var(--ws-bottom-inset)) !important;
        min-height: 0 !important;
        border-left: 0;
        border-right: 0;
        border-radius: 0;
        box-shadow: none;
    }

    /* Tab bar */
    .wsp-tabbar {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 40;
        display: grid;
        grid-auto-flow: column;
        grid-auto-columns: 1fr;
        height: calc(var(--ws-tabbar-h) + env(safe-area-inset-bottom, 0px));
        padding-bottom: env(safe-area-inset-bottom, 0px);
        background: rgba(255, 255, 255, .96);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        border-top: 1px solid #e5e7eb;
    }
    html.wsp-kb-open .wsp-tabbar, html.wsp-no-tabbar .wsp-tabbar { display: none; }
    .wsp-tab {
        position: relative;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        min-width: 0;
        padding: 6px 2px 4px;
        border: 0;
        background: transparent;
        color: #6b7280;
        text-decoration: none;
        font: 500 11px/1.1 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }
    .wsp-tab svg { width: 24px; height: 24px; }
    .wsp-tab span { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .wsp-tab:focus-visible { outline: 2px solid #2563eb; outline-offset: -3px; border-radius: 10px; }
    .wsp-tab.is-active { color: #1d4ed8; }
    .wsp-tab.is-active::before { content: ""; position: absolute; top: 0; left: 50%; width: 28px; height: 3px; margin-left: -14px; border-radius: 0 0 3px 3px; background: #1d4ed8; }
    .wsp-tab-badge {
        position: absolute;
        top: 3px;
        left: calc(50% + 4px);
        min-width: 18px;
        height: 18px;
        padding: 0 5px;
        border-radius: 999px;
        background: #dc2626;
        color: #fff;
        font: 700 11px/18px ui-sans-serif, system-ui, sans-serif;
        text-align: center;
    }
    .wsp-tab-dot { position: absolute; top: 7px; left: calc(50% + 8px); width: 8px; height: 8px; border-radius: 50%; background: #2563eb; }
    .wsp-tab-dot.is-wait { background: #f59e0b; }
    .wsp-tab-badge[hidden], .wsp-tab-dot[hidden] { display: none; }

    /* Impersonation banner: let the long sentence wrap. */
    .wsp-impersonation { flex-wrap: wrap; gap: 6px; padding-left: 12px !important; padding-right: 12px !important; }
}

/* ------------------------------------------------------------------ */
/* Phones                                                               */
/* ------------------------------------------------------------------ */
@media (max-width: 767px) {
    /* Compact header: these move to the drawer / tab bar on phones. */
    #mainNav .wsp-hide-phone { display: none !important; }
    #mainNav a img { max-width: 120px !important; }
    #mainNav .wsp-brand-text { font-size: 16px; max-width: 130px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: inline-block; }
    #mainNav .ml-6 { margin-left: 8px; }
    #mainNav .ml-3 { margin-left: 6px; }
    #mainNav .gs-root { margin-right: 4px; }

    /* Header panels (notifications, preferences): anchored right-0 to an icon
       that sits ~50px from the edge, a 320px panel ran off the left side. On
       phones they span the screen under the header instead. (#mainNav is the
       containing block while it is transformed, and it is full-width at the
       top, so this reads the same either way.) */
    #mainNav .w-80, #mainNav .w-72 {
        position: fixed;
        left: 8px;
        right: 8px;
        top: 68px;
        width: auto;
        max-height: calc(100dvh - 84px - var(--ws-bottom-inset));
        overflow-y: auto;
    }

    /* The floating chat bubble duplicates the Chat tab on phones. */
    .wc-launch { display: none !important; }

    /* Page gutters: 16px, once. */
    .wsp-gutter { padding-left: 16px !important; padding-right: 16px !important; }
    #wspMain { padding-left: 10px; padding-right: 10px; padding-top: 16px; }

    /* Form controls: 16px stops iPhones zooming on focus; a little taller
       for thumbs. Checkboxes, radios, sliders, colour and file inputs keep
       their own sizes. */
    input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="color"]):not([type="hidden"]),
    select,
    textarea { font-size: 16px !important; }
    input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="color"]):not([type="hidden"]),
    select { min-height: 42px; }

    /* Modal overlays: top-aligned and scrolling (the layout does this
       below 640px; this keeps it up to 767px and leaves room above the bar). */
    .fixed.inset-0.items-center {
        align-items: flex-start;
        overflow-y: auto;
        padding-top: 1rem;
        padding-bottom: calc(1rem + var(--ws-bottom-inset));
    }

    /* Rich-text toolbars scroll sideways instead of stacking into four rows. */
    .ql-toolbar.ql-snow { display: flex; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
    .ql-toolbar.ql-snow::-webkit-scrollbar { display: none; }
    .ql-toolbar.ql-snow .ql-formats { flex: none; display: inline-flex; align-items: center; }

    /* Chat page on a phone: the 520px floor made the pane taller than the screen. */
    .wc-root:not(.wc-popup) { height: calc(100dvh - 9rem - var(--ws-bottom-inset)) !important; min-height: 0 !important; }
}
