/* ==========================================================================
   WISAXIS AI RESUME ASSISTANT CHAT — MOBILE STYLES (2026 SaaS)
   ========================================================================== */

/* Full mobile layout lock and viewport matching */
body.chat-page {
    overflow: hidden !important;
    position: fixed;
    width: 100%;
    height: 100vh;
    height: 100dvh;
}

.chat-container {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    gap: 0.5rem;
    padding: calc(var(--mobile-navbar-height, 64px) + 0.5rem) 0.5rem calc(0.5rem + env(safe-area-inset-bottom, 0px));
    height: 100vh;
    height: 100dvh;
    box-sizing: border-box;
}

/* Transform Sidebar into an elegant floating horizontal pill-row */
.chat-sidebar {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    flex-direction: row !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    padding: 0.25rem 0.25rem !important;
    gap: 0.5rem !important;
    height: auto !important;
    border-radius: 0 !important;
    align-items: center !important;
    white-space: nowrap;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.chat-sidebar::-webkit-scrollbar {
    display: none;
}

.sidebar-title,
.assistant-info-box,
.sidebar-section h4 {
    display: none !important;
}

.sidebar-section {
    display: flex !important;
    flex-direction: row !important;
    gap: 0.5rem !important;
    width: auto !important;
}

.suggestion-pill {
    background: var(--surface-card);
    border: 1px solid var(--border-default);
    padding: 0.5rem 0.95rem;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: var(--radius-full);
    white-space: nowrap;
    display: inline-block;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
    min-height: 34px;
    -webkit-tap-highlight-color: transparent;
}

.suggestion-pill:hover,
.suggestion-pill:active {
    transform: scale(0.96);
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}

/* Chat window mobile adaptation */
.chat-window {
    border-radius: var(--radius-lg);
    height: 100%;
    box-shadow: var(--shadow-sm);
}

.chat-header {
    padding: 0.75rem 1rem;
    background: var(--surface-header);
    border-bottom: 1px solid var(--border-default);
}

.assistant-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    font-size: 1.1rem;
}

.assistant-name {
    font-size: 0.95rem;
    font-weight: 800;
}

.assistant-status {
    font-size: 0.7rem;
}

.btn-clear-chat {
    border-radius: var(--radius-md);
    padding: 6px 12px;
    font-size: 0.75rem;
    min-height: 34px;
}

/* Message pane bounds and scaling */
.chat-messages {
    padding: 1rem 0.75rem;
    gap: 1.25rem;
}

.chat-bubble-wrap {
    max-width: 90%;
    gap: 8px;
}

.bubble-icon {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
}

.chat-bubble {
    padding: 0.85rem 1rem;
    font-size: 0.88rem;
    line-height: 1.55;
    border-radius: var(--radius-lg);
}

.chat-bubble code {
    font-size: 0.8rem;
    padding: 1px 4px;
}

.chat-bubble pre {
    padding: 0.85rem;
    border-radius: var(--radius-md);
    margin: 8px 0;
}

/* Action widgets position */
.bubble-actions {
    bottom: -22px;
}

.btn-bubble-action {
    padding: 2px 8px;
    font-size: 0.68rem;
    min-height: 24px;
}

/* Input Area Float */
.chat-input-area {
    padding: 0.75rem 0.75rem calc(0.75rem + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--border-default);
    background: var(--surface-paper);
}

.chat-form {
    display: flex;
    gap: 8px;
    align-items: center;
}

.chat-input-wrapper {
    flex: 1;
}

.chat-input {
    width: 100%;
    padding: 10px 14px;
    font-size: 16px !important; /* Strictly 16px to prevent iOS auto-zoom */
    height: 46px;
    border-radius: var(--radius-md);
    box-sizing: border-box;
}

.chat-submit-btn {
    width: 46px;
    height: 46px;
    min-width: 46px;
    min-height: 46px;
    border-radius: var(--radius-md);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}

.chat-submit-btn:active {
    transform: scale(0.94);
}

/* ===== SCROLL SNAP ON PROMPT PILLS ===== */
.chat-sidebar {
    scroll-snap-type: x mandatory !important;
    -ms-overflow-style: none;
}

.suggestion-pill {
    scroll-snap-align: start;
    flex-shrink: 0 !important;
}

/* ===== CODE BLOCKS INSIDE MESSAGES ===== */
.chat-bubble pre {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    max-width: calc(100vw - 100px);
}

.chat-bubble pre code {
    font-size: 0.75rem;
    white-space: pre;
}

/* ===== USER BUBBLE ALIGNMENT ===== */
.chat-bubble-wrap.user {
    max-width: 85%;
}

.chat-bubble-wrap.user .chat-bubble {
    border-radius: var(--radius-lg) var(--radius-lg) var(--radius-sm) var(--radius-lg);
}

.chat-bubble-wrap.assistant .chat-bubble {
    border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) var(--radius-sm);
}

/* ===== ULTRA-NARROW CHAT (≤380px) ===== */
@media (max-width: 380px) {
    .chat-container {
        padding: calc(var(--mobile-navbar-height, 64px) + 4px) 4px calc(4px + env(safe-area-inset-bottom, 0px));
        gap: 4px;
    }

    .suggestion-pill {
        padding: 0.4rem 0.75rem;
        font-size: 0.7rem;
        min-height: 30px;
    }

    .chat-bubble {
        padding: 0.7rem 0.85rem;
        font-size: 0.82rem;
    }

    .bubble-icon {
        width: 24px;
        height: 24px;
        font-size: 0.7rem;
    }

    .chat-input {
        height: 42px;
        padding: 8px 12px;
    }

    .chat-submit-btn {
        width: 42px;
        height: 42px;
        min-width: 42px;
        min-height: 42px;
    }

    .assistant-name {
        font-size: 0.85rem;
    }

    .btn-clear-chat {
        font-size: 0.7rem;
        padding: 5px 10px;
        min-height: 30px;
    }
}
