/* Hedgestone CRM — phone layout.
 *
 * Every rule here is scoped to html.is-mobile, which base.html sets only on
 * phone-size screens (under 768 px wide, or a phone held sideways). On a
 * desktop/laptop none of this applies, apart from hiding the phone-only parts.
 *
 * Inbox on a phone = one panel at a time:
 *   list  (no thread / person open)  -> the thread or texts list, full width
 *   detail (thread or person open)   -> the conversation, full width
 * Labels/filters slide in from the left (menu), contact details from the right (Info).
 */

/* ---- desktop: phone-only parts never show ---- */
html:not(.is-mobile) .m-only { display: none !important; }

/* ---- shell ---- */
.is-mobile body { overscroll-behavior-y: none; }
.is-mobile #app-shell { height: 100vh; height: 100dvh; }
.is-mobile .m-desk { display: none !important; }

/* top bar */
.is-mobile #m-head { background: #1e3a8a; height: 56px; }
.is-mobile #m-head .m-title { font-size: 17px; font-weight: 600; line-height: 1.2; }
.is-mobile #m-head .m-sub { font-size: 12px; opacity: .8; line-height: 1.2; }
.is-mobile .m-icon {
    width: 44px; height: 44px; flex-shrink: 0; border-radius: 9999px;
    display: inline-flex; align-items: center; justify-content: center; color: inherit;
    -webkit-tap-highlight-color: transparent;
}
.is-mobile .m-icon svg { width: 24px; height: 24px; }
.is-mobile .m-icon:active { background: rgba(255, 255, 255, .18); }
.is-mobile #m-sync-btn.m-busy svg { animation: m-spin 1s linear infinite; }
@keyframes m-spin { to { transform: rotate(360deg); } }

/* search row (the desktop search box is moved in here by mobile.js) */
.is-mobile #m-search-row #search-wrap { width: 100%; }
.is-mobile #m-search-row #search-input { width: 100%; font-size: 16px; padding: 9px 12px; border-radius: 8px; }
.is-mobile #m-search-row #search-results { width: 100%; max-height: 70dvh; }
.is-mobile #search-results a { padding-top: 10px; padding-bottom: 10px; }

/* ---- the two panels ---- */
.is-mobile #m-list { width: 100%; border-right: 0; }
.is-mobile #m-main { display: none; }
.is-mobile [data-mview="detail"] #m-list { display: none; }
.is-mobile [data-mview="detail"] #m-main { display: flex; width: 100%; }

/* bigger tap targets in the lists */
.is-mobile #list-tabs a { flex: 1; text-align: center; padding-top: 10px; padding-bottom: 10px; font-size: 15px; }
.is-mobile #m-list [data-thread-id] a .text-sm,
.is-mobile #m-list [data-contact-row] a .text-sm { font-size: 15px; }
.is-mobile #m-list [data-thread-id] a .text-xs,
.is-mobile #m-list [data-contact-row] a .text-xs { font-size: 13px; }
.is-mobile .thread-checkbox, .is-mobile #select-all { width: 20px; height: 20px; }
.is-mobile #m-list input[type="text"], .is-mobile #m-list textarea { font-size: 16px; padding: 8px 10px; }
.is-mobile #new-text summary { padding-top: 12px; padding-bottom: 12px; font-size: 15px; }

/* ---- left menu (labels, filters, workspace) ---- */
.is-mobile #m-drawer {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 56;
    width: min(85vw, 320px); border-right: 0;
    transform: translateX(-105%); transition: transform .22s ease;
    box-shadow: 4px 0 24px rgba(0, 0, 0, .18);
    padding-bottom: env(safe-area-inset-bottom);
}
.is-mobile.m-drawer-open #m-drawer { transform: none; }
.is-mobile #m-drawer nav { font-size: 15px; }
.is-mobile #m-drawer nav a { padding-top: 10px; padding-bottom: 10px; }

/* ---- right panel (contact details) ---- */
.is-mobile #context-panel {
    position: fixed; top: 0; bottom: 0; right: 0; z-index: 56;
    width: min(92vw, 400px); border-left: 0;
    transform: translateX(105%); transition: transform .22s ease;
    box-shadow: -4px 0 24px rgba(0, 0, 0, .18);
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
    font-size: 15px;
}
.is-mobile.m-info-open #context-panel { transform: none; }
.is-mobile #context-panel .text-xs { font-size: 13px; }
.is-mobile #context-panel input, .is-mobile #context-panel textarea, .is-mobile #context-panel select { font-size: 16px; }
.is-mobile #context-panel button { min-height: 36px; }

/* dim layer behind the menu / details / bottom sheets */
#m-backdrop {
    position: fixed; inset: 0; z-index: 55; background: rgba(15, 23, 42, .45);
    opacity: 0; pointer-events: none; transition: opacity .2s;
}
.is-mobile.m-overlay #m-backdrop { opacity: 1; pointer-events: auto; }

/* ---- open thread / person ---- */
.is-mobile .m-pad { padding-left: 10px; padding-right: 10px; }
.is-mobile #thread-head { flex-wrap: wrap; padding: 8px 10px; row-gap: 6px; }
.is-mobile #thread-head > .min-w-0 { flex-basis: 100%; }
.is-mobile #thread-head > .min-w-0 .text-sm { overflow-wrap: anywhere; font-size: 13px; }
.is-mobile #thread-head-controls { margin-left: 0; flex-wrap: wrap; flex-shrink: 1; row-gap: 6px; }
.is-mobile #thread-head-controls button, .is-mobile #thread-head-controls select { font-size: 14px; min-height: 34px; }
.is-mobile #focus-head { display: none; }          /* name + number are in the top bar */
.is-mobile .m-dup-badge { display: none; }         /* the label dropdown already shows it */
.is-mobile #start-helper { display: none; }        /* starts the helper on the PC only */
.is-mobile #middle-tabs .mtab { flex: 1; padding-top: 10px; padding-bottom: 10px; font-size: 15px; }
.is-mobile .msg-inbound .text-sm, .is-mobile .msg-outbound .text-sm, .is-mobile .person-email { font-size: 15px; }

/* reply box + text box: comfortable typing, grows as you type (mobile.js) */
.is-mobile #reply-resize-handle { display: none; }
.is-mobile #reply-body { height: 4.8em; min-height: 4.8em; max-height: 45dvh; font-size: 16px; }
.is-mobile .text-compose { font-size: 16px; min-height: 3.2em; max-height: 40dvh; resize: none !important; }
.is-mobile #reply-send-btn, .is-mobile .text-send-btn { font-size: 16px; padding: 9px 22px; }
.is-mobile #reply-recipients input { font-size: 16px; padding: 7px 8px; }
.is-mobile #reply-form, .is-mobile .text-send-form { padding-bottom: env(safe-area-inset-bottom); }
/* while typing, give the conversation the room (keyboard takes half the screen) */
.is-mobile.m-typing #thread-head, .is-mobile.m-typing #middle-tabs { display: none; }

/* text bubbles */
.is-mobile .bubble { max-width: 85%; font-size: 15px; }

/* ---- dropdown menus become bottom sheets ---- */
.is-mobile #follow-up-menu, .is-mobile #more-menu, .is-mobile #bulk-more-menu {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; width: auto; margin: 0;
    max-height: 75dvh; overflow-y: auto; z-index: 60;
    border-radius: 16px 16px 0 0; border: 0; font-size: 16px;
    box-shadow: 0 -6px 30px rgba(0, 0, 0, .2);
    padding: 6px 0 calc(8px + env(safe-area-inset-bottom));
}
.is-mobile #follow-up-menu button[type="submit"], .is-mobile #more-menu button, .is-mobile #bulk-more-menu button {
    padding-top: 13px; padding-bottom: 13px; padding-left: 20px;
}
.is-mobile #follow-up-menu .fu-grade-pill { font-size: 14px; padding: 6px 12px; }
.is-mobile #follow-up-menu input[type="date"] { font-size: 16px; padding: 6px; }

/* flash messages: full width under the top bar */
.is-mobile .flash-msg { font-size: 15px; }
.is-mobile body > .fixed.top-4.right-4 { left: 12px; right: 12px; top: 64px; }

/* ======================================================================
 * Step 2 — the other pages (Contacts, Follow-Ups, Lead Sources, Labels,
 * upload / preview / settings, CSV pull). Their top bar is the <header>
 * right inside the page's outer <div>; the Inbox's own bars are excluded.
 * ====================================================================== */
.is-mobile body > div > header:not(#m-head):not(.m-desk) {
    flex-wrap: wrap; row-gap: 8px; column-gap: 12px; padding: 10px 12px;
}
.is-mobile body > div > header:not(#m-head):not(.m-desk) > div { flex-wrap: wrap; row-gap: 6px; column-gap: 12px; }
.is-mobile body > div > header:not(#m-head):not(.m-desk) h1 { font-size: 18px; }
.is-mobile body > div > header:not(#m-head):not(.m-desk) a,
.is-mobile body > div > header:not(#m-head):not(.m-desk) select { font-size: 15px; }
.is-mobile .m-hide { display: none !important; }
.is-mobile main { padding-left: 12px !important; padding-right: 12px !important; }
/* wide tables scroll sideways inside their box instead of stretching the page */
.is-mobile main div:has(> table) { overflow-x: auto; }
.is-mobile main table td.break-all { min-width: 160px; }
.is-mobile input[type="search"], .is-mobile input[type="text"], .is-mobile input[type="number"],
.is-mobile input[type="date"], .is-mobile select, .is-mobile textarea { font-size: 16px; }
.is-mobile .m-full { width: 100% !important; flex-basis: 100%; }

/* Contacts: filters stack, each row becomes a card */
.is-mobile #contacts-filters select { flex: 1 1 45%; min-width: 0; padding-top: 8px; padding-bottom: 8px; }
.is-mobile #contacts-filters button, .is-mobile #contacts-filters #export-csv { padding: 8px 14px; font-size: 15px; }
.is-mobile table.m-cards thead { display: none; }
.is-mobile table.m-cards, .is-mobile table.m-cards tbody { display: block; }
.is-mobile table.m-cards tr { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 8px; row-gap: 2px; padding: 12px; }
.is-mobile table.m-cards td { display: block; padding: 0 !important; text-align: left !important; order: 2; }
.is-mobile .m-cards .c-name { order: 0; flex: 1 1 60%; min-width: 0; font-size: 16px; }
.is-mobile .m-cards .c-last { order: 1; margin-left: auto; font-size: 12px; }
.is-mobile .m-cards .c-phone, .is-mobile .m-cards .c-email { flex-basis: 100%; font-size: 14px; }
.is-mobile .m-cards .c-stage { font-size: 12px; }
.is-mobile .m-cards .c-wants { flex-basis: 100%; }
.is-mobile .m-cards .c-wants div { max-width: none; }
.is-mobile .m-cards .c-sms, .is-mobile .m-cards .c-emails { font-size: 12px; }
.is-mobile .m-cards .c-sms::before { content: "💬 "; }
.is-mobile .m-cards .c-emails::before { content: "✉ "; }
.is-mobile .m-cards td[colspan] { flex-basis: 100%; text-align: center !important; padding: 24px 0 !important; }

/* Follow-Ups: filter pills wrap */
.is-mobile .max-w-4xl.mx-auto.px-4.pt-5 { flex-wrap: wrap; }
.is-mobile .m-cards .c-type .text-gray-300 { display: none; }   /* no "—" for an unknown type */

/* phone calls (2026-10-02): the last-call chip sits with the other small facts */
.is-mobile .m-cards .c-call:empty { display: none; }
.is-mobile .m-cards .c-call .call-chip { font-size: 12px; }
.is-mobile .call-line > div { font-size: 13px; }
