/* Stadt Land Kurt Chat — shared Block-Drop-style surface */

.chat-toggle-btn {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 1200;
    display: none;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border: 1px solid var(--slf-glass-border);
    border-radius: 16px;
    background: var(--slf-panel);
    color: var(--slf-text);
    box-shadow: var(--slf-glass-highlight), 0 10px 26px rgba(0, 0, 0, 0.45);
    backdrop-filter: var(--slf-glass-blur);
    -webkit-backdrop-filter: var(--slf-glass-blur);
    cursor: pointer;
    transition: border-color 0.2s ease, color 0.2s ease, transform 0.2s ease, background 0.2s ease;
}

.chat-toggle-btn:hover {
    color: var(--slf-accent);
    border-color: var(--slf-line-strong);
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-2px);
}

.chat-toggle-btn i {
    font-size: 1.35rem;
}

.chat-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 22px;
    height: 22px;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    border: 2px solid var(--slf-bg-0);
    border-radius: 999px;
    background: var(--slf-danger);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 800;
}

.chat-window {
    position: fixed;
    right: 20px;
    bottom: 88px;
    z-index: 1200;
    width: min(360px, calc(100vw - 28px));
    height: min(470px, calc(100dvh - 120px));
    display: none;
    flex-direction: column;
    padding: 0 !important;
    overflow: hidden;
    transform-origin: bottom right;
    animation: chatPopup 0.24s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes chatPopup {
    from {
        opacity: 0;
        transform: translateY(14px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.04);
}

.chat-header h3 {
    margin: 0;
    color: var(--slf-text);
    font-family: var(--slf-font-pixel);
    font-size: 0.82rem;
    font-weight: 400;
    letter-spacing: 1px;
}

.btn-close-chat {
    width: 34px;
    height: 34px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--slf-text-dim);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.btn-close-chat:hover {
    color: var(--slf-text);
    border-color: var(--slf-line-strong);
    transform: rotate(90deg);
}

.chat-messages {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 9px;
    padding: 14px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.18);
}

.chat-welcome {
    align-self: center;
    margin-top: 8px;
    color: var(--slf-text-dim);
    font-size: 0.88rem;
    font-style: italic;
    text-align: center;
}

.chat-message {
    max-width: 86%;
    display: grid;
    gap: 3px;
    padding: 9px 11px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    color: var(--slf-text);
    font-size: 0.92rem;
    line-height: 1.36;
    overflow-wrap: anywhere;
    animation: messageIn 0.18s ease-out;
}

@keyframes messageIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message.self {
    align-self: flex-end;
    border-color: rgba(162, 76, 255, 0.32);
    background: linear-gradient(135deg, rgba(162, 76, 255, 0.42), rgba(123, 47, 247, 0.34));
    border-bottom-right-radius: 4px;
}

.chat-message.other {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.06);
    border-bottom-left-radius: 4px;
}

.chat-message.system {
    align-self: center;
    max-width: 92%;
    border-color: rgba(89, 209, 178, 0.24);
    background: rgba(89, 209, 178, 0.08);
    color: var(--slf-text-dim);
    text-align: center;
}

.chat-message .sender-name {
    display: block;
    color: rgba(255, 255, 255, 0.58);
    font-size: 0.72rem;
    font-weight: 700;
}

.chat-message.self .sender-name {
    color: rgba(255, 255, 255, 0.78);
    text-align: right;
}

.chat-input-area {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.04);
}

.chat-input-area input {
    min-height: 40px;
    border-radius: 10px;
}

.btn-send-chat {
    width: 42px;
    height: 42px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    background: linear-gradient(135deg, var(--slf-accent), var(--slf-accent-2));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 10px 22px rgba(162, 76, 255, 0.2);
    transition: filter 0.2s ease, transform 0.2s ease;
}

.btn-send-chat:hover {
    filter: brightness(1.06);
    transform: translateY(-2px);
}

@media (max-width: 520px) {
    .chat-toggle-btn {
        right: 12px;
        bottom: 12px;
        width: 48px;
        height: 48px;
        border-radius: 14px;
    }

    .chat-window {
        right: 8px;
        bottom: 68px;
        width: calc(100vw - 16px);
        height: min(430px, calc(100dvh - 96px));
    }
}
