/* ================================================================
   Post SV Handball Bot – Chat Widget Styles
   Farben: Post-Gelb #FFCC00 / Post-Rot #CC0000 / Dunkel #1a1a1a
   ================================================================ */

:root {
    --postsv-yellow:      #FFCC00;
    --postsv-yellow-dark: #E6B800;
    --postsv-yellow-light:#FFF8DC;
    --postsv-red:         #CC0000;
    --postsv-red-dark:    #AA0000;
    --postsv-dark:        #1a1a1a;
    --postsv-grey-bg:     #F5F5F0;
    --postsv-border:      #E0D9C8;
    --postsv-text:        #1a1a1a;
    --postsv-bot-bg:      #FFF8DC;
    --postsv-shadow:      0 12px 48px rgba(204,0,0,.18), 0 2px 8px rgba(0,0,0,.10);
    --postsv-radius-xl:   22px;
    --postsv-radius-md:   16px;
    --postsv-ease:        .18s ease;
}

/* ── Reset – WordPress-Themes überschreiben sonst Buttons etc. ── */
#postsv-chat-bubble,
#postsv-chat-widget,
#postsv-chat-widget * {
    box-sizing: border-box;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    line-height: 1.5;
}
#postsv-chat-widget button,
#postsv-chat-widget textarea {
    font-family: inherit;
    font-size: inherit;
}

/* ═══════════════════════════════════════════════════════════════
   SCHWEBENDE CHAT-BLASE
   ═══════════════════════════════════════════════════════════════ */
#postsv-chat-bubble {
    position: fixed;
    bottom: 24px;
    right:  24px;
    z-index: 9998;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--postsv-yellow);
    color: var(--postsv-red);
    padding: 13px 20px 13px 14px;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: var(--postsv-shadow);
    font-size: 14px;
    font-weight: 800;
    letter-spacing: .2px;
    user-select: none;
    border: none;
    outline: none;
    transition: transform var(--postsv-ease), box-shadow var(--postsv-ease);
    isolation: isolate;
}
#postsv-chat-bubble:hover,
#postsv-chat-bubble:focus-visible {
    transform: translateY(-3px);
    box-shadow: 0 18px 52px rgba(204,0,0,.28), 0 4px 12px rgba(0,0,0,.12);
}

/* Pulsierender Aufmerksamkeits-Ring (läuft 3× nach Seitenload) */
#postsv-chat-bubble::after {
    content: '';
    position: absolute;
    inset: -5px;
    border-radius: 55px;
    border: 2.5px solid var(--postsv-yellow);
    opacity: 0;
    animation: postsv-pulse 3.2s 1.5s ease-out 3;
    pointer-events: none;
}
@keyframes postsv-pulse {
    0%   { opacity: .7; transform: scale(1);    }
    100% { opacity: 0;  transform: scale(1.15); }
}

.postsv-bubble-logo  { height: 28px; width: auto; flex-shrink: 0; }
.postsv-bubble-label { white-space: nowrap; }

/* ═══════════════════════════════════════════════════════════════
   WIDGET-CONTAINER
   ═══════════════════════════════════════════════════════════════ */
#postsv-chat-widget {
    position: fixed;
    bottom: 24px;
    right:  24px;
    z-index: 9999;
    width: 375px;
    max-width: calc(100vw - 32px);
    height: 520px;
    max-height: calc(100dvh - 48px);
    background: #fff;
    border-radius: var(--postsv-radius-xl);
    box-shadow: var(--postsv-shadow);
    /* display: flex wird per JS gesetzt */
    flex-direction: column;
    overflow: hidden;
    font-size: 14px;
    color: var(--postsv-text);
}

/* ═══════════════════════════════════════════════════════════════
   HEADER (Post-Gelb mit rotem Unterstrich)
   ═══════════════════════════════════════════════════════════════ */
#postsv-chat-header {
    background: var(--postsv-yellow);
    color: var(--postsv-dark);
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    border-radius: var(--postsv-radius-xl) var(--postsv-radius-xl) 0 0;
    border-bottom: 3px solid var(--postsv-red);
}

.postsv-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.postsv-header-logo {
    height: 44px;
    width: auto;
    flex-shrink: 0;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,.2));
}

.postsv-header-info > div > strong {
    display: block;
    font-size: 15px;
    font-weight: 800;
    color: var(--postsv-dark);
}

.postsv-header-sub {
    font-size: 11px;
    color: var(--postsv-red);
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 1px;
    opacity: .9;
}

/* Online-Indikator */
.postsv-header-sub::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #22c55e;
    display: inline-block;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px rgba(34,197,94,.3);
}

#postsv-chat-close {
    background: rgba(0,0,0,.08);
    border: 1px solid rgba(0,0,0,.12);
    border-radius: 50%;
    color: var(--postsv-dark);
    font-size: 18px;
    line-height: 1;
    width: 33px;
    height: 33px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background var(--postsv-ease);
    flex-shrink: 0;
}
#postsv-chat-close:hover { background: rgba(0,0,0,.16); }

/* ═══════════════════════════════════════════════════════════════
   NACHRICHTEN-BEREICH (scrollbar)
   ═══════════════════════════════════════════════════════════════ */
#postsv-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px 12px 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}

/* Dünne Scrollbar */
#postsv-chat-messages::-webkit-scrollbar { width: 4px; }
#postsv-chat-messages::-webkit-scrollbar-track { background: transparent; }
#postsv-chat-messages::-webkit-scrollbar-thumb {
    background: var(--postsv-border);
    border-radius: 4px;
}

/* ═══════════════════════════════════════════════════════════════
   NACHRICHTEN-BLASEN
   ═══════════════════════════════════════════════════════════════ */
.postsv-msg {
    max-width: 84%;
    padding: 10px 14px;
    border-radius: var(--postsv-radius-md);
    word-break: break-word;
    white-space: pre-wrap;
    animation: postsv-msgIn .22s cubic-bezier(.34, 1.32, .64, 1) both;
    font-size: 13.5px;
}

@keyframes postsv-msgIn {
    from { opacity: 0; transform: translateY(10px) scale(.96); }
    to   { opacity: 1; transform: translateY(0)    scale(1);   }
}

/* Bot-Nachricht */
.postsv-msg--bot {
    background: var(--postsv-bot-bg);
    border: 1px solid #EEE0A0;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    color: var(--postsv-text);
}

/* User-Nachricht */
.postsv-msg--user {
    background: var(--postsv-red);
    color: #fff;
    border-bottom-right-radius: 4px;
    align-self: flex-end;
}

/* Links in Nachrichten */
.postsv-msg a                  { color: var(--postsv-red); text-decoration: underline; }
.postsv-msg--user a            { color: #ffdd99; }
.postsv-msg strong             { font-weight: 700; }
.postsv-msg em                 { font-style: italic; }
.postsv-msg hr {
    border: none;
    border-top: 1px solid rgba(0,0,0,.12);
    margin: 8px 0;
}

/* ═══════════════════════════════════════════════════════════════
   TYPING-INDIKATOR (drei springende Punkte)
   ═══════════════════════════════════════════════════════════════ */
.postsv-typing {
    display: flex !important;
    align-items: center;
    gap: 5px;
    padding: 13px 18px !important;
    background: var(--postsv-bot-bg);
    border: 1px solid #EEE0A0;
    border-radius: var(--postsv-radius-md);
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    max-width: fit-content !important;
    white-space: normal !important;
}

.postsv-typing span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--postsv-red);
    display: inline-block;
    opacity: .45;
    animation: postsv-dot 1s infinite;
}
.postsv-typing span:nth-child(2) { animation-delay: .18s; }
.postsv-typing span:nth-child(3) { animation-delay: .36s; }

@keyframes postsv-dot {
    0%, 55%, 100% { transform: translateY(0);    opacity: .4;  }
    27%           { transform: translateY(-7px); opacity: 1;   }
}

/* ═══════════════════════════════════════════════════════════════
   QUICK-REPLY-BUTTONS
   ═══════════════════════════════════════════════════════════════ */
.postsv-quick-replies {
    display: flex;
    flex-direction: column;
    gap: 7px;
    align-self: flex-start;
    max-width: 94%;
    margin-top: 2px;
}

.postsv-quick-btn {
    background: #fff;
    border: 2px solid var(--postsv-red);
    color: var(--postsv-red);
    border-radius: 22px;
    padding: 8px 17px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    text-align: left;
    transition:
        background var(--postsv-ease),
        color var(--postsv-ease),
        transform .1s;
    white-space: nowrap;
    box-shadow: 0 1px 4px rgba(204,0,0,.10);
}
.postsv-quick-btn:hover {
    background: var(--postsv-red);
    color: #fff;
}
.postsv-quick-btn:active { transform: scale(.96); }

/* ═══════════════════════════════════════════════════════════════
   INPUT-BEREICH / FOOTER
   ═══════════════════════════════════════════════════════════════ */
#postsv-chat-input-wrap {
    border-top: 2px solid var(--postsv-yellow);
    background: #fff;
    flex-shrink: 0;
    border-radius: 0 0 var(--postsv-radius-xl) var(--postsv-radius-xl);
}

#postsv-chat-footer {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px 4px;
}

#postsv-chat-input {
    flex: 1;
    border: 1.5px solid var(--postsv-border);
    border-radius: 14px;
    padding: 9px 13px;
    font-size: 14px;
    line-height: 1.4;
    resize: none;
    outline: none;
    transition: border-color var(--postsv-ease), background var(--postsv-ease);
    max-height: 90px;
    overflow-y: auto;
    color: var(--postsv-text);
    background: var(--postsv-grey-bg);
    /* WordPress-Reset */
    box-shadow: none;
    width: auto;
    margin: 0;
}
#postsv-chat-input:focus {
    border-color: var(--postsv-red);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(204,0,0,.10);
}
#postsv-chat-input::placeholder { color: #aaa; }
#postsv-chat-input:disabled     { opacity: .6; cursor: not-allowed; }

#postsv-chat-send {
    width: 41px;
    height: 41px;
    border-radius: 50%;
    background: var(--postsv-red);
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 0;
    transition: background var(--postsv-ease), transform .1s;
    box-shadow: 0 2px 8px rgba(204,0,0,.30);
}
#postsv-chat-send:hover {
    background: var(--postsv-red-dark);
}
#postsv-chat-send:active  { transform: scale(.91); }
#postsv-chat-send:disabled {
    background: #ccc;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

/* Powered-by */
#postsv-powered-by {
    text-align: center;
    padding: 2px 14px 10px;
    font-size: 10px;
}
#postsv-powered-by a {
    color: #222;
    text-decoration: none;
    font-weight: 600;
    letter-spacing: .2px;
}
#postsv-powered-by a:hover {
    color: #000;
    text-decoration: underline;
}
.postsv-bxm-x {
    color: #F06000;
}

/* Zeichen-Zähler */
#postsv-char-counter {
    font-size: 11px;
    color: #aaa;
    text-align: right;
    padding: 2px 14px 8px;
    transition: color var(--postsv-ease);
    font-variant-numeric: tabular-nums;
}
#postsv-char-counter.postsv-warn {
    color: var(--postsv-red);
    font-weight: 700;
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE – MOBILE (Vollbild)
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 440px) {
    #postsv-chat-widget {
        bottom:    0;
        right:     0;
        width:     100vw;
        max-width: 100vw;
        height:    100dvh;
        max-height: 100dvh;
        border-radius: 0;
    }
    #postsv-chat-header {
        border-radius: 0;
    }
    #postsv-chat-input-wrap {
        border-radius: 0;
    }
    #postsv-chat-bubble {
        bottom: 16px;
        right:  16px;
    }
}
