/* ── eScooter Repair – Chat Widget ───────────────────────────────────────── */

#escr-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    font-size: 14px;
}

/* ── Toggle-Button ────────────────────────────────────────────────────────── */
#escr-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #1a73e8;
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, .28);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .2s, transform .15s, box-shadow .2s;
    flex-shrink: 0;
}
#escr-btn:hover {
    background: #1557b0;
    transform: scale(1.06);
    box-shadow: 0 6px 20px rgba(0, 0, 0, .32);
}
#escr-btn svg {
    width: 26px;
    height: 26px;
    pointer-events: none;
}

/* ── Chat-Fenster ─────────────────────────────────────────────────────────── */
#escr-window {
    width: 340px;
    max-height: 520px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, .18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin-bottom: 12px;
    opacity: 0;
    transform: translateY(16px) scale(.97);
    pointer-events: none;
    transition: opacity .25s ease, transform .25s ease;
}
#escr-window.escr-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* ── Header ───────────────────────────────────────────────────────────────── */
#escr-head {
    background: #1a73e8;
    color: white;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
#escr-head-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}
#escr-avatar {
    width: 38px;
    height: 38px;
    background: rgba(255, 255, 255, .2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 19px;
    flex-shrink: 0;
}
#escr-brand {
    font-weight: 700;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
#escr-sub {
    font-size: 11px;
    opacity: .82;
    margin-top: 1px;
}
#escr-dot {
    width: 9px;
    height: 9px;
    background: #4caf50;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, .45);
    flex-shrink: 0;
}
#escr-close {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 2px 4px;
    opacity: .75;
    flex-shrink: 0;
    transition: opacity .15s;
}
#escr-close:hover { opacity: 1; }

/* ── Nachrichten ──────────────────────────────────────────────────────────── */
#escr-msgs {
    flex: 1;
    overflow-y: auto;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}
#escr-msgs::-webkit-scrollbar { width: 4px; }
#escr-msgs::-webkit-scrollbar-thumb { background: #ddd; border-radius: 4px; }

.escr-msg {
    display: flex;
    max-width: 86%;
    animation: escr-fadein .18s ease;
}
@keyframes escr-fadein {
    from { opacity: 0; transform: translateY(5px); }
    to   { opacity: 1; transform: translateY(0); }
}
.escr-bot  { align-self: flex-start; }
.escr-user { align-self: flex-end; }

.escr-bubble {
    padding: 9px 13px;
    border-radius: 16px;
    line-height: 1.55;
    word-break: break-word;
    white-space: pre-wrap;
    font-size: 13.5px;
}
.escr-bot  .escr-bubble {
    background: #f0f2f5;
    color: #222;
    border-bottom-left-radius: 4px;
}
.escr-user .escr-bubble {
    background: #1a73e8;
    color: white;
    border-bottom-right-radius: 4px;
}

/* ── Tipp-Indikator ───────────────────────────────────────────────────────── */
.escr-typing .escr-bubble {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 13px 16px;
}
.escr-typing .escr-bubble span {
    display: block;
    width: 7px;
    height: 7px;
    background: #aaa;
    border-radius: 50%;
    animation: escr-bounce .9s infinite;
}
.escr-typing .escr-bubble span:nth-child(2) { animation-delay: .15s; }
.escr-typing .escr-bubble span:nth-child(3) { animation-delay: .30s; }
@keyframes escr-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30%           { transform: translateY(-5px); }
}

/* ── Eingabe ──────────────────────────────────────────────────────────────── */
#escr-input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid #eee;
    flex-shrink: 0;
}
#escr-ta {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 13px;
    font-family: inherit;
    resize: none;
    outline: none;
    max-height: 100px;
    line-height: 1.45;
    transition: border-color .2s;
    background: #fafafa;
}
#escr-ta:focus { border-color: #1a73e8; background: #fff; }
#escr-send {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #1a73e8;
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background .2s;
}
#escr-send:hover    { background: #1557b0; }
#escr-send:disabled { background: #ccc; cursor: default; }
#escr-send svg { width: 15px; height: 15px; }

/* ── WhatsApp-Button ──────────────────────────────────────────────────────── */
#escr-wa {
    display: block;
    background: #25d366;
    color: white;
    text-align: center;
    padding: 9px 12px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    border-radius: 0 0 16px 16px;
    transition: background .2s;
    flex-shrink: 0;
}
#escr-wa:hover { background: #1da851; }

/* ── Mobil ────────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
    #escr-widget { bottom: 16px; right: 16px; }
    #escr-window { width: calc(100vw - 32px); }
}

/* ── Live-Übergabe an Mitarbeiter ─────────────────────────────────────────── */
#escr-btn { position: relative; }
#escr-badge {
    display: none;
    position: absolute;
    top: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    background: #e53935;
    border: 2px solid #fff;
    border-radius: 50%;
}
.escr-staff { align-self: flex-start; }
.escr-staff .escr-bubble {
    background: #fff4e5;
    color: #222;
    border: 1px solid #f5c27a;
    border-bottom-left-radius: 4px;
}
.escr-autor {
    font-size: 11px;
    font-weight: 700;
    color: #b45f06;
    margin-bottom: 3px;
}
.escr-system {
    align-self: center;
    max-width: 100%;
}
.escr-system .escr-bubble {
    background: none;
    color: #888;
    font-size: 12px;
    padding: 2px 8px;
    text-align: center;
}
.escr-warte {
    font-style: normal;
    font-size: 12px;
    color: #666;
    margin-left: 6px;
}
#escr-window.escr-mensch #escr-head { background: #e8710a; }

/* ── Fest in die Seite eingebaut (/ai/) ───────────────────────────────────── */
#escr-widget.escr-inline-mode {
    position: static;
    display: block;
    z-index: auto;
}
#escr-widget.escr-inline-mode #escr-window {
    width: 100%;
    height: min(640px, 72vh);
    max-height: none;
    margin: 0;
    opacity: 1;
    transform: none;
    pointer-events: all;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .06);
}
#escr-widget.escr-inline-mode #escr-btn,
#escr-widget.escr-inline-mode #escr-close { display: none; }
#escr-widget.escr-inline-mode #escr-head { border-radius: 16px 16px 0 0; }
