/* Bili Premium (2026-11-07): WhatsApp hissi + Claude oturumları tasarım dili.
   chat.css ve widget.php içindeki satır içi stillerin ÜSTÜNE biner; hepsi #app-chat-sidebar ile sınırlıdır.
   Geri alma: main.php'deki bu dosyanın <link>'ini kaldırmak yeterli. */
#app-chat-sidebar {
    --bl-ink: #101828; --bl-soft: #667085; --bl-line: #e5eaf1; --bl-bg: #f6f8fb;
    --bl-acc: var(--primary, #4f46e5);
    --bl-acc-soft: color-mix(in srgb, var(--primary, #4f46e5) 11%, #fff);
    --bl-me: color-mix(in srgb, var(--primary, #4f46e5) 15%, #fff);
    --bl-ok: #22c55e; --bl-blue: #2563eb;
    font-family: inherit;
}
#app-chat-sidebar.chat-sidebar-overlay {
    width: 430px; max-width: 100vw; border-left: 0; background: #fff;
    box-shadow: -22px 0 60px -24px rgba(16, 24, 40, .5);
    transition: transform .35s cubic-bezier(.4, 0, .2, 1), width .25s ease;
}
#app-chat-sidebar.wide.chat-sidebar-overlay { width: min(1140px, 96vw); }
/* görünen yükseklik (adres çubuğu/klavye dahil): JS --bl-vh yazar, yoksa dinamik vh */
#app-chat-sidebar.chat-sidebar-overlay { height: var(--bl-vh, 100dvh) !important; max-height: var(--bl-vh, 100dvh); }
#app-chat-sidebar *, #app-chat-sidebar *::before, #app-chat-sidebar *::after { box-sizing: border-box; }
#app-chat-sidebar button { font-family: inherit; }

/* ---- üst çubuk ---- */
#app-chat-sidebar #wce-chat-header {
    background: #fff !important; color: var(--bl-ink) !important;
    padding: 10px 14px !important; min-height: 62px;
    border-bottom: 1px solid var(--bl-line) !important;
}
#app-chat-sidebar #wce-chat-header > span { color: var(--bl-ink); }
#app-chat-sidebar #wce-chat-header > span > div {
    width: 40px !important; height: 40px !important; margin-right: 11px !important; border: 0 !important;
    background: linear-gradient(135deg, var(--bl-acc), color-mix(in srgb, var(--bl-acc) 55%, #000)) !important;
    box-shadow: 0 8px 18px -8px var(--bl-acc);
}
#app-chat-sidebar #wce-chat-header > span > div svg { width: 22px; height: 22px; }
#app-chat-sidebar #wce-chat-header > span > span:not(.wce-total-unread-badge) { font-size: 19px !important; font-weight: 800; letter-spacing: -.02em; }
#app-chat-sidebar #wce-header-menu-btn, #app-chat-sidebar #wce-chat-header #wce-chat-toggle, #app-chat-sidebar #wce-chat-header #wce-chat-expand { color: var(--bl-soft) !important; background: transparent !important; width: 34px; height: 34px; border-radius: 10px !important; padding: 0 !important; margin: 0 2px !important; display: inline-grid !important; place-items: center; border: 0 !important; }
#app-chat-sidebar #wce-header-menu-btn:hover, #app-chat-sidebar #wce-chat-header #wce-chat-toggle:hover, #app-chat-sidebar #wce-chat-header #wce-chat-expand:hover { background: var(--bl-bg) !important; color: var(--bl-ink) !important; }
/* açılır menü: kendi düzeni (dikey liste) */
#app-chat-sidebar #wce-header-menu-dropdown { flex-direction: column !important; width: 230px !important; border: 1px solid var(--bl-line); border-radius: 14px !important; box-shadow: 0 18px 40px -14px rgba(16, 24, 40, .35) !important; padding: 6px; top: 40px !important; }
#app-chat-sidebar #wce-header-menu-dropdown button { display: flex !important; width: 100% !important; height: auto !important; align-items: center; gap: 10px; text-align: left; justify-content: flex-start; padding: 10px 12px !important; border: 0 !important; border-radius: 9px !important; background: transparent !important; color: var(--bl-ink) !important; font-size: 13.5px; font-weight: 600; }
#app-chat-sidebar #wce-header-menu-dropdown button:hover { background: var(--bl-bg) !important; }
#app-chat-sidebar #wce-chat-header #wce-chat-expand { display: none !important; }
@media (min-width: 1000px) { #app-chat-sidebar #wce-chat-header #wce-chat-expand { display: inline-grid !important; } }
#app-chat-sidebar #wce-chat-header .wce-total-unread-badge { position: static !important; margin-left: 8px !important; }
#app-chat-sidebar .wce-total-unread-badge { background: var(--bl-acc) !important; color: #fff !important; border-radius: 99px !important; font-size: 11px !important; padding: 1px 8px !important; }

/* ---- gövde: kompakt (tek panel) ---- */
#app-chat-sidebar #wce-chat-body { background: #fff !important; }
#app-chat-sidebar #wce-user-list { background: #fff !important; }
#app-chat-sidebar #wce-user-search-container { padding: 12px 14px 6px !important; background: #fff !important; border: 0 !important; }
#app-chat-sidebar #wce-search-box-inner {
    background: var(--bl-bg) !important; border: 1px solid var(--bl-line) !important; border-radius: 12px !important; padding: 0 12px !important;
}
#app-chat-sidebar #wce-search-box-inner:focus-within { border-color: var(--bl-acc) !important; background: #fff !important; box-shadow: 0 0 0 3px var(--bl-acc-soft); }
#app-chat-sidebar #wce-user-search-input { font-size: 14px !important; font-weight: 500 !important; padding: 10px 0 !important; }
#wce-chip-row { display: flex; gap: 6px; padding: 6px 14px 10px; overflow-x: auto; scrollbar-width: none; flex: none; }
#wce-chip-row::-webkit-scrollbar { display: none; }
#wce-chip-row button {
    border: 1px solid var(--bl-line); background: #fff; color: var(--bl-soft); border-radius: 99px; padding: 5px 13px; font-size: 12.5px; font-weight: 600; white-space: nowrap; cursor: pointer; display: inline-flex; align-items: center; gap: 5px;
}
#wce-chip-row button:hover { background: var(--bl-bg); }
#wce-chip-row button.on { background: var(--bl-acc); border-color: var(--bl-acc); color: #fff; }
#wce-chip-row button i { font-style: normal; background: var(--bl-acc); color: #fff; border-radius: 99px; font-size: 10.5px; padding: 0 6px; min-width: 17px; text-align: center; }
#wce-chip-row button.on i { background: #fff; color: var(--bl-acc); }
#wce-chip-row button i:empty { display: none; }
#app-chat-sidebar #wce-user-list-content { padding: 0 !important; background: #fff; }

.bl-item { display: flex; gap: 12px; padding: 11px 14px; cursor: pointer; align-items: center; border-bottom: 1px solid #f1f4f8; background: #fff; position: relative; transition: background .12s; }
.bl-item:hover { background: #fafbfd; }
.bl-item.on { background: var(--bl-acc-soft); box-shadow: inset 3px 0 0 var(--bl-acc); }
.bl-avatar { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 18px; position: relative; flex: none; background: var(--bl-acc); }
.bl-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }
.bl-avatar.grp { background: #e8eefb; color: #3b5bdb; }
.bl-avatar.sm { width: 40px; height: 40px; font-size: 16px; }
.bl-dot { position: absolute; right: -1px; bottom: -1px; width: 13px; height: 13px; border-radius: 50%; background: var(--bl-ok); border: 2.5px solid #fff; }
.bl-item.on .bl-dot { border-color: var(--bl-acc-soft); }
.bl-main { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.bl-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.bl-name { font-weight: 700; font-size: 15px; color: var(--bl-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; letter-spacing: -.01em; }
.bl-time { margin-left: auto; font-size: 11.5px; color: var(--bl-soft); flex: none; }
.bl-time.unread { color: var(--bl-acc); font-weight: 700; }
.bl-prev { font-size: 13px; color: var(--bl-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 4px; min-width: 0; flex: 1; }
.bl-prev b { font-weight: 600; color: var(--bl-ink); }
.bl-prev .bl-tick { flex: none; }
.bl-co { font-size: 11px; color: var(--bl-acc); font-weight: 600; opacity: .9; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bl-badge { min-width: 20px; height: 20px; border-radius: 10px; background: var(--bl-acc); color: #fff; font-size: 11.5px; font-weight: 700; display: grid; place-items: center; padding: 0 6px; flex: none; }
.bl-empty { padding: 34px 20px; text-align: center; color: var(--bl-soft); font-size: 13.5px; }

/* ---- geniş (iki panel) görünüm ---- */
#app-chat-sidebar.wide #wce-chat-body {
    display: grid !important; grid-template-columns: 380px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr);
    flex: 1 !important; height: 0 !important; min-height: 0; position: relative; overflow: hidden;
}
#app-chat-sidebar.wide #wce-user-list {
    display: flex !important; width: auto !important; height: 100% !important; grid-column: 1; grid-row: 1;
    border-right: 1px solid var(--bl-line); background: #fff !important;
}
#app-chat-sidebar.wide #wce-chat-area { display: none; grid-column: 2; grid-row: 1; position: relative !important; }
#app-chat-sidebar.wide #wce-chat-area:not([style*="display: none"]):not([style*="display:none"]) {
    display: flex !important; position: relative !important; width: 100% !important; height: 100% !important; top: auto; left: auto;
}
#app-chat-sidebar.wide #wce-chat-area[style*="display: none"], #app-chat-sidebar.wide #wce-chat-area[style*="display:none"] { display: none !important; }
#app-chat-sidebar.wide #wce-chat-back { display: none !important; }
#app-chat-sidebar.wide #wce-chat-area, #app-chat-sidebar.wide #wce-user-list, #app-chat-sidebar.wide #wce-empty-state { min-height: 0; max-height: 100%; overflow: hidden; }
#app-chat-sidebar #wce-chat-history { min-height: 0; }
#wce-empty-state { display: none; }
#app-chat-sidebar.wide #wce-empty-state {
    grid-column: 2; grid-row: 1; flex-direction: column; align-items: center; justify-content: center; gap: 10px; text-align: center; color: var(--bl-soft); padding: 30px;
    background: radial-gradient(circle at 50% 38%, var(--bl-acc-soft), transparent 55%), var(--bl-bg);
}
#app-chat-sidebar.wide #wce-chat-body.no-chat #wce-empty-state { display: flex; }
#wce-empty-state .big { width: 84px; height: 84px; border-radius: 26px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, var(--bl-acc), color-mix(in srgb, var(--bl-acc) 55%, #000)); box-shadow: 0 18px 36px -14px var(--bl-acc); }
#wce-empty-state h3 { margin: 6px 0 0; color: var(--bl-ink); font-size: 20px; letter-spacing: -.02em; }
#wce-empty-state p { margin: 0; max-width: 340px; font-size: 13.5px; line-height: 1.5; }
#wce-empty-state kbd { background: #fff; border: 1px solid var(--bl-line); border-bottom-width: 2px; border-radius: 6px; padding: 1px 6px; font-size: 12px; color: var(--bl-ink); }

/* ---- sohbet başlığı ---- */
#app-chat-sidebar #wce-chat-area { background: #fff !important; }
#app-chat-sidebar #wce-chat-area > div:first-child {
    padding: 9px 14px !important; background: #fff !important; border-bottom: 1px solid var(--bl-line) !important; min-height: 62px;
}
#app-chat-sidebar #wce-chat-back, #app-chat-sidebar #wce-chat-group-info-btn, #app-chat-sidebar #wce-chat-tasks-view-btn, #app-chat-sidebar #wce-chat-call, #app-chat-sidebar #wce-chat-video-call, #app-chat-sidebar #wce-chat-remote, #app-chat-sidebar #wce-chat-options-btn { color: var(--bl-soft) !important; width: 36px; height: 36px; border-radius: 10px !important; padding: 0 !important; margin: 0 1px !important; place-items: center; background: transparent !important; border: 0 !important; }
#app-chat-sidebar #wce-chat-tasks-view-btn, #app-chat-sidebar #wce-chat-call, #app-chat-sidebar #wce-chat-video-call, #app-chat-sidebar #wce-chat-options-btn { display: inline-grid !important; }
#app-chat-sidebar #wce-chat-back:hover, #app-chat-sidebar #wce-chat-tasks-view-btn:hover, #app-chat-sidebar #wce-chat-call:hover, #app-chat-sidebar #wce-chat-video-call:hover, #app-chat-sidebar #wce-chat-remote:hover, #app-chat-sidebar #wce-chat-options-btn:hover { background: var(--bl-bg) !important; color: var(--bl-ink) !important; }
#app-chat-sidebar #wce-chat-options-menu { border: 1px solid var(--bl-line); border-radius: 12px !important; box-shadow: 0 18px 40px -14px rgba(16, 24, 40, .35) !important; padding: 6px !important; min-width: 190px !important; top: 40px !important; }
#app-chat-sidebar #wce-chat-options-menu button { display: block; width: 100%; padding: 9px 12px !important; border-radius: 8px !important; font-weight: 600; }
#app-chat-sidebar #wce-chat-options-menu button:hover { background: var(--bl-bg) !important; }
#app-chat-sidebar #wce-chat-area > div:first-child > div:first-child { min-width: 0; flex: 1; }
.bl-peer { display: flex; align-items: center; gap: 10px; min-width: 0; }
.bl-peer-txt { min-width: 0; }
#app-chat-sidebar #wce-chat-with-name { font-weight: 700 !important; font-size: 16px !important; color: var(--bl-ink) !important; max-width: 100% !important; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#wce-chat-with-status { font-size: 12px; color: var(--bl-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#wce-chat-with-status.on { color: #16a34a; font-weight: 600; }
#app-chat-sidebar #wce-chat-back { margin-right: 6px !important; }

/* ---- mesajlar ---- */
#app-chat-sidebar #wce-chat-history {
    padding: 14px 16px 10px !important; gap: 0;
    background: linear-gradient(#f7f8fb, #eef1f6) !important;
}
#app-chat-sidebar .wce-msg {
    max-width: min(78%, 640px) !important; padding: 7px 11px 5px !important; margin-bottom: 4px !important; border-radius: 14px !important;
    box-shadow: 0 1px 1.5px rgba(16, 24, 40, .1) !important; font-size: 14.5px !important; line-height: 1.38 !important; animation: blIn .18s ease;
}
@keyframes blIn { from { opacity: 0; transform: translateY(4px) scale(.985); } to { opacity: 1; transform: none; } }
#app-chat-sidebar .wce-msg.me { background: var(--bl-me) !important; border-bottom-right-radius: 5px !important; }
#app-chat-sidebar .wce-msg.other { background: #fff !important; border-bottom-left-radius: 5px !important; }
#app-chat-sidebar .wce-msg .msg-text { font-weight: 400 !important; word-break: break-word; }
#app-chat-sidebar .bl-who { font-size: 12px; font-weight: 700; margin-bottom: 2px; display: block; }
.bl-meta { display: flex; justify-content: flex-end; align-items: center; gap: 4px; margin-top: 1px; font-size: 10.5px; color: #8a94a6; line-height: 1; }
.bl-tick { display: inline-flex; color: #8a94a6; }
.bl-tick.read { color: var(--bl-blue); }
#app-chat-sidebar .wce-msg.pending { opacity: .85; }
#app-chat-sidebar .wce-msg.failed { outline: 1.5px solid #ef4444; }
.bl-retry { border: 0; background: #fee2e2; color: #b91c1c; border-radius: 8px; padding: 2px 8px; font-size: 11px; font-weight: 700; cursor: pointer; margin-left: 6px; }
#app-chat-sidebar .wce-day { background: #fff !important; border: 1px solid var(--bl-line); color: var(--bl-soft) !important; border-radius: 99px !important; padding: 3px 13px !important; font-weight: 600 !important; box-shadow: 0 1px 2px rgba(16, 24, 40, .05); }
#app-chat-sidebar #wce-jump { background: #fff !important; color: var(--bl-ink) !important; border: 1px solid var(--bl-line) !important; box-shadow: 0 8px 20px -8px rgba(16, 24, 40, .35) !important; }

/* ---- yazma alanı ---- */
#app-chat-sidebar #wce-chat-controls { background: #fff !important; border-top: 1px solid var(--bl-line) !important; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)) !important; }
#app-chat-sidebar .wce-input-row { align-items: flex-end !important; gap: 4px; }
#app-chat-sidebar .wce-input-row > div > button { color: var(--bl-soft) !important; width: 38px; height: 38px; border-radius: 50% !important; display: inline-grid !important; place-items: center; margin: 0 !important; padding: 0 !important; opacity: 1 !important; }
#app-chat-sidebar .wce-input-row > div > button:hover { background: var(--bl-bg) !important; color: var(--bl-ink) !important; }
#app-chat-sidebar #wce-chat-input {
    flex: 1; border: 1px solid var(--bl-line) !important; background: var(--bl-bg) !important; border-radius: 22px !important; padding: 10px 16px !important;
    font: inherit; font-size: 14.5px !important; line-height: 1.35; resize: none; max-height: 140px; min-height: 42px; outline: 0; margin: 0 4px;
}
#app-chat-sidebar #wce-chat-input:focus { background: #fff !important; border-color: var(--bl-acc) !important; box-shadow: 0 0 0 3px var(--bl-acc-soft) !important; }
#app-chat-sidebar #wce-chat-send {
    width: 42px !important; height: 42px !important; border-radius: 50% !important; background: var(--bl-acc) !important; color: #fff !important; margin: 0 0 0 2px !important;
    display: inline-grid !important; place-items: center; padding: 0 !important; box-shadow: 0 8px 18px -8px var(--bl-acc); flex: none;
}
#app-chat-sidebar #wce-chat-send:hover { filter: brightness(1.06); }
#app-chat-sidebar #wce-chat-send svg { margin-left: -1px; }
#app-chat-sidebar #wce-chat-attach-menu, #app-chat-sidebar #wce-emoji-picker { border: 1px solid var(--bl-line); box-shadow: 0 18px 40px -14px rgba(16, 24, 40, .35) !important; border-radius: 14px !important; }
#wce-emoji-picker.bl-emoji { width: 300px !important; max-height: 300px; overflow: auto; padding: 8px !important; grid-template-columns: repeat(8, 1fr) !important; gap: 2px !important; }
#wce-emoji-picker.bl-emoji button { background: none; border: 0; font-size: 21px; border-radius: 8px; cursor: pointer; padding: 3px 0; }
#wce-emoji-picker.bl-emoji button:hover { background: var(--bl-bg); }
#wce-emoji-picker.bl-emoji .bl-ecat { grid-column: 1 / -1; font-size: 11px; font-weight: 700; color: var(--bl-soft); text-transform: uppercase; letter-spacing: .06em; padding: 6px 4px 2px; }

/* ---- mobil ---- */
@media (max-width: 999px) {
    #app-chat-sidebar.chat-sidebar-overlay, #app-chat-sidebar.wide.chat-sidebar-overlay { width: 100vw; }
    #app-chat-sidebar .wce-msg { max-width: 86% !important; }
}
