/* ============================================
   THIKAA MOBILE UX ENHANCEMENTS
   Bottom tab bar, FAB, pull-to-refresh, swipe
   Responsive layouts for all admin pages
   Only active on <= 768px
   ============================================ */

/* =====================
   BOTTOM TAB BAR
   ===================== */
.tk-mobile-tabbar {
    display: none;
}

/* Hide top-bar bot toggle on desktop (user details panel has it) */
.tk-top-bot-toggle {
    display: none;
}

/* Hide page name badge on desktop (only shown on mobile) */
.tk-top-page-name {
    display: none;
}

/* Hide date label in top bar on mobile */
@media (max-width: 768px) {
    .tk-board .tk-conversation > .tk-top > .tk-label-date-top {
        display: none !important;
    }
}

/* Hide filter when search is expanded */
.tk-flex.tk-search-open > .tk-filter-btn {
    display: none !important;
}

@media (max-width: 768px) {
    .tk-mobile-tabbar {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 60px;
        background: white;
        border-top: 1px solid #e2e8f0;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.06);
        z-index: 9999;
        align-items: stretch;
        padding: 0;
        padding-bottom: env(safe-area-inset-bottom, 0);
    }

    /* Give main content space for bottom bar */
    .tk-mobile-enhanced .tk-admin > main {
        padding-bottom: 70px !important;
    }

    .tk-mobile-enhanced .tk-conversation .tk-editor {
        bottom: 60px !important;
    }

    .tk-tab-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        background: none;
        border: none;
        cursor: pointer;
        color: #94a3b8;
        font-family: inherit;
        transition: all 0.2s;
        position: relative;
        -webkit-tap-highlight-color: transparent;
    }

    .tk-tab-item i {
        font-size: 20px;
        transition: all 0.2s;
    }

    .tk-tab-item span {
        font-size: 10px;
        font-weight: 600;
        letter-spacing: 0.2px;
    }

    .tk-tab-item.tk-tab-active {
        color: #075E54;
    }

    .tk-tab-item.tk-tab-active i {
        transform: scale(1.1);
    }

    .tk-tab-item.tk-tab-active::before {
        content: '';
        position: absolute;
        top: 0;
        left: 25%;
        right: 25%;
        height: 3px;
        background: #075E54;
        border-radius: 0 0 3px 3px;
    }

    .tk-tab-item:active {
        background: #f8fafc;
    }

    /* Hide the top nav on mobile when tab bar is active */
    .tk-mobile-enhanced .tk-admin > .tk-header {
        /* Keep header but make it more compact */
    }
}

/* =====================
   FLOATING ACTION BUTTON
   ===================== */
.tk-mobile-fab {
    display: none;
}

@media (max-width: 768px) {
    .tk-mobile-fab {
        display: flex;
        position: fixed;
        bottom: 76px; /* above tab bar */
        right: 16px;
        width: 52px;
        height: 52px;
        border-radius: 50%;
        background: #075E54;
        color: white;
        border: none;
        box-shadow: 0 4px 16px rgba(7, 94, 84, 0.4);
        align-items: center;
        justify-content: center;
        font-size: 20px;
        cursor: pointer;
        z-index: 9998;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        -webkit-tap-highlight-color: transparent;
        animation: tkFabPop 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    }

    @keyframes tkFabPop {
        from { transform: scale(0); opacity: 0; }
        to { transform: scale(1); opacity: 1; }
    }

    .tk-mobile-fab:active {
        transform: scale(0.9);
        box-shadow: 0 2px 8px rgba(7, 94, 84, 0.3);
    }

    /* Move FAB when scrolling down */
    .tk-mobile-fab.tk-fab-hidden {
        transform: translateY(120px);
        opacity: 0;
    }
}

/* =====================
   PULL TO REFRESH
   ===================== */
.tk-pull-indicator {
    display: none;
}

@media (max-width: 768px) {
    .tk-pull-indicator {
        display: flex;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 50px;
        align-items: center;
        justify-content: center;
        gap: 8px;
        background: #f0fdf4;
        color: #075E54;
        font-size: 13px;
        font-weight: 500;
        z-index: 99999;
        transform: translateY(-60px);
        opacity: 0;
        transition: transform 0.2s, opacity 0.2s;
    }

    .tk-pull-indicator.tk-pull-ready {
        background: #dcfce7;
    }

    .tk-pull-indicator i {
        font-size: 16px;
        transition: transform 0.2s;
    }

    .tk-pull-ready i {
        transform: rotate(180deg);
    }
}

/* =====================
   SWIPE-TO-ACTION (Archive / Delete)
   WhatsApp-style: row slides, buttons revealed behind.
   Zero DOM changes to <li> — single floating panel in <ul>.
   ===================== */
@media (max-width: 768px) {

    /* Clip li content that slides past the edge */
    .tk-board > .tk-admin-list .tk-scroll-area {
        overflow-x: hidden !important;
    }

    /* Li sits above the actions panel when sliding */
    .tk-board > .tk-admin-list .tk-scroll-area li[data-conversation-id] {
        position: relative;
        z-index: 1;
    }

    /* The floating actions panel — lives in <ul>, behind li's */
    .tk-swipe-panel {
        position: absolute;
        z-index: 0;
        display: none;
        right: 0;
        width: 160px;
        gap: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
        border: none !important;
    }

    .tk-swipe-panel.tk-visible {
        display: flex;
    }

    /* Action divs — all styling is inline, CSS just for active state */
    .tk-swipe-panel > div:active {
        filter: brightness(0.85);
    }

    /* RTL: panel on the left */
    .tk-rtl .tk-swipe-panel {
        right: auto;
        left: 0;
    }

    /* Row removal */
    .tk-board > .tk-admin-list .tk-scroll-area li.tk-swipe-removing {
        transition: max-height 0.3s ease, opacity 0.25s ease;
        max-height: 0 !important;
        opacity: 0 !important;
        overflow: hidden !important;
    }
}

/* =====================
   GENERAL MOBILE IMPROVEMENTS
   ===================== */
@media (max-width: 768px) {
    /* Larger touch targets */
    .tk-mobile-enhanced .tk-btn,
    .tk-mobile-enhanced button {
        min-height: 44px;
        min-width: 44px;
    }

    /* Top bar spacing handled in conversation top bar section below */

    /* Full-width modals on mobile */
    .tk-mobile-enhanced .tk-lightbox {
        width: calc(100% - 16px) !important;
        max-width: none !important;
        left: 8px !important;
        right: 8px !important;
        transform: translate(0, -50%) !important;
    }

    /* Better conversation list on mobile */
    .tk-mobile-enhanced .tk-conversation-item {
        padding: 12px 14px;
    }

    /* Dashboard cards stack on mobile */
    .tk-mobile-enhanced .tk-dash-cards {
        grid-template-columns: 1fr 1fr;
    }

    .tk-mobile-enhanced .tk-dash-row {
        grid-template-columns: 1fr;
    }

    /* Hide dashboard on conversation view for more space */
    .tk-mobile-enhanced .tk-admin > main > .tk-dashboard {
        max-height: 400px;
        overflow-y: auto;
    }

    /* Checklist compact on mobile */
    .tk-mobile-enhanced .tk-setup-checklist {
        margin: 6px;
    }
}

/* =====================
   SAFE AREA (NOTCH) SUPPORT
   ===================== */
@supports (padding: env(safe-area-inset-bottom)) {
    .tk-mobile-tabbar {
        padding-bottom: env(safe-area-inset-bottom);
        height: calc(60px + env(safe-area-inset-bottom));
    }

    .tk-mobile-fab {
        bottom: calc(76px + env(safe-area-inset-bottom));
    }
}

/* ============================================
   MOBILE CONVERSATION VIEW

   On mobile: hide header, hide everything except
   conversations. Full-screen conversation experience.

   admin.css has panel-toggle at 429-912px but
   nothing below 429px. We handle both ranges.
   ============================================ */

@media (max-width: 768px) {

    /* ==========================================
       HIDE EVERYTHING EXCEPT CONVERSATIONS
       ========================================== */

    /* Header: gone */
    .tk-admin > .tk-header {
        display: none !important;
    }

    /* Reclaim header 60px */
    .tk-admin > main {
        padding-top: 0 !important;
    }

    /* Kill sidebar padding */
    .tk-admin {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    /* Green + FAB button: gone */
    .tk-mobile-fab {
        display: none !important;
    }

    /* <> collapse arrow buttons: gone */
    .tk-area-conversations > .tk-btn-collapse {
        display: none !important;
    }

    /* Hamburger menu in conversation top bar: hidden on mobile */
    .tk-board .tk-conversation .tk-menu-mobile {
        display: none !important;
    }

    /* ==========================================
       CONVERSATION LIST + CONVERSATION VIEW
       Full-screen panels, JS toggles tk-active
       ========================================== */

    /* Board fills the screen */
    .tk-board {
        height: 100vh !important;
    }

    /* Side panels: full-screen overlays, hidden by default */
    .tk-board > .tk-admin-list,
    .tk-board .tk-user-details {
        position: fixed !important;
        z-index: 2 !important;
        background: #fff !important;
        left: 0 !important;
        right: 0 !important;
        top: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        display: none !important;
    }

    /* Show panel when JS adds tk-active */
    .tk-board > .tk-admin-list.tk-active,
    .tk-board .tk-user-details.tk-active {
        display: flex !important;
        flex-direction: column !important;
    }

    /* User details above conversation list */
    .tk-board .tk-user-details {
        z-index: 3 !important;
    }

    /* When no conversation is selected: show list by default */
    .tk-board.tk-no-conversation > .tk-admin-list {
        display: flex !important;
        flex-direction: column !important;
    }

    /* ==========================================
       CONVERSATION AREA
       ========================================== */

    .tk-board .tk-conversation {
        width: 100% !important;
        min-width: 0 !important;
        height: 100vh !important;
    }

    /* ==========================================
       CONVERSATION TOP BAR — Full nuke & rebuild
       Layout:
         ┌─────────────────────────────────────┐
         │ Name               [● AI]    [←]    │
         │ 📱 WhatsApp · Page Name              │
         └─────────────────────────────────────┘
       ========================================== */

    /* ── NUKE: kill every inherited style ── */
    .tk-board .tk-conversation > .tk-top {
        all: unset !important;
        display: grid !important;
        grid-template-columns: 1fr auto auto !important;
        grid-template-rows: 1fr auto !important;
        align-items: center !important;
        width: 100% !important;
        padding: 10px 16px 8px !important;
        background: #fff !important;
        border-bottom: 1px solid rgba(0,0,0,.08) !important;
        column-gap: 12px !important;
        row-gap: 2px !important;
        box-sizing: border-box !important;
    }

    .tk-board .tk-conversation > .tk-top > * {
        box-sizing: border-box !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* ── HIDE: things we don't need ── */
    .tk-board .tk-conversation > .tk-top > .tk-labels,
    .tk-board .tk-conversation > .tk-top > .tk-label-date-top,
    .tk-board .tk-conversation > .tk-top > .tk-menu-mobile {
        display: none !important;
    }

    /* ── ROW 1, COL 1 — Contact name ── */
    .tk-board .tk-conversation > .tk-top > a {
        all: unset !important;
        grid-column: 1 !important;
        grid-row: 1 !important;
        font-size: 16px !important;
        font-weight: 600 !important;
        color: #111 !important;
        line-height: 22px !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
        cursor: pointer !important;
        min-width: 0 !important;
    }

    /* ── ROW 2, COL 1 — Channel / page name ── */
    .tk-board .tk-conversation > .tk-top > .tk-top-page-name {
        all: unset !important;
        display: flex !important;
        align-items: center !important;
        grid-column: 1 !important;
        grid-row: 2 !important;
        font-size: 12px !important;
        font-weight: 400 !important;
        color: #888 !important;
        line-height: 16px !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
        min-width: 0 !important;
        gap: 4px !important;
    }

    .tk-board .tk-conversation > .tk-top > .tk-top-page-name:empty,
    .tk-board .tk-conversation > .tk-top > .tk-top-page-name[data-platform=""] {
        display: none !important;
    }

    .tk-top-page-name .tk-platform-icon {
        width: 13px !important;
        height: 13px !important;
        flex-shrink: 0 !important;
        object-fit: contain !important;
        opacity: 0.65 !important;
    }

    .tk-top-page-name > span {
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }

    /* Platform accent colors */
    .tk-top-page-name[data-platform="wa"],
    .tk-top-page-name[data-platform="ww"],
    .tk-top-page-name[data-platform="wd"] { color: #25d366 !important; }
    .tk-top-page-name[data-platform="fb"] { color: #1877f2 !important; }
    .tk-top-page-name[data-platform="ig"] { color: #c13584 !important; }
    .tk-top-page-name[data-platform="tg"],
    .tk-top-page-name[data-platform="tm"] { color: #0088cc !important; }
    .tk-top-page-name[data-platform="tt"] { color: #777 !important; }
    .tk-top-page-name[data-platform="ch"],
    .tk-top-page-name[data-platform=""],
    .tk-top-page-name:not([data-platform]) { color: #999 !important; }

    /* ── ROW 1-2, COL 2 — AI toggle ── */
    .tk-board .tk-conversation > .tk-top > .tk-top-bot-toggle {
        all: unset !important;
        grid-column: 2 !important;
        grid-row: 1 / -1 !important;
        display: inline-flex !important;
        align-items: center !important;
        align-self: center !important;
        gap: 5px !important;
        height: 28px !important;
        padding: 0 10px !important;
        border-radius: 14px !important;
        cursor: pointer !important;
        flex-shrink: 0 !important;
        -webkit-tap-highlight-color: transparent !important;
        transition: opacity .15s !important;
    }

    .tk-top-bot-toggle .tk-bot-dot {
        font-size: 12px !important;
        width: auto !important;
        height: auto !important;
        border-radius: 0 !important;
        background: none !important;
        flex-shrink: 0 !important;
    }

    .tk-top-bot-toggle .tk-bot-label {
        font-size: 11px !important;
        font-weight: 700 !important;
        letter-spacing: .5px !important;
        line-height: 1 !important;
    }

    .tk-top-bot-toggle:active { opacity: .6 !important; }

    .tk-top-bot-toggle.active { background: #dcfce7 !important; }
    .tk-top-bot-toggle.active .tk-bot-dot { color: #16a34a !important; }
    .tk-top-bot-toggle.active .tk-bot-label { color: #15803d !important; }

    .tk-top-bot-toggle.paused { background: #fee2e2 !important; }
    .tk-top-bot-toggle.paused .tk-bot-dot { color: #dc2626 !important; }
    .tk-top-bot-toggle.paused .tk-bot-label { color: #b91c1c !important; }

    /* ── ROW 1-2, COL 3 — Back button ── */
    .tk-board .tk-conversation > .tk-top > .tk-btn-back {
        all: unset !important;
        grid-column: 3 !important;
        grid-row: 1 / -1 !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        align-self: center !important;
        width: 28px !important;
        height: 28px !important;
        border-radius: 50% !important;
        background: #f2f2f2 !important;
        color: #555 !important;
        font-size: 13px !important;
        flex-shrink: 0 !important;
        cursor: pointer !important;
        -webkit-tap-highlight-color: transparent !important;
        transition: background .15s !important;
    }

    .tk-board .tk-conversation > .tk-top > .tk-btn-back::before {
        transform: rotate(180deg) !important;
        display: inline-block !important;
    }

    .tk-board .tk-conversation > .tk-top > .tk-btn-back:active {
        background: #e0e0e0 !important;
    }

    /* ── RTL: override red-theme-override.css flex → keep grid ── */
    .tk-rtl .tk-board .tk-conversation > .tk-top {
        display: grid !important;
        grid-template-columns: 1fr auto auto !important;
        grid-template-rows: 1fr auto !important;
        direction: rtl !important;
        flex-direction: unset !important;
    }

    /* Reset order/margin injected by red-theme-override.css */
    .tk-rtl .tk-board .tk-conversation > .tk-top > .tk-btn-back,
    .tk-rtl .tk-board .tk-conversation > .tk-top > a,
    .tk-rtl .tk-board .tk-conversation > .tk-top > .tk-top-page-name,
    .tk-rtl .tk-board .tk-conversation > .tk-top > .tk-labels,
    .tk-rtl .tk-board .tk-conversation > .tk-top > .tk-menu-mobile,
    .tk-rtl .tk-board .tk-conversation > .tk-top > .tk-label-date-top,
    .tk-rtl .tk-board .tk-conversation > .tk-top > .tk-top-bot-toggle {
        order: unset !important;
        margin: 0 !important;
    }

    /* RTL name: right-aligned */
    .tk-rtl .tk-board .tk-conversation > .tk-top > a {
        direction: rtl !important;
        text-align: right !important;
    }

    /* RTL page name: right-aligned */
    .tk-rtl .tk-board .tk-conversation > .tk-top > .tk-top-page-name {
        direction: rtl !important;
        text-align: right !important;
    }

    /* RTL back arrow: no rotation (points left naturally) */
    .tk-rtl .tk-board .tk-conversation > .tk-top > .tk-btn-back::before {
        transform: none !important;
    }

    /* ==========================================
       EDITOR
       ========================================== */

    .tk-board .tk-conversation .tk-editor {
        margin: 0 !important;
        border-radius: 0 !important;
        border-left: none !important;
        border-right: none !important;
    }

    /* Send button: bigger touch target on mobile */
    .tk-board .tk-conversation .tk-editor div.tk-icon-send.tk-submit {
        width: 38px !important;
        height: 38px !important;
        min-width: 38px !important;
        min-height: 38px !important;
        border-radius: 50% !important;
        background: #028be5 !important;
        background-color: #028be5 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        cursor: pointer !important;
        flex-shrink: 0 !important;
        margin: 2px !important;
        padding: 0 !important;
        box-shadow: none !important;
    }
    .tk-board .tk-conversation .tk-editor div.tk-icon-send.tk-submit:before {
        color: #fff !important;
        font-size: 17px !important;
        display: inline !important;
        position: relative !important;
        background: none !important;
        background-color: transparent !important;
    }
    .tk-board .tk-conversation .tk-editor div.tk-icon-send.tk-submit:hover {
        background: #0279c8 !important;
        background-color: #0279c8 !important;
    }
    .tk-board .tk-conversation .tk-editor div.tk-icon-send.tk-submit:hover:before {
        color: #fff !important;
        background: none !important;
        background-color: transparent !important;
    }
    .tk-board .tk-conversation .tk-editor div.tk-icon-send.tk-submit:active {
        background: #0267ab !important;
        background-color: #0267ab !important;
        transform: scale(0.95);
    }
    .tk-board .tk-conversation .tk-editor div.tk-icon-send.tk-submit:active:before {
        color: #fff !important;
        background: none !important;
        background-color: transparent !important;
    }

    /* ==========================================
       MESSAGE BUBBLES: wider
       ========================================== */

    .tk-board .tk-list > .tk-right,
    .tk-board .tk-list > div:not(.tk-right) {
        max-width: calc(100% - 24px) !important;
    }

    /* ==========================================
       CONVERSATION LIST TOP BAR
       ========================================== */

    .tk-board > .tk-admin-list .tk-scroll-area {
        height: calc(100% - 55px) !important;
    }

    /* Top bar layout */
    .tk-board > .tk-admin-list .tk-top {
        padding: 6px 10px !important;
        position: relative !important;
    }

    /* Toolbar: icons evenly spaced */
    .tk-board > .tk-admin-list .tk-top .tk-flex {
        gap: 2px;
    }

    /* Uniform circular icon buttons */
    .tk-board > .tk-admin-list .tk-top .tk-filter-btn,
    .tk-board > .tk-admin-list .tk-top .tk-search-btn {
        width: 36px !important;
        height: 36px !important;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        transition: background 0.15s;
    }

    .tk-board > .tk-admin-list .tk-top .tk-filter-btn:active,
    .tk-board > .tk-admin-list .tk-top .tk-search-btn:active {
        background: rgba(0, 0, 0, 0.08) !important;
    }

    .tk-board > .tk-admin-list .tk-top .tk-filter-btn > i,
    .tk-board > .tk-admin-list .tk-top .tk-search-btn > i {
        position: static !important;
        width: auto !important;
        height: auto !important;
        font-size: 17px !important;
        line-height: 1 !important;
    }

    /* ---- SEARCH EXPANDED STATE ---- */

    /* When search is open: hide inbox dropdown + other icons, search takes full width */
    .tk-board > .tk-admin-list .tk-top.tk-search-open > .tk-select {
        display: none !important;
    }

    .tk-board > .tk-admin-list .tk-top.tk-search-open > .tk-flex {
        flex: 1;
    }

    .tk-board > .tk-admin-list .tk-top.tk-search-open .tk-filter-btn {
        display: none !important;
    }

    /* Search container when active: fill parent */
    .tk-board > .tk-admin-list .tk-top .tk-search-btn.tk-active {
        width: 100% !important;
        height: 38px !important;
        border-radius: 8px !important;
        position: relative !important;
        background: #f1f5f9 !important;
    }

    /* Search input: override absolute positioning, fill container */
    .tk-board > .tk-admin-list .tk-top .tk-search-btn.tk-active > input {
        position: relative !important;
        min-width: 0 !important;
        max-width: none !important;
        width: 100% !important;
        right: auto !important;
        left: auto !important;
        border-radius: 8px !important;
        font-size: 14px !important;
        line-height: 36px !important;
        height: 38px !important;
        padding: 0 40px 0 12px !important;
        box-sizing: border-box !important;
        background: transparent !important;
    }

    /* Search close icon: big enough touch target */
    .tk-board > .tk-admin-list .tk-top .tk-search-btn.tk-active > i {
        position: absolute !important;
        right: 0 !important;
        left: auto !important;
        top: 0 !important;
        bottom: 0 !important;
        transform: none !important;
        z-index: 5;
        width: 38px !important;
        height: 38px !important;
        display: flex !important;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        border-radius: 0 8px 8px 0;
    }

    /* RTL: search close icon on the left */
    .tk-rtl .tk-board > .tk-admin-list .tk-top .tk-search-btn.tk-active > i {
        right: auto !important;
        left: 0 !important;
        border-radius: 8px 0 0 8px;
    }

    .tk-rtl .tk-board > .tk-admin-list .tk-top .tk-search-btn.tk-active > input {
        padding: 0 12px 0 40px !important;
    }

    /* ---- FILTER EXPANDED STATE ---- */
    /* Inline overlay: same line as desktop, filter replaces top bar content */

    .tk-board > .tk-admin-list .tk-top.tk-filter-open > .tk-select {
        display: none !important;
    }

    .tk-board > .tk-admin-list .tk-top.tk-filter-open .tk-search-btn {
        display: none !important;
    }

    /* Filter-btn static so child div positions relative to .tk-top */
    .tk-board > .tk-admin-list .tk-filter-btn.tk-active {
        position: static !important;
    }

    /* Filter icon: absolute top-right corner as close button */
    .tk-board > .tk-admin-list .tk-filter-btn.tk-active > i {
        position: absolute !important;
        z-index: 15 !important;
        top: 50% !important;
        right: 10px !important;
        left: auto !important;
        transform: translateY(-50%);
        width: 30px;
        height: 30px;
        display: flex !important;
        align-items: center;
        justify-content: center;
    }

    /* Filter selects container: overlay the top bar inline */
    .tk-board > .tk-admin-list .tk-filter-btn.tk-active > div {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: auto !important;
        min-width: 0 !important;
        max-width: none !important;
        background: #fff !important;
        padding: 0 40px 0 8px !important;
        height: 100% !important;
        z-index: 10 !important;
        align-items: center;
        gap: 6px;
        overflow: visible !important;
    }

    /* Hide hidden selects */
    .tk-board > .tk-admin-list .tk-filter-btn.tk-active > div > .tk-select.tk-hide {
        display: none !important;
    }

    /* Selects: compact inline pills */
    .tk-board > .tk-admin-list .tk-filter-btn.tk-active > div > .tk-select {
        flex-shrink: 0;
        min-width: 0 !important;
        position: relative !important;
        z-index: 20 !important;
    }

    .tk-board > .tk-admin-list .tk-filter-btn.tk-active > div > .tk-select > p {
        font-size: 12px !important;
        white-space: nowrap;
        padding: 0 14px 0 0 !important;
    }

    /* Filter select dropdowns: centered on screen, not stuck to edges */
    .tk-board > .tk-admin-list .tk-filter-btn.tk-active > div > .tk-select > ul {
        position: fixed !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
        min-width: 260px !important;
        max-width: calc(100vw - 32px) !important;
        max-height: 60vh !important;
        overflow-y: auto !important;
        border-radius: 12px !important;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2) !important;
        border: 1px solid #e2e8f0 !important;
        background: #fff !important;
        z-index: 99999 !important;
        padding: 6px 0 !important;
        margin: 0 !important;
    }

    .tk-board > .tk-admin-list .tk-filter-btn.tk-active > div > .tk-select > ul li {
        padding: 12px 16px !important;
        font-size: 14px !important;
        min-height: 44px;
        display: flex !important;
        align-items: center;
        background: #fff !important;
        border-bottom: 1px solid #f1f5f9;
    }

    .tk-board > .tk-admin-list .tk-filter-btn.tk-active > div > .tk-select > ul li:last-child {
        border-bottom: none;
    }

    .tk-board > .tk-admin-list .tk-filter-btn.tk-active > div > .tk-select > ul li:active {
        background: #f1f5f9 !important;
    }

    .tk-board > .tk-admin-list .tk-filter-btn.tk-active > div > .tk-select > ul li.tk-active {
        background: #3b82f6 !important;
        color: #fff !important;
    }

    /* Backdrop when a filter select dropdown is open */
    .tk-board > .tk-admin-list .tk-filter-btn.tk-active > div > .tk-select.tk-active::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.3);
        z-index: 99998;
    }

    /* RTL: filter close icon on left */
    .tk-rtl .tk-board > .tk-admin-list .tk-filter-btn.tk-active > i {
        right: auto !important;
        left: 10px !important;
    }

    .tk-rtl .tk-board > .tk-admin-list .tk-filter-btn.tk-active > div {
        padding: 0 8px 0 40px !important;
    }

    .tk-admin-list .tk-scroll-area li .tk-profile .tk-name {
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
    }

    /* ==========================================
       MISC
       ========================================== */

    .tk-admin,
    .tk-admin > main {
        overflow-x: hidden !important;
    }

    .tk-lightbox {
        width: calc(100% - 16px) !important;
        max-width: none !important;
        left: 8px !important;
        right: 8px !important;
        margin-left: 0 !important;
    }

    /* ==========================================
       PROFILE BOX — Full nuke & rebuild
       WhatsApp-style contact info sheet
       ========================================== */

    /* ── Container: full-screen overlay ── */
    .tk-profile-box.tk-lightbox {
        all: unset !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        height: 100% !important;
        max-width: none !important;
        max-height: none !important;
        margin: 0 !important;
        padding: 0 !important;
        border: none !important;
        border-radius: 0 !important;
        transform: none !important;
        z-index: 9999999 !important;
        display: flex !important;
        flex-direction: column !important;
        background: #f3f4f6 !important;
        animation: tk-profile-slide 0.35s cubic-bezier(0.32, 0.72, 0, 1) !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
    }

    .tk-profile-box.tk-lightbox:not(.tk-active) {
        display: none !important;
    }

    /* ── Top bar: nuke & rebuild as column ── */
    .tk-profile-box .tk-top-bar {
        all: unset !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        padding: 50px 16px 0 !important;
        background: #fff !important;
        position: relative !important;
        flex-shrink: 0 !important;
        box-sizing: border-box !important;
        width: 100% !important;
    }

    /* ── Close X: absolute top-right ── */
    .tk-profile-box .tk-top-bar > div:last-child > a.tk-close {
        all: unset !important;
        position: absolute !important;
        top: 12px !important;
        right: 12px !important;
        width: 36px !important;
        height: 36px !important;
        border-radius: 50% !important;
        background: #f3f4f6 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        cursor: pointer !important;
        z-index: 2 !important;
        -webkit-tap-highlight-color: transparent !important;
    }

    .tk-profile-box .tk-top-bar > div:last-child > a.tk-close:active {
        background: #e5e7eb !important;
    }

    .tk-profile-box .tk-top-bar > div:last-child > a.tk-close i {
        font-size: 16px !important;
        color: #6b7280 !important;
    }

    /* ── Avatar: centered hero ── */
    /* Kill .tk-profile globals: position:relative, padding-left:45px, display:flex row */
    .tk-profile-box .tk-top-bar .tk-profile,
    .tk-profile-box .tk-top-bar > div:first-child {
        all: unset !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        gap: 10px !important;
        width: 100% !important;
        box-sizing: border-box !important;
        position: static !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    .tk-profile-box .tk-top-bar .tk-profile img {
        position: static !important;
        left: auto !important;
        right: auto !important;
        width: 80px !important;
        height: 80px !important;
        border-radius: 50% !important;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1) !important;
        object-fit: cover !important;
    }

    .tk-profile-box .tk-top-bar .tk-profile .tk-name,
    .tk-profile-box .tk-top-bar .tk-profile > span,
    .tk-profile-box .tk-top-bar .tk-profile span {
        position: static !important;
        display: block !important;
        font-size: 20px !important;
        font-weight: 700 !important;
        color: #111827 !important;
        margin: 0 !important;
        padding: 0 !important;
        line-height: 1.3 !important;
        text-align: center !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        max-width: 100% !important;
        letter-spacing: normal !important;
        float: none !important;
    }

    /* ── Action buttons row ── */
    .tk-profile-box .tk-top-bar > div:last-child {
        all: unset !important;
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 20px !important;
        padding: 20px 16px !important;
        width: 100% !important;
        box-sizing: border-box !important;
        flex-wrap: wrap !important;
    }

    /* Every action button: icon-only circle */
    .tk-profile-box .tk-top-bar > div:last-child > a {
        all: unset !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: 46px !important;
        height: 46px !important;
        border-radius: 50% !important;
        background: #f3f4f6 !important;
        cursor: pointer !important;
        -webkit-tap-highlight-color: transparent !important;
        transition: background 0.15s !important;
        flex-shrink: 0 !important;
        font-size: 0 !important;
        color: transparent !important;
    }

    .tk-profile-box .tk-top-bar > div:last-child > a:active {
        background: #e0e0e0 !important;
    }

    /* Icon inside button — kill absolute positioning from .tk-btn.tk-icon > i */
    .tk-profile-box .tk-top-bar > div:last-child > a i {
        position: static !important;
        left: auto !important;
        right: auto !important;
        display: inline-block !important;
        font-size: 18px !important;
        color: #4b5563 !important;
        line-height: 1 !important;
        width: auto !important;
        height: auto !important;
        padding: 0 !important;
        margin: 0 !important;
        background: none !important;
    }

    /* Accent colors */
    .tk-profile-box .tk-top-bar > div:last-child > a[data-value="whatsapp"] {
        background: #dcfce7 !important;
    }
    .tk-profile-box .tk-top-bar > div:last-child > a[data-value="whatsapp"] i {
        color: #059669 !important;
    }
    .tk-profile-box .tk-top-bar > div:last-child > a[data-value="custom_email"] {
        background: #dbeafe !important;
    }
    .tk-profile-box .tk-top-bar > div:last-child > a[data-value="custom_email"] i {
        color: #2563eb !important;
    }
    .tk-profile-box .tk-top-bar > div:last-child > a.tk-edit {
        background: #f3e8ff !important;
    }
    .tk-profile-box .tk-top-bar > div:last-child > a.tk-edit i {
        color: #7c3aed !important;
    }
    .tk-profile-box .tk-top-bar > div:last-child > a.tk-start-conversation {
        background: #e0f2fe !important;
    }
    .tk-profile-box .tk-top-bar > div:last-child > a.tk-start-conversation i {
        color: #0284c7 !important;
    }

    /* ── Main content: scrollable area ── */
    .tk-profile-box .tk-main {
        all: unset !important;
        display: flex !important;
        flex-direction: column !important;
        flex: 1 !important;
        min-height: 0 !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        background: #f3f4f6 !important;
        box-sizing: border-box !important;
    }

    .tk-profile-box .tk-main > div {
        width: 100% !important;
        height: auto !important;
        max-width: none !important;
        float: none !important;
        box-sizing: border-box !important;
        background: #fff !important;
        margin-top: 10px !important;
        padding: 16px !important;
    }

    .tk-profile-box .tk-main > div:last-child {
        margin-bottom: 10px !important;
    }

    /* Section title */
    .tk-profile-box .tk-main .tk-title {
        font-size: 12px !important;
        font-weight: 700 !important;
        color: #9ca3af !important;
        text-transform: uppercase !important;
        letter-spacing: 0.8px !important;
        margin: 0 0 12px !important;
        padding: 0 !important;
    }

    /* ── Detail list ── */
    .tk-profile-box .tk-profile-list {
        padding: 0 !important;
        margin: 0 !important;
    }

    .tk-profile-box .tk-profile-list ul {
        all: unset !important;
        display: flex !important;
        flex-direction: column !important;
        list-style: none !important;
    }

    .tk-profile-box .tk-profile-list li {
        all: unset !important;
        display: flex !important;
        align-items: center !important;
        gap: 10px !important;
        padding: 10px 0 !important;
        border-bottom: 1px solid #f3f4f6 !important;
        box-sizing: border-box !important;
    }

    .tk-profile-box .tk-profile-list li:last-child {
        border-bottom: none !important;
    }

    .tk-profile-box .tk-profile-list li > i {
        width: 32px !important;
        height: 32px !important;
        min-width: 32px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        background: #f3f4f6 !important;
        border-radius: 10px !important;
        color: #6b7280 !important;
        font-size: 14px !important;
        flex-shrink: 0 !important;
    }

    .tk-profile-box .tk-profile-list li > span {
        color: #9ca3af !important;
        font-size: 11px !important;
        flex-shrink: 0 !important;
        white-space: nowrap !important;
    }

    .tk-profile-box .tk-profile-list li > label {
        color: #111827 !important;
        font-weight: 500 !important;
        font-size: 13px !important;
        margin-left: auto !important;
        text-align: right !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
        min-width: 0 !important;
    }

    /* ── Conversations list ── */
    .tk-profile-box .tk-user-conversations {
        all: unset !important;
        display: flex !important;
        flex-direction: column !important;
        list-style: none !important;
    }

    .tk-profile-box .tk-user-conversations > li {
        padding: 12px 0 !important;
        border-bottom: 1px solid #f3f4f6 !important;
        border-left: none !important;
        border-right: none !important;
        list-style: none !important;
        position: static !important;
    }

    .tk-profile-box .tk-user-conversations > li:last-child {
        border-bottom: none !important;
    }

    .tk-profile-box .tk-user-conversations > li:first-child {
        border-top: none !important;
    }

    /* Conversation item: grid layout — avatar spans both rows */
    .tk-profile-box .tk-user-conversations .tk-conversation-item,
    .tk-profile-box .tk-user-conversations > li > div {
        display: grid !important;
        grid-template-columns: 40px 1fr !important;
        grid-template-rows: auto auto !important;
        gap: 2px 10px !important;
        align-items: center !important;
        padding: 0 !important;
        position: static !important;
        line-height: 1.4 !important;
    }

    /* Avatar: in-flow, spans both rows */
    .tk-profile-box .tk-user-conversations .tk-conversation-item > img,
    .tk-profile-box .tk-user-conversations > li > div > img {
        grid-row: 1 / -1 !important;
        grid-column: 1 !important;
        position: static !important;
        left: auto !important;
        top: auto !important;
        width: 40px !important;
        height: 40px !important;
        border-radius: 50% !important;
        object-fit: cover !important;
        display: block !important;
    }

    /* Name + time row */
    .tk-profile-box .tk-user-conversations .tk-conversation-item > div:not(.tk-message),
    .tk-profile-box .tk-user-conversations > li > div > div:not(.tk-message) {
        grid-column: 2 !important;
        grid-row: 1 !important;
        display: flex !important;
        justify-content: space-between !important;
        align-items: baseline !important;
        gap: 8px !important;
        min-width: 0 !important;
        opacity: 1 !important;
    }

    .tk-profile-box .tk-user-conversations .tk-name {
        font-size: 14px !important;
        font-weight: 600 !important;
        color: #111827 !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
        min-width: 0 !important;
        flex: 1 !important;
    }

    .tk-profile-box .tk-user-conversations .tk-time {
        font-size: 11px !important;
        color: #9ca3af !important;
        white-space: nowrap !important;
        flex-shrink: 0 !important;
        float: none !important;
        margin: 0 !important;
    }

    /* Message row */
    .tk-profile-box .tk-user-conversations .tk-message {
        grid-column: 2 !important;
        grid-row: 2 !important;
        font-size: 13px !important;
        color: #6b7280 !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
        height: auto !important;
        line-height: 1.4 !important;
    }

    /* Agent area */
    .tk-profile-box .tk-agent-area {
        padding-top: 12px !important;
    }

    /* ── RTL overrides ── */
    .tk-rtl .tk-profile-box .tk-top-bar {
        flex-direction: column !important;
    }

    .tk-rtl .tk-profile-box .tk-top-bar .tk-profile {
        flex-direction: column !important;
        align-items: center !important;
        padding: 0 !important;
    }

    .tk-rtl .tk-profile-box .tk-top-bar .tk-profile img {
        position: static !important;
    }

    .tk-rtl .tk-profile-box .tk-top-bar .tk-profile span,
    .tk-rtl .tk-profile-box .tk-top-bar .tk-profile .tk-name {
        margin: 0 !important;
        text-align: center !important;
    }

    .tk-rtl .tk-profile-box .tk-top-bar > div:last-child {
        flex-direction: row !important;
    }

    .tk-rtl .tk-profile-box .tk-top-bar > div:last-child > a {
        margin: 0 !important;
    }

    .tk-rtl .tk-profile-box .tk-top-bar > div:last-child > a.tk-close {
        right: auto !important;
        left: 12px !important;
    }

    .tk-rtl .tk-profile-box .tk-profile-list {
        padding: 0 !important;
    }

    .tk-rtl .tk-profile-box .tk-profile-list li > label {
        margin-left: 0 !important;
        margin-right: auto !important;
        text-align: left !important;
    }

    /* Slide animation */
    @keyframes tk-profile-slide {
        from { transform: translateY(100%); }
        to { transform: translateY(0); }
    }

    .bot-toggle-btn {
        min-height: 48px !important;
        font-size: 15px !important;
    }

    /* Hide suggestions on mobile (unless .tk-mobile-suggestions-on is set on body) */
    body:not(.tk-mobile-suggestions-on) .tk-board .tk-conversation .tk-editor .tk-suggestions {
        display: none !important;
    }

}

/* --- Very small phones --- */
@media (max-width: 375px) {

    .tk-board .tk-editor .tk-bar-icons > div {
        margin-right: 2px !important;
        width: 24px !important;
    }

    .tk-board .tk-list > .tk-right,
    .tk-board .tk-list > div:not(.tk-right) {
        margin-left: 4px !important;
        margin-right: 4px !important;
    }
}
