/* =========================================================
   URTIPUUL MESAJLAR+ (mesajlar ve bildirimler iyileştirmeleri)
   - Mobilde WhatsApp tarzı akış: önce liste, sonra tam ekran sohbet
   - "Kullanıcı Ara" altında yatay kaydırılabilen filtre çipleri
   - Grupları kişilerle aynı listede gösterme
   - Bildirim filtrelerini sadeleştirme
   ========================================================= */

/* --- Filtre çipleri (her boyutta, arama kutusunu büyütmez) --- */
.mplus-filters {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding-bottom: 2px;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
}

.mplus-filters::-webkit-scrollbar {
    display: none;
}

.mplus-chip {
    flex: 0 0 auto;
    scroll-snap-align: start;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 30px;
    padding: 0 12px;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    background: transparent;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.mplus-chip:active {
    transform: scale(0.96);
}

.mplus-chip.is-active {
    background: #1d9bf0;
    border-color: #1d9bf0;
    color: #fff;
}

.mplus-chip .mplus-chip-count {
    font-size: 11px;
    opacity: 0.75;
}

/* --- Grupları kişilerle aynı akışa sok --- */
#existing-chats {
    display: flex;
    flex-direction: column;
}

#existing-chats .mplus-group-wrap {
    display: contents !important;
}

#existing-chats .mplus-group-heading {
    display: none !important;
}

.mplus-empty {
    padding: 26px 16px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 13px;
}

/* --- Mobil sohbet: tam ekran --- */
.mplus-back-btn {
    display: none;
}

@media screen and (max-width: 768px) {

    #mesajlar .messages-container {
        display: block;
        height: calc(100vh - 65px);
        height: calc(100dvh - 65px);
        margin: 0;
        padding: 0;
        gap: 0;
        overflow: hidden;
    }

    #mesajlar .messages-container .chat-list {
        width: 100% !important;
        max-width: 100%;
        height: 100%;
        border: 0;
        border-radius: 0;
        box-shadow: none;
        padding: 8px 8px 74px;
        overflow-y: auto;
    }

    #mesajlar .user-search-container {
        padding: 10px 10px 8px !important;
        position: sticky;
        top: 0;
        z-index: 5;
        background: var(--card-bg);
    }

    /* Sohbet açıkken: tam ekran, alt barın da üstünde */
    #mesajlar .messages-container:not(.no-active-chat) .chat-area {
        position: fixed;
        inset: 0;
        z-index: 1400;
        width: 100%;
        height: 100%;
        margin: 0;
        border: 0;
        border-radius: 0;
        display: flex;
        padding-bottom: env(safe-area-inset-bottom, 0px);
        background: var(--bg-primary);
    }

    #mesajlar .messages-container.no-active-chat .chat-area {
        display: none !important;
    }

    #mesajlar .chat-area .chat-header {
        height: 58px;
        padding: 8px 12px;
        flex: 0 0 auto;
        position: sticky;
        top: 0;
        z-index: 2;
        justify-content: flex-start;
        gap: 8px;
    }

    #mesajlar .chat-area .chat-header > div:first-of-type {
        flex: 1;
        min-width: 0;
    }

    #mesajlar .chat-area .chat-header h3 {
        font-size: 16px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 62vw;
    }

    #mesajlar .chat-area .chat-messages {
        flex: 1 1 auto;
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    #mesajlar .chat-area .chat-input-area {
        flex: 0 0 auto;
    }

    .mplus-back-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 38px;
        height: 38px;
        margin-right: 2px;
        border: none;
        border-radius: 50%;
        background: transparent;
        color: var(--text-primary);
        font-size: 18px;
        cursor: pointer;
        flex: 0 0 auto;
        -webkit-tap-highlight-color: transparent;
    }

    .mplus-back-btn:active {
        background: rgba(127, 127, 127, 0.16);
    }

    /* Yazarken alanın klavye ile birlikte kayması */
    #mesajlar .chat-area.active-chat {
        min-height: 0;
    }

    /* --- Bildirim filtreleri: az ve küçük --- */
    .notifications-toolbar {
        flex-wrap: nowrap !important;
        overflow-x: auto;
        overflow-y: hidden;
        gap: 6px !important;
        padding: 8px 10px !important;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }

    .notifications-toolbar::-webkit-scrollbar {
        display: none;
    }

    .notifications-toolbar .notif-chip {
        flex: 0 0 auto;
        padding: 6px 10px !important;
        font-size: 11.5px !important;
        gap: 4px;
        white-space: nowrap;
    }

    /* Kafa karıştıran filtre mobilde gizli */
    .notifications-toolbar .notif-chip[data-filter="non-friend"] {
        display: none !important;
    }

    /* "Tümünü okundu" yalnızca ikon kalsın */
    .notifications-toolbar .notif-chip-readall {
        padding: 6px 9px !important;
    }

    .notifications-toolbar .notif-chip-readall span {
        display: none;
    }

    .notifications-shell .notifications-hero {
        padding: 14px 16px !important;
    }
}

/* =========================================================
   GÖNDERİLEN MESAJ: KÜÇÜK YÜKLEME ANİMASYONU
   Balon hemen görünür kalır; onay gelene kadar sağ altında
   minik logo döner. Onaylanınca animasyon kaybolur.
   ========================================================= */
.message.sent.mplus-sending {
    padding-bottom: 22px !important;
}

.mplus-send-spinner {
    position: absolute;
    right: 8px;
    bottom: 4px;
    width: 16px;
    height: 12px;
    opacity: .85;
    pointer-events: none;
    display: inline-block;
}

.mplus-send-spinner .urti-mini-loader__svg {
    width: 100%;
    height: 100%;
}

/* Animasyon betiği yüklenmezse sade minik halka */
.mplus-send-spinner--css {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    border: 1.6px solid rgba(255, 255, 255, .35);
    border-top-color: #fff;
    animation: mplus-spin .7s linear infinite;
}

@keyframes mplus-spin { to { transform: rotate(360deg); } }

/* Giriş alanının sağ altında, gönderim sürerken görünen minik gösterge */
.mplus-send-status {
    position: absolute;
    right: 10px;
    bottom: 2px;
    width: 15px;
    height: 11px;
    opacity: 0;
    visibility: hidden;
    transition: opacity .15s ease;
    pointer-events: none;
}

.mplus-send-status.is-on {
    opacity: .8;
    visibility: visible;
}

.mplus-send-failed {
    box-shadow: 0 0 0 1.5px rgba(237, 73, 86, .7) !important;
}

/* Gönderim göstergesi giriş alanına göre konumlansın */
#mesajlar .chat-input-area { position: relative; }

/* ------------------------------------------------------------------
   DÜZELTME: gönderim animasyonu YALNIZCA balonun sağ altında olsun.
   Önceden giriş alanının sağ altında ikinci bir halka dönüyor ve
   gönder düğmesinin üstüne biniyordu ("animasyon yanlış yerde").
   ------------------------------------------------------------------ */
.mplus-send-status {
    display: none !important;
}

/* Balon her zaman konumlandırma referansı olsun; aksi hâlde mutlak
   konumlu küçük logo sohbet alanının köşesine kaçıyordu. */
#mesajlar .message,
.chat-messages .message {
    position: relative;
}

.mplus-send-spinner {
    position: absolute;
    right: 6px;
    bottom: 3px;
    width: 10px;
    height: 10px;
    margin: 0;
    opacity: .9;
}

.mplus-send-spinner .urti-mini-loader__svg {
    animation: mplus-logo-breathe .9s ease-in-out infinite alternate;
}

@keyframes mplus-logo-breathe {
    from { transform: scale(.82); opacity: .65; }
    to   { transform: scale(1); opacity: 1; }
}

/* =========================================================
   OKUNDU BİLGİSİ
   Karşı taraf mesajı görünce kendi balonumuzun sağ altında
   küçük "Okundu" etiketi belirir. Gönderim sürerken gizlenir.
   ========================================================= */
.message.sent.mplus-read:not(.has-attachment) {
    padding-bottom: 22px !important;
}

.message.sent.mplus-sending .mplus-read-receipt {
    display: none;
}

.mplus-read-receipt {
    position: absolute;
    right: 8px;
    bottom: 4px;
    padding: 1px 5px;
    border-radius: 8px;
    background: rgba(0, 0, 0, .16);
    font-size: 10px;
    line-height: 1.2;
    font-weight: 600;
    letter-spacing: .2px;
    color: rgba(255, 255, 255, .88);
    pointer-events: none;
    white-space: nowrap;
}
