/* ===== Live-Chat (aus Food-Projekt portiert, Beisch-Design) ===== */

/* --- Floating Widget (Kundenseite) --- */
#chatWidgetRoot { position: fixed; bottom: 20px; right: 20px; z-index: 9000; font-family: inherit; }

.bchat-fab {
    width: 56px; height: 56px;
    border-radius: 50%;
    border: none;
    background: #14335c;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(20, 30, 50, .3);
    position: relative;
    float: right;
    transition: transform .15s;
}
.bchat-fab:hover { transform: scale(1.06); }

.bchat-badge {
    position: absolute;
    top: -4px; right: -4px;
    min-width: 20px; height: 20px;
    border-radius: 10px;
    background: #e8590c;
    color: #fff;
    font-size: 12px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    padding: 0 5px;
}

.bchat-panel {
    width: 340px; max-width: calc(100vw - 32px);
    height: 480px; max-height: calc(100vh - 120px);
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 8px 32px rgba(20, 30, 50, .25);
    display: flex; flex-direction: column;
    overflow: hidden;
    margin-bottom: 12px;
}

.bchat-head {
    background: #14335c;
    color: #fff;
    padding: 14px 16px;
    display: flex; align-items: center; justify-content: space-between;
}
.bchat-head-info { min-width: 0; }
.bchat-title { font-weight: 700; font-size: 15px; }
.bchat-status { font-size: 12px; color: #c6d4ea; margin-top: 2px; display: flex; align-items: center; gap: 6px; }
.bchat-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.bchat-dot.online { background: #4ade80; }
.bchat-dot.offline { background: #94a3b8; }

.bchat-close {
    background: none; border: none; color: #c6d4ea;
    font-size: 26px; line-height: 1; cursor: pointer; padding: 0 2px;
}
.bchat-close:hover { color: #fff; }

.bchat-msgs { flex: 1; overflow-y: auto; padding: 14px; background: #f4f4f1; }
.bchat-sysmsg {
    text-align: center; font-size: 12px; color: #6b7280;
    background: #fff; border: 1px solid #e3e2dc; border-radius: 8px;
    padding: 6px 12px; margin: 8px auto; max-width: 85%;
}
.bchat-row { display: flex; margin-bottom: 10px; }
.bchat-row.mine { justify-content: flex-end; }
.bchat-row.other { justify-content: flex-start; }
.bchat-bubble {
    max-width: 78%;
    padding: 9px 12px;
    border-radius: 12px;
    font-size: 14px; line-height: 1.45;
    word-break: break-word;
}
.bchat-bubble.mine { background: #14335c; color: #fff; border-bottom-right-radius: 4px; }
.bchat-bubble.other { background: #fff; color: #1a1d21; border: 1px solid #e3e2dc; border-bottom-left-radius: 4px; }
.bchat-meta { display: block; font-size: 10.5px; opacity: .65; margin-top: 3px; text-align: right; }

.bchat-typing { padding: 4px 16px; font-size: 12px; color: #6b7280; background: #f4f4f1; }

.bchat-inputrow {
    display: flex; gap: 8px; padding: 10px;
    border-top: 1px solid #e3e2dc; background: #fff;
}
.bchat-inputrow textarea {
    flex: 1; resize: none;
    border: 1px solid #e3e2dc; border-radius: 10px;
    padding: 8px 12px; font-size: 14px; font-family: inherit;
    max-height: 90px;
}
.bchat-inputrow textarea:focus { outline: 2px solid #14335c; outline-offset: -1px; }
.bchat-send {
    width: 40px; border: none; border-radius: 10px;
    background: #14335c; color: #fff; font-size: 16px; cursor: pointer;
}
.bchat-send:hover { background: #1d4a83; }

@media (max-width: 480px) {
    #chatWidgetRoot { bottom: 14px; right: 14px; }
    .bchat-panel { height: 70vh; }
}

/* --- Admin Live-Chat (floating, unten rechts, auf jeder Seite) --- */

/* Admin sieht nur das Admin-Widget, nicht das Kunden-Widget */
body.acw-admin #chatWidgetRoot { display: none !important; }

#acwRoot {
    position: fixed;
    bottom: 20px; right: 20px;
    z-index: 9100;
    font-family: inherit;
}

/* FAB (Chat-Knopf) – immer sichtbar, auch beim Scrollen */
.acw-fab {
    width: 58px; height: 58px;
    border-radius: 50%;
    border: none;
    background: #14335c;
    color: #fff;
    font-size: 25px;
    cursor: pointer;
    box-shadow: 0 4px 18px rgba(20, 30, 50, .35);
    position: relative;
    float: right;
    transition: transform .15s;
}
.acw-fab:hover { transform: scale(1.06); }

.acw-badge {
    position: absolute;
    top: -4px; right: -4px;
    min-width: 20px; height: 20px;
    border-radius: 10px;
    background: #e8590c;
    color: #fff;
    font-size: 12px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    padding: 0 5px;
}

/* Panel – smooth open/close */
.acw-panel {
    position: absolute;
    bottom: 70px; right: 0;
    width: min(780px, calc(100vw - 32px));
    height: min(560px, calc(100vh - 110px));
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 10px 40px rgba(20, 30, 50, .28);
    display: flex; flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(14px) scale(.96);
    transform-origin: bottom right;
    pointer-events: none;
    transition: opacity .18s ease, transform .18s ease;
}
.acw-panel.open {
    opacity: 1;
    transform: none;
    pointer-events: auto;
}

.acw-head {
    background: #14335c;
    color: #fff;
    padding: 12px 16px;
    display: flex; align-items: center; gap: 10px;
}
.acw-back {
    background: none; border: none; color: #fff;
    font-size: 20px; cursor: pointer; padding: 0 2px; line-height: 1;
    display: none;
}
.acw-head-info { min-width: 0; flex: 1; }
.acw-title { font-weight: 700; font-size: 15px; }
.acw-sub { font-size: 11.5px; color: #c6d4ea; margin-top: 2px; display: flex; align-items: center; gap: 6px; }
.acw-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.acw-dot.online { background: #4ade80; }

.acw-min {
    background: none; border: none; color: #c6d4ea;
    font-size: 24px; line-height: 1; cursor: pointer; padding: 0 4px;
}
.acw-min:hover { color: #fff; }

.acw-body {
    flex: 1;
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    min-height: 0;
}

.acw-list {
    overflow-y: auto;
    border-right: 1px solid #e3e2dc;
    background: #fafaf8;
}
.ac-conv {
    padding: 12px 16px; border-bottom: 1px solid #e3e2dc; cursor: pointer;
    transition: background .12s;
}
.ac-conv:hover { background: #f4f4f1; }
.ac-conv.active { background: #eef2f8; border-left: 3px solid #14335c; padding-left: 13px; }
.ac-conv-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 14px; }
.ac-conv-last { font-size: 12.5px; color: #6b7280; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ac-conv-meta { font-size: 11.5px; color: #9ca3af; margin-top: 3px; display: flex; align-items: center; gap: 6px; }
.ac-dot { width: 7px; height: 7px; border-radius: 50%; background: #cbd5e1; display: inline-block; flex-shrink: 0; }
.ac-dot.online { background: #2f9e44; }
.ac-unread {
    min-width: 20px; height: 20px; border-radius: 10px;
    background: #e8590c; color: #fff; font-size: 11.5px; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center; padding: 0 6px;
    flex-shrink: 0;
}
.ac-closed { color: #9ca3af; font-size: 11px; }
.ac-empty { padding: 24px 16px; color: #6b7280; font-size: 13px; text-align: center; line-height: 1.6; }
.ac-online-text { color: #2f9e44; font-weight: 600; }

.acw-chat {
    display: flex; flex-direction: column;
    min-width: 0; min-height: 0;
    background: #fff;
}
.acw-chat-head {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 10px 14px; border-bottom: 1px solid #e3e2dc;
    min-height: 46px;
}
.acw-info { font-size: 13px; color: #6b7280; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acw-close-conv {
    flex-shrink: 0;
    background: none; border: 1px solid #e3e2dc; border-radius: 8px;
    color: #6b7280; font-size: 12px; padding: 5px 10px; cursor: pointer;
}
.acw-close-conv:hover { border-color: #dc2626; color: #dc2626; }

.acw-msgs { flex: 1; overflow-y: auto; padding: 14px; background: #f4f4f1; min-height: 0; }
.acw-typing { padding: 4px 14px; font-size: 12px; color: #6b7280; background: #f4f4f1; }

.acw-inputrow {
    display: flex; gap: 8px; padding: 10px;
    border-top: 1px solid #e3e2dc; background: #fff;
}
.acw-inputrow textarea {
    flex: 1; resize: none;
    border: 1px solid #e3e2dc; border-radius: 10px;
    padding: 8px 12px; font-size: 14px; font-family: inherit;
    max-height: 90px;
}
.acw-inputrow textarea:focus { outline: 2px solid #14335c; outline-offset: -1px; }
.acw-send {
    width: 42px; border: none; border-radius: 10px;
    background: #14335c; color: #fff; font-size: 16px; cursor: pointer;
}
.acw-send:hover { background: #1d4a83; }

/* Mobil: Panel fuellt den Bildschirm, Liste/Chat wechseln sich ab */
@media (max-width: 768px) {
    #acwRoot { bottom: 14px; right: 14px; }
    .acw-panel {
        position: fixed;
        inset: 0;
        width: 100%; height: 100%;
        border-radius: 0;
        bottom: 0; right: 0;
    }
    .acw-back { display: none; }
    .acw-body { grid-template-columns: 1fr; }
    .acw-chat { display: none; }
    .acw-panel.show-chat .acw-list { display: none; }
    .acw-panel.show-chat .acw-chat { display: flex; }
    .acw-panel.show-chat .acw-back { display: block; }
}
