/* ============================================================
   MOBILE-CHAT.CSS — Telegram iOS-style chat UI
   Applied on mobile devices (≤ 768px) for the chats tab
   ============================================================ */

/* ===== DESKTOP CHAT LAYOUT (unchanged, improved) ===== */

.chat-layout {
    display: flex;
    height: 495px; /* Exact height of profileContent (400 top + 25 gap + 70 int_bottom) */
    gap: 20px; /* Розділяємо панелі на ПК */
    /* overflow removed to prevent clipping on hover translateY */
}

/* LEFT SIDEBAR: Chat list */
.chats-sidebar {
    width: 320px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    overflow: hidden;
}

/* Telegram iOS Header for Chats */
.mobile-chats-header {
    display: none; /* hidden on desktop */
}

/* Chat search */
.chat-search-container {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    background: transparent;
}

.search-icon {
    color: var(--text-muted);
    font-size: 14px;
    flex-shrink: 0;
}

.chat-search-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    outline: none;
}

.chat-search-input::placeholder {
    color: var(--text-muted);
    opacity: 0.7;
}

/* Search results */
.search-results {
    flex: 1;
    overflow-y: auto;
}

.search-results-header {
    padding: 10px 16px 6px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    font-weight: 700;
    opacity: 0.7;
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.2s ease;
    border-radius: 10px;
    margin: 2px 6px;
}

.search-result-item:hover {
    background: rgba(249,134,82,0.1);
}

.search-result-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    image-rendering: pixelated;
}

.search-result-info {
    flex: 1;
    min-width: 0;
}

.search-result-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-result-tag {
    font-size: 12px;
    color: var(--text-muted);
}

/* Chat list */
.chats-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.chats-list-header {
    padding: 10px 16px 6px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    font-weight: 700;
    opacity: 0.7;
    border-bottom: 1px solid var(--border-color);
}

.chats-items {
    flex: 1;
    overflow-y: auto;
    padding: 6px 0;
}

/* Each chat item */
.chat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.2s ease;
    position: relative;
    border-radius: 10px;
    margin: 2px 6px;
}

.chat-item:hover {
    background: rgba(249,134,82,0.08);
}

.chat-item.active {
    background: rgba(249,134,82,0.15);
}

.chat-item-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    image-rendering: pixelated;
    border: 2px solid transparent;
    transition: border-color 0.2s;
}

.chat-item.active .chat-item-avatar {
    border-color: var(--accent-color);
}

.chat-item-info {
    flex: 1;
    min-width: 0;
}

.chat-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.chat-item-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item-time {
    font-size: 11px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.chat-item-preview {
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.chat-item-badge {
    background: var(--accent-color);
    color: white;
    font-size: 11px;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    flex-shrink: 0;
}

/* Empty chats state */
.empty-chats {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    gap: 10px;
    color: var(--text-muted);
    text-align: center;
}

.empty-chats i {
    font-size: 40px;
    opacity: 0.3;
}

.empty-chats p {
    font-size: 15px;
    font-weight: 600;
}

.empty-chats span {
    font-size: 13px;
    opacity: 0.7;
}

/* RIGHT: Chat window */
.chat-window {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
}

/* No chat selected placeholder */
.no-chat-selected {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    color: var(--text-muted);
    text-align: center;
    padding: 40px;
}

.no-chat-selected i {
    font-size: 56px;
    opacity: 0.2;
}

.no-chat-selected h3 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    opacity: 0.5;
}

.no-chat-selected p {
    font-size: 14px;
    opacity: 0.5;
    max-width: 240px;
}

/* Active chat */
.active-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Chat header */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    background: transparent;
    flex-shrink: 0;
    gap: 12px;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.chat-user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    image-rendering: pixelated;
}

.chat-user-info {
    flex: 1;
    min-width: 0;
}

.chat-user-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-user-tag {
    font-size: 12px;
    color: var(--accent-color);
    font-weight: 500;
}

.chat-header-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.chat-action-btn {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 10px;
    color: var(--text-muted);
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chat-action-btn:hover {
    background: rgba(249,134,82,0.1);
    color: var(--accent-color);
    border-color: rgba(249,134,82,0.3);
}

.chat-action-btn.following {
    color: var(--accent-color);
}

/* Chat messages area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Individual messages */
.message {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    max-width: 80%;
}

.message.own {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    image-rendering: pixelated;
    flex-shrink: 0;
}

.message-content {
    display: flex;
    flex-direction: column;
    gap: 3px;
    max-width: 100%;
    align-items: flex-start; /* Витримуємо текст ліворуч замість розтягування */
}

.message.own .message-content {
    align-items: flex-end; /* Витримуємо текст праворуч для власних повідомлень */
}

.message-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 4px;
}

.message-sender {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent-color);
}

.message-time {
    font-size: 11px;
    color: var(--text-muted);
    opacity: 0.7;
}

.message-bubble {
    background: rgba(0,0,0,0.08);
    border: 1px solid var(--border-color);
    border-radius: 18px 18px 18px 4px;
    padding: 8px 14px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    word-wrap: break-word;
    position: relative;
    width: fit-content; /* Хітбокс підлаштовується під текст замість 100% ширини */
    max-width: 100%;
}

.message.own .message-bubble {
    background: var(--accent-gradient);
    border-color: transparent;
    color: white;
    border-radius: 18px 18px 4px 18px;
}

/* Message input */
.chat-input-container {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 12px 14px;
    border-top: 1px solid var(--border-color);
    background: rgba(0,0,0,0.05);
    flex-shrink: 0;
}

/* Reset styles for the new buttons */
.mobile-attach-btn,
.mobile-input-icon-btn,
.mobile-voice-btn,
.mobile-nav-search-btn {
    background: transparent;
    border: none;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    outline: none;
    cursor: pointer;
    color: var(--text-muted);
}

.message-input {
    flex: 1;
    background: rgba(0,0,0,0.08);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 10px 14px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    resize: none;
    max-height: 120px;
    overflow-y: auto;
    min-height: 40px;
    transition: border-color 0.2s;
    outline: none;
    line-height: 1.5;
}

.message-input:focus {
    border-color: rgba(249,134,82,0.5);
}

.message-input::placeholder {
    color: var(--text-muted);
    opacity: 0.7;
}

.send-message-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-gradient);
    border: none;
    color: white;
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s ease;
    box-shadow: 0 3px 10px rgba(249,134,82,0.4);
}

.send-message-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(249,134,82,0.6);
}

.send-message-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Hidden utility */
.hidden {
    display: none !important;
}

/* ============================================================
   MOBILE-SPECIFIC STYLES (≤ 768px)
   Telegram iOS Chat Look
   ============================================================ */

@media (max-width: 768px) {

    /* ---- Chat content wrapper ---- */
    #chatsContent {
        padding: 0 !important;
        margin: 0 !important;
        position: fixed;
        inset: 0;
        z-index: 9999; /* Ensure it is above the general site header/footer */
        background: var(--bg-primary);
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }
    
    /* Fix for position: fixed getting trapped inside .cabinet-main-wrapper */
    .cabinet-main-wrapper:has(#chatsContent:not(.hidden)) {
        position: static !important;
        transform: none !important;
        backdrop-filter: none !important;
        filter: none !important;
        overflow: visible !important;
    }

    #chatsContent.hidden {
        display: none !important;
    }

    /* ---- Chat layout on mobile = column stack ---- */
    .chat-layout {
        flex-direction: column;
        height: 100%;
        border-radius: 0;
        border: none;
        gap: 0;
        flex: 1;
        overflow: hidden;
    }

    /* ---- ============================================================
       MOBILE CHAT LIST SCREEN
       ============================================================ ---- */
    .chats-sidebar {
        width: 100%;
        flex: 1;
        display: flex;
        flex-direction: column;
        border-right: none;
        border-bottom: none;
        overflow: hidden;
        background: var(--bg-primary);
    }

    /* ---- Mobile Chats Header ---- */
    .mobile-chats-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 16px 16px 5px;
        background: var(--bg-primary);
        flex-shrink: 0;
    }

    .mobile-chats-title {
        font-size: 28px;
        font-weight: 700;
        margin: 0;
        color: var(--text-primary);
    }

    .mobile-chats-edit-btn {
        background: transparent;
        border: none;
        color: var(--accent-color);
        font-size: 16px;
        padding: 5px;
        cursor: pointer;
    }

    /* ---- Mobile top search bar (Telegram header style) ---- */
    .chat-search-container {
        padding: 5px 16px 10px;
        border-bottom: none;
        background: var(--bg-primary);
        box-shadow: none;
        border: none;
        margin: 0;
        border-radius: 0;
    }

    .chat-search-input {
        background: rgba(0,0,0,0.06);
        border-radius: 10px;
        height: 36px;
        font-size: 16px; /* prevents zoom on iOS */
        padding: 0 16px 0 38px;
    }
    
    .search-icon {
        left: 26px; /* Position inside input padding */
        position: absolute;
    }

    body[data-theme='dark'] .chat-search-input {
        background: rgba(255,255,255,0.08); /* slight adjust for dark theme */
    }

    /* Mobile chat list header - like Telegram "Messages" (we replaced it with mobile-chats-header) */
    .chats-list-header {
        display: none !important;
    }

    /* Chat items on mobile - larger touch targets */
    .chats-items {
        padding: 0 0 80px 0; /* bottom padding for bottom nav */
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .chat-item {
        padding: 10px 16px;
        margin: 0;
        border-radius: 0;
        border-bottom: none;
        position: relative;
        gap: 12px;
        min-height: 70px;
        background: transparent;
    }
    
    .chat-item::after {
        content: '';
        position: absolute;
        bottom: 0;
        left: 76px; /* offset for avatar */
        right: 0;
        height: 1px;
        background: rgba(0,0,0,0.05); /* very light ios-like border */
    }

    .chat-item:last-child::after {
        display: none;
    }

    body[data-theme='dark'] .chat-item::after {
        background: rgba(255,255,255,0.05);
    }

    .chat-item:hover, .chat-item:active {
        background: rgba(0,0,0,0.03);
    }

    body[data-theme='dark'] .chat-item:hover, body[data-theme='dark'] .chat-item:active {
        background: rgba(255,255,255,0.03);
    }

    .chat-item.active {
        background: rgba(249,134,82,0.1);
    }

    .chat-item-avatar {
        width: 52px;
        height: 52px;
        border: none; /* iOS has no border on avatar */
    }

    .chat-item-name {
        font-size: 16px;
        font-weight: 600;
    }

    .chat-item-time {
        font-size: 12px;
    }

    .chat-item-preview {
        font-size: 14px;
        margin-top: 3px;
    }

    .chat-item-badge {
        min-width: 22px;
        height: 22px;
        font-size: 12px;
        border-radius: 11px;
    }

    /* ====================================================
       MOBILE BOTTOM NAV BAR (Telegram iOS Style)
       ==================================================== */
    .mobile-chat-bottom-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 72px;
        background: var(--bg-navbar);
        border-top: 1px solid var(--border-color);
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0 8px;
        padding-bottom: env(safe-area-inset-bottom);
        z-index: 300;
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
    }

    .mobile-nav-center-tabs {
        display: flex;
        background: rgba(120, 120, 128, 0.12);
        border-radius: 18px;
        padding: 3px;
        flex: 1;
        margin: 0 8px;
        gap: 2px;
    }

    .mobile-nav-tab {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        padding: 6px 4px;
        border-radius: 14px;
        font-size: 10px;
        font-weight: 600;
        color: var(--text-muted);
        cursor: pointer;
        border: none;
        background: transparent;
        transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
        font-family: inherit;
        position: relative;
    }

    .mobile-nav-tab i {
        font-size: 20px;
        transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    }

    .mobile-nav-tab.active {
        background: var(--bg-card);
        color: var(--accent-color);
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    }

    .mobile-nav-tab.active i {
        transform: scale(1.1);
    }

    .mobile-nav-tab .tab-badge-count {
        position: absolute;
        top: 4px;
        right: calc(50% - 14px);
        background: #ff3b30;
        color: white;
        font-size: 10px;
        font-weight: 800;
        min-width: 16px;
        height: 16px;
        border-radius: 8px;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0 4px;
        transform: scale(0);
        transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    }

    .mobile-nav-tab .tab-badge-count.visible {
        transform: scale(1);
    }

    /* Mobile search button */
    .mobile-nav-search-btn {
        width: 44px;
        height: 44px;
        border-radius: 50%;
        background: rgba(120, 120, 128, 0.12);
        border: none;
        display: flex;
        align-items: center;
        justify-content: center;
        color: var(--text-muted);
        font-size: 18px;
        cursor: pointer;
        flex-shrink: 0;
        transition: all 0.2s ease;
    }

    .mobile-nav-search-btn:active {
        background: rgba(249,134,82,0.15);
        color: var(--accent-color);
        transform: scale(0.95);
    }

    /* ====================================================
       MOBILE ACTIVE CHAT SCREEN (Full screen like Telegram)
       ==================================================== */

    /* When chat is open, hide the sidebar */
    .chats-sidebar.mobile-hidden {
        display: none !important;
    }

    /* Chat window full screen on mobile */
    .chat-window {
        position: fixed;
        inset: 0;
        z-index: 400;
        display: flex;
        flex-direction: column;
        background: var(--bg-primary);
        transform: translateX(100%);
        transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
    }

    .chat-window.mobile-open {
        transform: translateX(0);
    }

    /* ---- Mobile Chat Header (Telegram iOS style) ---- */
    .chat-header {
        background: var(--bg-navbar);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border-bottom: 1px solid var(--border-color);
        padding: 10px 12px;
        padding-top: max(10px, env(safe-area-inset-top));
        min-height: 60px;
        box-shadow: 0 1px 8px rgba(0,0,0,0.06);
    }

    /* Back button */
    .mobile-back-btn {
        display: flex;
        align-items: center;
        gap: 4px;
        background: none;
        border: none;
        color: var(--accent-color);
        font-size: 16px;
        font-weight: 500;
        font-family: inherit;
        cursor: pointer;
        padding: 6px 4px;
        border-radius: 8px;
        flex-shrink: 0;
        transition: opacity 0.15s;
    }

    .mobile-back-btn:active {
        opacity: 0.6;
    }

    .mobile-back-btn i {
        font-size: 18px;
    }

    .mobile-back-count {
        font-size: 16px;
        font-weight: 600;
        background: rgba(120,120,128,0.18);
        border-radius: 12px;
        padding: 2px 9px;
        min-width: 28px;
        text-align: center;
    }

    /* User info in header - centred like Telegram */
    .chat-header-info {
        flex: 1;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 1px;
        cursor: pointer;
    }

    .chat-user-info {
        text-align: center;
    }

    .chat-user-name {
        font-size: 16px;
        font-weight: 700;
    }

    /* Online status replaces tag on mobile */
    .chat-user-tag {
        font-size: 12px;
        color: #30b83b;
        font-weight: 500;
    }

    /* Avatar in header */
    .chat-user-avatar {
        width: 36px;
        height: 36px;
        order: 2; /* put avatar to the right */
        flex-shrink: 0;
    }

    /* Reorder: back btn | info (centered, column) | avatar */
    .chat-header {
        flex-direction: row;
    }

    /* Chat actions (desktop icons) hidden on mobile, replaced by avatar */
    .chat-header-actions {
        display: none;
    }

    /* ---- Pinned Message Banner ---- */
    .mobile-pinned-banner {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 8px 14px;
        background: var(--bg-navbar);
        border-bottom: 1px solid var(--border-color);
        cursor: pointer;
        transition: background 0.15s;
        flex-shrink: 0;
    }

    .mobile-pinned-banner:active {
        background: rgba(249,134,82,0.07);
    }

    .mobile-pinned-accent-bar {
        width: 3px;
        align-self: stretch;
        background: var(--accent-color);
        border-radius: 2px;
        flex-shrink: 0;
    }

    .mobile-pinned-content {
        flex: 1;
        min-width: 0;
    }

    .mobile-pinned-label {
        font-size: 12px;
        font-weight: 700;
        color: var(--accent-color);
        margin-bottom: 1px;
    }

    .mobile-pinned-text {
        font-size: 13px;
        color: var(--text-secondary);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .mobile-pinned-close {
        width: 24px;
        height: 24px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: rgba(120,120,128,0.15);
        border: none;
        border-radius: 12px;
        color: var(--text-muted);
        font-size: 12px;
        flex-shrink: 0;
        cursor: pointer;
    }

    /* ---- Messages area ---- */
    .chat-messages {
        flex: 1;
        padding: 10px 12px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        background: var(--bg-primary);
    }

    /* Messages with Telegram bubble corners */
    .message {
        max-width: 75%;
    }

    .message.own {
        max-width: 75%;
    }

    .message-bubble {
        border-radius: 18px 18px 18px 6px;
        padding: 8px 12px;
        font-size: 15px;
    }

    .message.own .message-bubble {
        border-radius: 18px 18px 6px 18px;
        background: linear-gradient(135deg, #f98652, #d84315);
    }

    /* ---- Mobile Input Bar (Telegram iOS style) ---- */
    .chat-input-container {
        padding: 8px 10px;
        padding-bottom: max(10px, env(safe-area-inset-bottom));
        background: var(--bg-navbar);
        border-top: 1px solid var(--border-color);
        gap: 8px;
        box-shadow: 0 -2px 12px rgba(0,0,0,0.05);
        align-items: center;
    }

    /* Attachment button */
    .mobile-attach-btn {
        width: 36px;
        height: 36px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: transparent;
        border: none;
        color: var(--text-muted);
        font-size: 20px;
        cursor: pointer;
        flex-shrink: 0;
        border-radius: 50%;
        transition: all 0.2s;
    }

    .mobile-attach-btn:active {
        background: rgba(249,134,82,0.1);
        color: var(--accent-color);
    }

    /* Message input - Telegram pill style */
    .message-input {
        border-radius: 22px;
        padding: 9px 14px;
        font-size: 16px; /* prevents iOS zoom */
        min-height: 38px;
        max-height: 120px;
        background: var(--bg-card);
        border: 1px solid var(--border-color);
    }

    .message-input:focus {
        border-color: rgba(249,134,82,0.4);
        background: var(--bg-card);
    }

    /* Right-side input icons */
    .mobile-input-extras {
        display: flex;
        align-items: center;
        gap: 4px;
        flex-shrink: 0;
    }

    .mobile-input-icon-btn {
        width: 32px;
        height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: transparent;
        border: none;
        color: var(--text-muted);
        font-size: 17px;
        cursor: pointer;
        border-radius: 50%;
        transition: all 0.2s;
    }

    .mobile-input-icon-btn:active {
        background: rgba(249,134,82,0.1);
        color: var(--accent-color);
    }

    /* Voice/Send button */
    .send-message-btn,
    .mobile-voice-btn {
        width: 38px;
        height: 38px;
        border-radius: 50%;
        flex-shrink: 0;
    }

    .mobile-voice-btn {
        background: rgba(120,120,128,0.15);
        border: none;
        color: var(--text-muted);
        font-size: 18px;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: all 0.2s;
    }

    .mobile-voice-btn:active {
        background: rgba(249,134,82,0.15);
        color: var(--accent-color);
        transform: scale(0.95);
    }

    /* ---- No chat selected is hidden on mobile (user always in list first) ---- */
    #noChatSelected {
        display: none !important;
    }

    /* Active chat hidden until user taps a chat */
    #activeChat.hidden {
        display: none !important;
    }

    /* Fix: search results on mobile */
    .search-results {
        flex: 1;
        overflow-y: auto;
    }

    .search-result-item {
        margin: 0;
        border-radius: 0;
        padding: 12px 16px;
        border-bottom: 1px solid rgba(0,0,0,0.05);
    }

    .search-result-avatar {
        width: 48px;
        height: 48px;
    }

    /* Make chats list fill available space when on mobile */
    .chats-list {
        flex: 1;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }
}

/* ============================================================
   DESKTOP IMPROVEMENTS (> 768px)
   ============================================================ */
@media (min-width: 769px) {
    .mobile-chat-bottom-nav {
        display: none !important;
    }

    .mobile-back-btn {
        display: none !important;
    }

    /* Desktop input styles for new buttons */
    .chat-input-container {
        padding: 16px 20px;
        background: var(--bg-card);
        border-top: 1px solid var(--border-color);
        border-radius: 0 0 14px 0;
    }

    .message-input {
        background: rgba(0,0,0,0.05);
        border-radius: 20px;
        padding: 10px 16px;
    }

    .mobile-attach-btn {
        margin-right: 4px;
        color: var(--text-muted);
        opacity: 0.8;
    }
    .mobile-attach-btn:hover {
        opacity: 1;
        color: var(--text-primary);
    }

    .mobile-input-extras {
        margin-right: 4px;
    }

    .mobile-input-icon-btn {
        color: var(--text-muted);
        opacity: 0.8;
    }
    .mobile-input-icon-btn:hover {
        opacity: 1;
        color: var(--text-primary);
    }

    .mobile-voice-btn {
        color: var(--text-muted);
        opacity: 0.8;
        background: transparent;
    }
    .mobile-voice-btn:hover {
        opacity: 1;
        color: var(--accent-color);
    }

    .send-message-btn {
        display: flex; /* Always show send on desktop for now, or use JS toggle */
    }

    /* Desktop pinned banner styling */
    .mobile-pinned-banner {
        background: rgba(0,0,0,0.02);
        padding: 10px 16px;
    }
    .mobile-pinned-banner:hover {
        background: rgba(0,0,0,0.04);
    }
}
