/* ==========================================================================
   GEZİ SOHBET — SOHBET BUTONU, SAĞ PANEL, GİRİŞ & MESAJLAŞMA STİLLERİ
   style.css içindeki tasarım değişkenleri (var(--primary) vb.) kullanılır;
   açık ve koyu tema (body.dark) ile uyumludur. Mevcut sayfa düzenini bozmaz.
   ========================================================================== */

/* --- Harita araç çubuğundaki Sohbet butonu ------------------------------
   region-pill sınıfını BİLEREK kullanmaz: app.js .region-pill üzerinden
   bölge filtresi bağladığı için bu buton filtre mantığına karışmaz.        */
.chat-pill {
    background: var(--primary-light);
    border: 1px solid var(--primary);
    border-radius: var(--radius-full);
    padding: 6px 14px;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--primary);
    cursor: pointer;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s ease;
}

.game-pill {
    background: var(--primary-light);
    border: 1px solid var(--primary);
    border-radius: var(--radius-full);
    padding: 6px 14px;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--primary);
    cursor: pointer;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    transition: all 0.15s ease;
}

.game-pill:hover {
    background: var(--primary);
    color: #fff;
}

.game-pill:active {
    transform: translateY(1px);
}

.chat-pill:hover {
    background: var(--primary);
    color: #fff;
}

.chat-pill:active {
    transform: translateY(1px);
}

.chat-pill:focus-visible,
.chat-panel button:focus-visible,
.chat-panel textarea:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* hidden özniteliği yazar CSS ile ezilmesin (auth/room görünümleri) */
.chat-panel [hidden] {
    display: none !important;
}

/* --- Arka plan karartması (overlay) ------------------------------------ */
.chat-overlay {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.55);
    backdrop-filter: blur(2px);
    z-index: 3000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.chat-overlay.is-open {
    opacity: 1;
    visibility: visible;
}

/* --- Sağ panel --------------------------------------------------------- */
.chat-panel {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    height: 100dvh;
    width: min(420px, 100vw);
    display: flex;
    flex-direction: column;
    background: var(--bg-surface);
    border-left: 1px solid var(--border-color);
    box-shadow: var(--shadow-elevated);
    z-index: 3001;
    transform: translateX(103%);
    visibility: hidden;
    transition: transform 0.28s ease, visibility 0.28s ease;
}

.chat-panel.is-open {
    transform: translateX(0);
    visibility: visible;
}

/* --- Panel başlığı ----------------------------------------------------- */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(135deg, var(--primary-light), transparent 70%);
    flex: 0 0 auto;
}

.chat-header-title {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.chat-header-title h2 {
    font-size: 1.02rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: 0.01em;
}

.chat-header-status {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
}

.chat-icon-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: var(--bg-surface-elevated);
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1;
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: all 0.15s ease;
    flex: 0 0 auto;
}

.chat-icon-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* --- Uyarı / hata bildirimi -------------------------------------------- */
.chat-notice {
    margin: 12px 14px 0;
    padding: 10px 12px;
    border-radius: 12px;
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.5;
    color: var(--text-primary);
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.45);
    flex: 0 0 auto;
    white-space: pre-line;
}

.chat-notice--warn {
    background: rgba(245, 158, 11, 0.12);
    border-color: rgba(245, 158, 11, 0.5);
}

.chat-notice--info {
    background: var(--primary-light);
    border-color: var(--primary);
}

.chat-notice--ok {
    background: rgba(16, 185, 129, 0.12);
    border-color: rgba(16, 185, 129, 0.5);
}

/* --- Giriş ekranı (giriş yapılmadıysa) ---------------------------------- */
.chat-auth-view {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 20px;
    overflow-y: auto;
}

.chat-auth-card {
    width: 100%;
    max-width: 330px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.chat-auth-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 1.8rem;
    background: var(--primary-light);
    border: 1px solid var(--border-color);
}

.chat-auth-card h3 {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--text-primary);
}

.chat-auth-card p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.chat-google-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 11px 16px;
    border-radius: 12px;
    border: 1px solid #dadce0;
    background: #fff;
    color: #3c4043;
    font-size: 0.9rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: box-shadow 0.15s ease, transform 0.1s ease;
}

.chat-google-btn:hover {
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}

.chat-google-btn:active {
    transform: translateY(1px);
}

.chat-google-btn:disabled {
    opacity: 0.6;
    cursor: wait;
}

.chat-auth-hint {
    font-size: 0.72rem;
    color: var(--text-muted);
    line-height: 1.6;
}

/* --- Sohbet odası (giriş yapıldıktan sonra) ----------------------------- */
.chat-room-view {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.chat-userbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-surface-elevated);
    flex: 0 0 auto;
}

.chat-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--border-color);
    background: var(--primary-light);
    color: var(--primary);
    display: grid;
    place-items: center;
    font-size: 0.9rem;
    font-weight: 800;
    flex: 0 0 auto;
    overflow: hidden;
}

.chat-userinfo {
    min-width: 0;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    line-height: 1.3;
}

.chat-userinfo strong {
    font-size: 0.85rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-userinfo span {
    font-size: 0.7rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-logout-btn {
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 700;
    font-family: inherit;
    padding: 7px 12px;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all 0.15s ease;
    flex: 0 0 auto;
}

.chat-logout-btn:hover {
    border-color: #ef4444;
    color: #ef4444;
}

/* --- Mesaj listesi ------------------------------------------------------ */
.chat-messages {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overscroll-behavior: contain;
    background: var(--bg-main);
}

.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border-highlight);
    border-radius: 8px;
}

.chat-msg {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    max-width: 88%;
}

.chat-msg--own {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chat-msg-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--primary-light);
    color: var(--primary);
    display: grid;
    place-items: center;
    font-size: 0.72rem;
    font-weight: 800;
    border: 1px solid var(--border-color);
    flex: 0 0 auto;
}

.chat-msg-body {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.chat-msg-meta {
    font-size: 0.68rem;
    color: var(--text-muted);
    display: flex;
    gap: 6px;
    align-items: baseline;
}

.chat-msg--own .chat-msg-meta {
    justify-content: flex-end;
}

.chat-msg-meta b {
    color: var(--text-secondary);
    font-weight: 700;
}

.chat-bubble {
    padding: 8px 12px;
    border-radius: 14px;
    font-size: 0.86rem;
    line-height: 1.5;
    word-break: break-word;
    white-space: pre-wrap;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

.chat-msg--own .chat-bubble {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    border-bottom-left-radius: 14px;
    border-bottom-right-radius: 4px;
}

.chat-msg-time {
    font-size: 0.66rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.chat-msg--own .chat-msg-time {
    text-align: right;
}

.chat-msg-status {
    font-size: 0.66rem;
    color: #f87171;
    font-weight: 700;
}

/* Boş / yükleniyor durumları */
.chat-empty {
    margin: auto;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.83rem;
    font-weight: 600;
    line-height: 1.7;
    padding: 20px;
}

/* --- Mesaj yazma alanı --------------------------------------------------- */
.chat-composer {
    flex: 0 0 auto;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-surface);
}

.chat-composer textarea {
    flex: 1 1 auto;
    resize: none;
    border: 1px solid var(--border-color);
    background: var(--bg-main);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.88rem;
    line-height: 1.45;
    padding: 10px 14px;
    border-radius: 18px;
    max-height: 110px;
    min-height: 42px;
    outline: none;
    transition: border-color 0.15s ease;
}

.chat-composer textarea:focus {
    border-color: var(--primary);
}

.chat-composer textarea::placeholder {
    color: var(--text-muted);
}

.chat-send-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: none;
    background: var(--primary);
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: background 0.15s ease, transform 0.1s ease;
    flex: 0 0 auto;
}

.chat-send-btn:hover {
    background: var(--primary-hover);
}

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

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* --- Mobil: panel tam ekran --------------------------------------------- */
@media (max-width: 640px) {
    .chat-panel {
        width: 100vw;
        border-left: none;
    }

    body.chat-panel-open {
        overflow: hidden;
    }
}

@media (prefers-reduced-motion: reduce) {
    .chat-panel,
    .chat-overlay {
        transition: none;
    }
}
