/* ================================================================
   CHAT-TOOLBAR.CSS — Profesyonel Toolbar Sistemi
   Tüm toolbar stilleri burada, çakışma yok
   ================================================================ */

/* ── Ana toolbar bar ── */
.chat-toolbar {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 5px 10px;
    background: rgba(5, 9, 22, 0.8);
    border-bottom: 1px solid rgba(255,255,255,0.05);
    flex-shrink: 0;
    overflow: visible;       /* popup'ların taşmasına izin ver */
    position: relative;
    z-index: 10;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

@media (max-width: 768px) {
    .chat-toolbar {
        /* Mobilde scroll et, popup overflow ayrıca yönetilir */
        overflow-x: auto;
        overflow-y: visible;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
        /* İçindeki popup'lar için overflow:visible'ı koru — clip etme */
        overflow-clip-margin: content-box;
        padding: 5px 8px;
        gap: 0;
    }
    .chat-toolbar::-webkit-scrollbar { display: none; }

    /* Mobilde tb-btn yazıları kısalt */
    .tb-btn { padding: 5px 7px !important; font-size: 10.5px !important; gap: 3px !important; }
    .tb-btn svg { width: 13px !important; height: 13px !important; }

    /* Aksiyon butonları daha kısa */
    .tb-action { padding: 5px 6px !important; font-size: 10px !important; }

    /* Ayraç daha ince */
    .tb-sep { margin: 0 3px; }

    /* Yazı boyutu A- A+ küçült */
    .tb-sz { min-width: 22px !important; padding: 4px 5px !important; font-size: 10px !important; }

    /* Bold/İtalik butonlar küçült */
    .tb-style { min-width: 24px !important; padding: 4px 6px !important; }

    /* Popup'lar scroll ile kaymasın, konumları korunsun */
    .tb-group { flex-shrink: 0; }
}

/* ── Grup ── */
.tb-group {
    display: flex;
    align-items: center;
    gap: 1px;
    position: relative;      /* popup bu group'a göre konumlanır */
}

/* ── Ayraç ── */
.tb-sep {
    width: 1px;
    height: 16px;
    background: rgba(255,255,255,0.08);
    margin: 0 5px;
    flex-shrink: 0;
}

/* ── Toolbar butonu ── */
.tb-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 9px;
    border-radius: 4px;
    background: transparent;
    border: 1px solid transparent;
    color: rgba(148, 163, 184, 0.8);
    font-size: 11.5px;
    font-weight: 500;
    font-family: var(--font-body, 'DM Sans', sans-serif);
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    line-height: 1;
}
.tb-btn svg { flex-shrink: 0; opacity: 0.7; }
.tb-btn:hover {
    background: rgba(255,255,255,0.07);
    border-color: rgba(255,255,255,0.1);
    color: #f0f4ff;
}
.tb-btn:hover svg { opacity: 1; }

.tb-btn-active,
.tb-btn.tb-btn-active,
.tb-btn.active {
    background: rgba(59,130,246,0.15) !important;
    border-color: rgba(59,130,246,0.35) !important;
    color: #93c5fd !important;
}

/* Bold aktif — metin kalın göster */
#btn-bold.active {
    background: rgba(59,130,246,0.18) !important;
    border-color: rgba(59,130,246,0.45) !important;
    color: #93c5fd !important;
    font-weight: 900 !important;
    box-shadow: 0 0 8px rgba(59,130,246,0.25);
}

/* İtalik aktif — metin italik göster */
#btn-italic.active {
    background: rgba(124,58,237,0.18) !important;
    border-color: rgba(124,58,237,0.45) !important;
    color: #c4b5fd !important;
    font-style: italic !important;
    box-shadow: 0 0 8px rgba(124,58,237,0.2);
}

/* Stil butonları */
.tb-style { font-size: 12px; font-weight: 700; min-width: 28px; justify-content: center; }
.tb-italic { font-style: italic; }
.tb-sz { font-size: 10.5px; font-weight: 800; font-family: var(--font-mono, monospace); min-width: 28px; justify-content: center; background: rgba(6,182,212,0.07); color: #67e8f9; }
.tb-sz:hover { background: rgba(6,182,212,0.15); color: #a5f3fc; }

/* Renk seçici */
.tb-color-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}
.tb-color-preview {
    display: block;
    width: 18px; height: 18px;
    border-radius: 3px;
    background: #ffffff;
    border: 1px solid rgba(255,255,255,0.2);
    cursor: pointer;
    transition: transform 0.15s;
}
.tb-color-wrap:hover .tb-color-preview { transform: scale(1.15); }
.tb-color-wrap input[type=color] {
    position: absolute;
    inset: 0;
    opacity: 0;
    width: 100%; height: 100%;
    cursor: pointer;
    border: none; background: none; padding: 0;
}

/* Arkaplan buton grubu */
.tb-bg-group {
    align-items: center;
    gap: 2px;
}
.tb-bg { color: #a78bfa; }
.tb-bg:hover { background: rgba(124,58,237,0.12); border-color: rgba(124,58,237,0.3); color: #c4b5fd; }
.tb-bg-clear {
    padding: 4px 6px !important;
    font-size: 10px !important;
    color: #f87171 !important;
    background: rgba(239,68,68,0.08) !important;
    border-color: rgba(239,68,68,0.2) !important;
}
.tb-bg-clear:hover { background: rgba(239,68,68,0.16) !important; }

/* ================================================================
   POPUP — gerçekten çalışan sistem
   tb-group'a relative, popup absolute bottom
   ================================================================ */
.tb-popup {
    /* Konumlama */
    position: absolute;
    bottom: calc(100% + 10px);
    left: 0;
    z-index: 9999;

    /* Görsel */
    background: rgba(6, 10, 24, 0.97);
    backdrop-filter: blur(24px) saturate(200%);
    -webkit-backdrop-filter: blur(24px) saturate(200%);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 10px;
    box-shadow:
        0 -4px 6px -1px rgba(0,0,0,0.2),
        0 -20px 40px -8px rgba(0,0,0,0.6),
        0 0 0 1px rgba(255,255,255,0.04) inset;

    /* İçerik — block: header + grid sıralı */
    min-width: 220px;
    padding: 0;
    overflow: hidden;

    /* Animasyon */
    animation: popupIn 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes popupIn {
    from { opacity: 0; transform: translateY(6px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.tb-popup-header {
    font-size: 9.5px;
    font-weight: 700;
    color: rgba(148,163,184,0.6);
    text-transform: uppercase;
    letter-spacing: 1.2px;
    padding: 8px 10px 6px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    font-family: var(--font-body, sans-serif);
}

/* Emoji grid */
.emoji-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    padding: 8px;
    gap: 2px;
}
.emoji-grid span {
    font-size: 20px;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: background 0.12s, transform 0.12s;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px; height: 34px;
}
.emoji-grid span:hover {
    background: rgba(255,255,255,0.1);
    transform: scale(1.25);
}

/* GIF popup */
.tb-popup-gif {
    min-width: 340px;
    width: 340px;
}
.gif-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
    padding: 10px;
}
.gif-grid img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 4px;
    cursor: pointer;
    transition: transform 0.15s, opacity 0.15s, border-color 0.15s;
    border: 2px solid transparent;
    display: block;
    background: rgba(255,255,255,0.04);
}
.gif-grid img:hover {
    transform: scale(1.06);
    border-color: rgba(59,130,246,0.55);
    box-shadow: 0 0 10px rgba(59,130,246,0.25);
}

/* ── Toolbar aksiyon butonları (İstek Yap / Söz / Fal) ── */
.tb-action {
    font-size: 11px !important;
    font-weight: 600 !important;
    padding: 5px 9px !important;
    white-space: nowrap;
}
.tb-action.ab-purple { color: #c084fc !important; border-color: rgba(192,132,252,0.15) !important; background: rgba(124,58,237,0.07) !important; }
.tb-action.ab-purple:hover { background: rgba(124,58,237,0.16) !important; border-color: rgba(192,132,252,0.4) !important; }
.tb-action.ab-orange { color: #fbbf24 !important; border-color: rgba(251,191,36,0.15) !important; background: rgba(245,158,11,0.07) !important; }
.tb-action.ab-orange:hover { background: rgba(245,158,11,0.16) !important; border-color: rgba(251,191,36,0.4) !important; }
.tb-action.ab-brown  { color: #c8956a !important; border-color: rgba(200,149,106,0.15) !important; background: rgba(139,69,19,0.07) !important; }
.tb-action.ab-brown:hover  { background: rgba(139,69,19,0.16) !important; border-color: rgba(200,149,106,0.4) !important; }

/* ── Typing indicator — toolbar sağında yüzer ── */
.tb-typing-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    min-width: 0;
    overflow: hidden;
    pointer-events: none;
}

/* ── Action bar — artık kullanılmıyor ama varsa gizle ── */
.chat-action-bar { display: none !important; }

/* ── Action bar ── */
.chat-action-bar {
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 5px 10px;
    background: rgba(3, 7, 18, 0.7);
    border-bottom: 1px solid rgba(255,255,255,0.04);
    flex-shrink: 0;
    overflow-x: auto;
    scrollbar-width: none;
    backdrop-filter: blur(8px);
}
.chat-action-bar::-webkit-scrollbar { display: none; }
.action-bar-sep { flex: 1; }

.action-bar-btn {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 5px 10px;
    border-radius: 4px;
    border: 1px solid transparent;
    font-size: 11px; font-weight: 600; cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
    font-family: var(--font-body, sans-serif);
    background: rgba(255,255,255,0.04);
    color: rgba(148,163,184,0.75);
}
.action-bar-btn:hover { background: rgba(255,255,255,0.09); color: #f0f4ff; border-color: rgba(255,255,255,0.1); transform: translateY(-1px); }
.ab-purple { color: #c084fc; border-color: rgba(192,132,252,0.15); background: rgba(124,58,237,0.07); }
.ab-purple:hover { background: rgba(124,58,237,0.16); border-color: rgba(192,132,252,0.4); }
.ab-orange { color: #fbbf24; border-color: rgba(251,191,36,0.15); background: rgba(245,158,11,0.07); }
.ab-orange:hover { background: rgba(245,158,11,0.16); border-color: rgba(251,191,36,0.4); }
.ab-brown  { color: #c8956a; border-color: rgba(200,149,106,0.15); background: rgba(139,69,19,0.07); }
.ab-brown:hover  { background: rgba(139,69,19,0.16); border-color: rgba(200,149,106,0.4); }

/* ── Typing indicator ── */
.typing-indicator {
    margin-left: 4px;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    font-size: 11px;
    font-style: italic;
    color: rgba(148,163,184,0.6) !important;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: opacity 0.3s;
    font-family: var(--font-body, sans-serif);
}
.typing-indicator strong { color: #67e8f9; font-weight: 600; font-style: normal; }

/* ── Arkaplan overlay (mesaj alanı) ── */
#messages-area {
    position: relative;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Scroll eden içerik katmanı */
#messages-area.has-bg {
    background-image: none !important;
}

/* Sabit arka plan — attachment:fixed ile scroll etmez, tam kapsar */
#messages-area.has-bg::after {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image: var(--room-bg-url);
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    background-attachment: local;
    z-index: 0;
    pointer-events: none;
}

/* Karartma overlay */
#messages-area.has-bg::before {
    content: '';
    position: absolute; inset: 0;
    background: rgba(4, 8, 20, 0.55);
    pointer-events: none;
    z-index: 1;
}
#messages-area > * { position: relative; z-index: 2; }

/* ── Light Theme ── */
body.light-theme .chat-toolbar { background: rgba(240,244,255,0.88); border-bottom-color: rgba(0,0,0,0.07); }
body.light-theme .tb-btn { color: #64748b; }
body.light-theme .tb-btn:hover { background: rgba(0,0,0,0.06); border-color: rgba(0,0,0,0.1); color: #0f172a; }
body.light-theme .tb-btn-active { background: rgba(59,130,246,0.1) !important; color: #2563eb !important; border-color: rgba(59,130,246,0.3) !important; }
body.light-theme .tb-sz { background: rgba(14,165,233,0.07); color: #0284c7; }
body.light-theme .tb-sz:hover { background: rgba(14,165,233,0.15); }
body.light-theme .tb-color-preview { border-color: rgba(0,0,0,0.2); }
body.light-theme .tb-popup { background: rgba(255,255,255,0.98); border-color: rgba(0,0,0,0.1); box-shadow: 0 -8px 30px rgba(0,0,0,0.12); }
body.light-theme .tb-popup-header { color: #94a3b8; border-bottom-color: rgba(0,0,0,0.07); }
body.light-theme .emoji-grid span:hover { background: rgba(0,0,0,0.06); }
body.light-theme .gif-grid img:hover { border-color: rgba(59,130,246,0.3); }
body.light-theme .chat-action-bar { background: rgba(240,244,255,0.85); border-bottom-color: rgba(0,0,0,0.06); }
body.light-theme .action-bar-btn { color: #64748b; background: rgba(0,0,0,0.04); }
body.light-theme .action-bar-btn:hover { background: rgba(0,0,0,0.08); color: #0f172a; }
body.light-theme .ab-purple { color: #7c3aed; }
body.light-theme .ab-orange { color: #d97706; }
body.light-theme .ab-brown  { color: #92400e; }
/* ── Toolbar Mobil: label gizle, sadece icon ── */
@media (max-width: 768px) {
    .chat-toolbar {
        overflow-x: auto;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
        padding: 4px 6px;
        gap: 1px;
    }
    .chat-toolbar::-webkit-scrollbar { display: none; }

    /* Metin label'ları gizle */
    .tb-btn .tb-label { display: none; }

    /* Butonları sadece ikon boyutuna düşür */
    .tb-btn {
        padding: 6px 7px;
        font-size: 15px;
        min-width: 32px;
        justify-content: center;
    }
    .tb-btn svg { flex-shrink: 0; }

    /* Stil ve boyut grupları kompakt */
    .tb-style-group, .tb-size-group { gap: 1px; }
    .tb-btn.tb-style, .tb-btn.tb-sz { padding: 6px 7px; font-size: 13px; min-width: 28px; }

    /* Typing indicator gizle mobilde */
    .tb-typing-wrap { display: none; }

    /* Sep boşluğu küçült */
    .tb-sep { margin: 0 2px; }
}
