/* ==========================================================================
   Flanör — Mobile Chat layout (v3)
   - Header sticky üstte (42px)
   - Banner sticky header altında
   - Mesajlar scroll edilebilir (ortada)
   - Input (footer) FIXED bottom: 28px+safe-area (ticker'ın üstünde)
   - Ticker FIXED bottom: 0+safe-area (en altta)
   - viewport-fit=cover ile env(safe-area-inset-bottom) iOS'ta çalışır
   ========================================================================== */

@media (max-width: 768px) {
    /* Ticker mobil chat'te ALTTA, daha ince + input'un altında */
    body.chat_page .flanor-ticker {
        display: block !important;
        height: 28px !important;
        font-size: 11px !important;
        z-index: 9980 !important;
        bottom: 0 !important;
    }
    body.chat_page .flanor-ticker .flanor-ticker-track {
        line-height: 28px !important;
    }

    /* Body normal flow — sadece overflow:hidden ile sayfa scroll engellenir */
    body.chat_page {
        overflow: hidden !important;
        padding-bottom: 0 !important;
    }

    /* HEADER — Grupo'nun chat header'ı .chatbox > .header (kompakt) */
    body.chat_page .main .middle .chatbox > .header,
    body .main .middle .chatbox > .header {
        padding: 4px 10px !important;
        min-height: 42px !important;
        max-height: 42px !important;
        height: 42px !important;
        flex-shrink: 0 !important;
        position: sticky !important;
        top: 0 !important;
        z-index: 60 !important;
        background: #1E1F22 !important;
        overflow: hidden;
    }

    body.chat_page .main .middle .chatbox > .header .image,
    body.chat_page .main .middle .chatbox > .header .image > .thumbnail,
    body.chat_page .main .middle .chatbox > .header .image > .thumbnail > img,
    body.chat_page .main .middle .chatbox > .header .group_icon,
    body.chat_page .main .middle .chatbox > .header .user_image,
    body.chat_page .main .middle .chatbox > .header .user_image > img {
        width: 32px !important;
        height: 32px !important;
        max-width: 32px !important;
        max-height: 32px !important;
    }

    body.chat_page .main .middle .chatbox > .header .title,
    body .main .middle .chatbox > .header .title {
        font-size: 14px !important;
        font-weight: 700 !important;
        line-height: 1.2 !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }

    body.chat_page .main .middle .chatbox > .header .subtitle,
    body.chat_page .main .middle .chatbox > .header .description,
    body.chat_page .main .middle .chatbox > .header .last_seen {
        display: none !important;
    }

    body.chat_page .main .middle .chatbox > .header .icons span,
    body.chat_page .main .middle .chatbox > .header .icons div {
        width: 32px !important;
        height: 32px !important;
        padding: 0 !important;
    }

    body.chat_page .main .middle .chatbox > .header .icons svg {
        width: 18px !important;
        height: 18px !important;
    }

    /* Flanör chat banner sticky header'ın altında */
    body.chat_page .main .middle .chatbox > .flanor-chat-banner,
    body .main .middle .chatbox > .flanor-chat-banner {
        position: sticky !important;
        top: 42px !important;
        z-index: 55 !important;
        flex-shrink: 0 !important;
        padding: 6px 10px !important;
        font-size: 11px !important;
    }

    /* CHAT_MESSAGES — son mesaj footer+ticker'a çakılmasın diye padding-bottom */
    body.chat_page .main .middle .chatbox > .contents > .chat_messages,
    body .main .middle .chatbox > .contents > .chat_messages {
        padding-bottom: calc(112px + env(safe-area-inset-bottom)) !important;
    }

    /* FOOTER (input area) — VIEWPORT'A FIXED, ticker'ın ÜSTÜNDE */
    body.chat_page .main .middle .chatbox > .footer,
    body.chat_page .main .middle .footer,
    body .main .middle > .chatbox > .footer,
    body .main .middle .footer {
        position: fixed !important;
        bottom: calc(28px + env(safe-area-inset-bottom)) !important; /* ticker height + safe-area */
        left: 0 !important;
        right: 0 !important;
        z-index: 100 !important;
        background: #2B2D31 !important;
        border-top: 1px solid #3F4147 !important;
        padding: 8px 10px !important;
        margin: 0 !important;
        width: 100% !important;
        box-shadow: 0 -4px 14px rgba(0, 0, 0, 0.4) !important;
    }

    /* Mesaj yazma alanı — 16px iOS zoom engelle */
    body.chat_page .main .middle .footer textarea,
    body.chat_page .main .middle .footer input[type="text"],
    body .main .middle .footer textarea,
    body .main .middle .footer input[type="text"] {
        font-size: 16px !important;
        min-height: 44px !important;
        padding: 10px 14px !important;
        line-height: 1.4 !important;
        border-radius: 22px !important;
        background: #1E1F22 !important;
        color: #F2F3F5 !important;
        border: 1px solid #3F4147 !important;
    }

    /* Footer ikonları kompakt */
    body.chat_page .main .middle .footer .icons,
    body .main .middle .footer .icons {
        gap: 4px !important;
    }

    body.chat_page .main .middle .footer .icons span,
    body .main .middle .footer .icons span {
        width: 38px !important;
        height: 38px !important;
        min-width: 38px !important;
        padding: 0 !important;
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
    }

    body.chat_page .main .middle .footer .icons svg,
    body .main .middle .footer .icons svg {
        width: 22px !important;
        height: 22px !important;
    }

    /* Sticker viewport'tan taşmasın */
    body.chat_page .main .middle .chat_messages img,
    body.chat_page .main .middle .chat_messages .sticker_image {
        max-width: 200px !important;
        max-height: 200px !important;
        width: auto !important;
        height: auto !important;
    }
}

/* Tablet ek polish */
@media (min-width: 769px) and (max-width: 1024px) {
    body.chat_page .main .middle .footer textarea,
    body.chat_page .main .middle .footer input[type="text"],
    body .main .middle > .footer textarea,
    body .main .middle > .footer input[type="text"] {
        font-size: 15px !important;
        min-height: 42px !important;
    }
}
