/* Chat mobile styles.
   Loaded at <=768px (same breakpoint as shell.mobile.css / other *.mobile.css files).

   Two concerns:
     1. Hide the desktop slide-in panel (#chat-panel) and its toggle button at
        mobile breakpoint — replaced by the full-screen /comms/chat page.
     2. Style the full-screen .chat-page for the mobile chat page template
        (templates/comms/chat.html).
*/

/* ===================================================================
   1. Hide desktop panel at mobile breakpoint
   =================================================================== */
@media (max-width: 768px) {
    /* Desktop slide-in panel — always hidden on mobile */
    #chat-panel {
        display: none !important;
    }

    /* Desktop toggle button — always hidden on mobile */
    .chat-toggle-btn {
        display: none !important;
    }
}

/* ===================================================================
   2. Full-screen mobile chat page (.chat-page)
      Used by templates/comms/chat.html
   =================================================================== */

/*
   On mobile the document scrolls naturally (shell.desktop.css's fixed-height
   console is min-width:769 only). On the chat route we lock .app-content to a
   viewport-fill flex column so .chat-page owns its own scroll via the message
   list instead of the page growing to content height (which left the input
   floating mid-screen). The status bar is sticky/68px; subtract it. The
   bottom-tabs (56px, fixed) are cleared by .app-content's existing
   padding-bottom from shell.mobile.css. 100dvh tracks mobile browser chrome. */
@media (max-width: 768px) {
    body.chat-route .app-content {
        /* Fill the viewport below the status bar, but never below a 480px
           floor — on very short screens the page scrolls instead of crushing
           the chat. */
        height: max(480px, calc(100dvh - var(--resource-bar-height)));
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }
}

/* .chat-page — a tac-panel-style card that fills the locked content area. */
.chat-page {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 480px;
    overflow: hidden;

    background: var(--color-bg-panel);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-panel);
}

/* ===================================================================
   Mobile tab strip — Global / Federation
   =================================================================== */
.chat-page .chat-tab-bar {
    display: flex;
    flex-shrink: 0;
    border-bottom: 1px solid var(--color-border-subtle);
    background: var(--color-bg-panel-raised);
}

.chat-page .chat-tab-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;         /* 44px touch target */
    padding: 0 var(--space-1);

    background: transparent;
    border: 0;
    border-bottom: 2px solid transparent;
    color: var(--color-text-secondary);
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 0.875rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    transition:
        color var(--transition-fast),
        border-color var(--transition-fast),
        background var(--transition-fast);
}

.chat-page .chat-tab-btn:hover {
    color: var(--color-text-primary);
    background: rgba(var(--color-accent-rgb), 0.05);
}

.chat-page .chat-tab-btn.active,
.chat-page .chat-tab-btn[aria-selected="true"] {
    color: var(--color-accent);
    border-bottom-color: var(--color-accent);
}

.chat-page .chat-tab-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* ===================================================================
   Mobile message list
   =================================================================== */
.chat-page .chat-message-list {
    flex: 1 1 auto;
    overflow-y: auto;
    min-height: 0;

    display: flex;
    flex-direction: column;
    gap: 0;

    padding: var(--space-1) 0;
    scroll-behavior: smooth;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

/* Slightly larger hit area on mobile messages */
.chat-page .chat-message {
    padding: var(--space-0-5) var(--space-2);
}

/* ===================================================================
   Mobile input row
   =================================================================== */
.chat-page .chat-input-row {
    flex-shrink: 0;
    display: flex;
    align-items: stretch;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-2);
    border-top: 1px solid var(--color-border-subtle);
    background: var(--color-bg-panel-raised);
    /* Sit above the bottom-tabs bar */
    position: relative;
    z-index: 1;
}

/* iOS prevents zoom on focus if font-size >= 16px */
.chat-page .chat-input {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 44px;
    max-height: 96px;
    padding: var(--space-1) var(--space-2);
    resize: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;

    background: var(--color-bg-input);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-control);
    color: var(--color-text-primary);
    font-family: var(--font-body);
    font-size: 16px;        /* prevents iOS auto-zoom on focus */
    line-height: 1.4;

    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.chat-page .chat-input::placeholder {
    color: var(--color-text-muted);
}

.chat-page .chat-input:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: var(--focus-ring);
}

/* Larger send button tap target on mobile */
.chat-page .chat-send-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    min-width: 44px;
    height: 44px;
    padding: 0 var(--space-1);

    background: var(--color-accent);
    border: 1px solid var(--color-accent);
    border-radius: var(--radius-control);
    color: #061021;
    cursor: pointer;
    font-weight: 600;
    transition: background var(--transition-fast), border-color var(--transition-fast);
}

.chat-page .chat-send-btn:hover {
    background: var(--color-accent-soft);
    border-color: var(--color-accent-soft);
}

.chat-page .chat-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.chat-page .chat-send-btn svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
