/* ======================================================
   Masa sohbeti: bütün masa oyunlarında aynı ortak bileşen (src/net/chat.ts).
   Renkler game.css'teki --p-* değişkenlerini kullanır (koyu kahve, yeşil, krem, altın); bu dosya yalnızca
   .chat-* seçicilerini tanımlar, hiçbir oyuna özgü kuralı değiştirmez.
   Genişlik eşiği (1400px) burada ve chat.ts'teki DRAWER_QUERY'de aynı tutulmalı: altında panel sabit konumlu
   bir çekmeceye döner, üstünde oyun alanının sağında kalıcı bir sütundur.
   ====================================================== */

#chat-toggle { position: relative; }
.chat-badge {
    display: inline-grid;
    place-items: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--p-bordo);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
}

.chat-panel {
    display: flex;
    flex-direction: column;
    flex: 0 0 300px;
    min-height: 0;
    background: rgba(20, 11, 7, .86);
    border: 1px solid rgba(229, 169, 59, .22);
    border-radius: 16px;
    overflow: hidden;
}
.chat-panel:not(.is-open) { display: none; }

.chat-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    padding: 12px 14px;
    border-bottom: 1px solid rgba(229, 169, 59, .18);
}
.chat-head h2 { margin: 0; font-family: var(--serif); font-weight: 400; font-size: 18px; color: var(--p-cream); }
.chat-icon-btn {
    display: inline-grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--p-sage);
    cursor: pointer;
}
.chat-icon-btn:hover { background: rgba(255,255,255,.08); color: var(--p-cream); }
.chat-icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

.chat-list-wrap { position: relative; flex: 1; min-height: 0; display: flex; }
.chat-list {
    flex: 1;
    min-height: 0;
    margin: 0;
    padding: 10px 12px;
    list-style: none;
    overflow-y: auto;
    overscroll-behavior: contain;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.chat-empty {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0 22px;
    text-align: center;
    color: var(--p-sage-dim);
    font-size: 13.5px;
    pointer-events: none;
}

.chat-msg { display: flex; gap: 8px; align-items: flex-start; }
.chat-msg.is-me { flex-direction: row-reverse; }
.chat-avatar {
    flex-shrink: 0;
    display: inline-grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255,255,255,.08);
    color: var(--p-cream);
    font-size: 11px;
    font-weight: 700;
    overflow: hidden;
}
.chat-avatar img { width: 100%; height: 100%; object-fit: cover; }
.chat-body { min-width: 0; max-width: calc(100% - 36px); display: flex; flex-direction: column; gap: 2px; }
.chat-msg-head { display: flex; align-items: baseline; gap: 6px; }
.chat-msg.is-me .chat-msg-head { flex-direction: row-reverse; }
.chat-msg-head strong { font-size: 12.5px; color: var(--p-mustard); font-weight: 600; }
.chat-msg-head time { font-size: 10.5px; color: var(--p-sage-dim); }
.chat-text {
    margin: 0;
    padding: 7px 10px;
    border-radius: 12px;
    background: rgba(255,255,255,.05);
    color: var(--p-cream);
    font-size: 13.5px;
    line-height: 1.4;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.chat-msg.is-me .chat-text { background: rgba(229, 169, 59, .18); }

.chat-jump {
    position: absolute;
    left: 50%;
    bottom: 10px;
    transform: translateX(-50%);
    padding: 6px 14px;
    border-radius: 999px;
    border: 1px solid rgba(229,169,59,.5);
    background: var(--p-brown);
    color: var(--p-mustard);
    font: 500 12.5px var(--sans);
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(0,0,0,.4);
}

.chat-form { flex-shrink: 0; padding: 10px 12px; border-top: 1px solid rgba(229, 169, 59, .18); }
.chat-form textarea {
    width: 100%;
    max-height: 120px;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1.5px solid rgba(246,231,208,.2);
    background: rgba(0,0,0,.25);
    color: var(--p-cream);
    font: 400 13.5px/1.4 var(--sans);
    resize: none;
}
.chat-form textarea:focus-visible { outline: 2px solid var(--p-mustard); outline-offset: 1px; }
.chat-status { min-height: 16px; margin: 4px 2px 0; color: var(--p-bordo); font-size: 11.5px; }
.chat-form-row { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 4px; }
.chat-counter { color: var(--p-sage-dim); font-size: 11px; font-variant-numeric: tabular-nums; }
.chat-counter.is-over { color: var(--p-bordo); }
.chat-send {
    padding: 7px 16px;
    border-radius: 8px;
    border: none;
    background: var(--p-mustard);
    color: var(--p-brown);
    font: 600 13px var(--sans);
    cursor: pointer;
}
.chat-send:disabled { opacity: .4; cursor: not-allowed; }
.chat-send:not(:disabled):hover { background: #f0bb57; }

/* ---------- Tema uyumlu kaydırma çubuğu (yalnızca sohbet bileşeni) ---------- */
.chat-list, .chat-form textarea {
    scrollbar-width: thin;
    scrollbar-color: #795B35 #1C0F0A;
}
.chat-list::-webkit-scrollbar, .chat-form textarea::-webkit-scrollbar { width: 7px; }
.chat-list::-webkit-scrollbar-track, .chat-form textarea::-webkit-scrollbar-track { background: #1C0F0A; border-radius: 999px; }
.chat-list::-webkit-scrollbar-thumb, .chat-form textarea::-webkit-scrollbar-thumb { background: #795B35; border-radius: 999px; }
.chat-list::-webkit-scrollbar-thumb:hover, .chat-form textarea::-webkit-scrollbar-thumb:hover,
.chat-list::-webkit-scrollbar-thumb:active, .chat-form textarea::-webkit-scrollbar-thumb:active { background: #B58A47; }

/* ---------- Dar ekran: yan sütun yerine açılıp kapanan çekmece ---------- */
@media (max-width: 1400px) {
    /* Çekmece: kapalıyken de akışta kalır (ekran dışına kaydırılmış) ki açılış/kapanış animasyonlu olsun —
       masaüstündeki "kapalıyken display:none" kuralı burada geçersiz kılınır. */
    .chat-panel, .chat-panel:not(.is-open) {
        display: flex;
        position: fixed;
        inset: 0 0 0 auto;
        width: min(360px, 92vw);
        height: auto;
        border-radius: 0;
        z-index: 60;
        transform: translateX(100%);
        transition: transform .25s ease;
        box-shadow: -12px 0 32px rgba(0,0,0,.45);
    }
    .chat-panel.is-open { transform: translateX(0); }
}
