#chat-widget-toggle {
    position: fixed;
    right: 24px;
    bottom: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: #18305c;
    color: #fff;
    font-size: 24px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    cursor: pointer;
    z-index: 1050;
}

#chat-widget-panel {
    position: fixed;
    right: 24px;
    bottom: 92px;
    width: 320px;
    max-width: calc(100vw - 48px);
    height: 420px;
    max-height: calc(100vh - 140px);
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 1050;
}

#chat-widget-panel.d-none {
    display: none;
}

#chat-widget-header {
    background: linear-gradient(135deg, #18305c, #0f1f3d);
    color: #fff;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
}

#chat-widget-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}

#chat-widget-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 14px;
}

.chat-widget-row {
    display: flex;
    flex-direction: column;
    animation: chat-widget-msg-in 0.18s ease-out;
}

@keyframes chat-widget-msg-in {
    from {
        opacity: 0;
        transform: translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-widget-row.user {
    align-items: flex-end;
}

.chat-widget-row.bot {
    align-items: flex-start;
}

.chat-widget-msg-time {
    font-size: 10px;
    color: #8a8a93;
    margin-top: 2px;
    padding: 0 4px;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.chat-widget-row:hover .chat-widget-msg-time {
    opacity: 1;
}

.chat-widget-msg {
    max-width: 85%;
    padding: 8px 12px;
    border-radius: 12px;
    line-height: 1.35;
    white-space: pre-wrap;
}

    .chat-widget-msg.user {
        background: #18305c;
        color: #fff;
        border-bottom-right-radius: 2px;
    }

.chat-widget-msg.bot {
    background: #f1f1f4;
    color: #222;
    border-bottom-left-radius: 2px;
}

.chat-widget-msg.pending {
    padding-top: 11px;
    padding-bottom: 11px;
}

.chat-widget-typing-dots {
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.chat-widget-typing-dots .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #18305c;
    animation: chat-widget-typing-bounce 1.1s infinite ease-in-out;
}

.chat-widget-typing-dots .dot:nth-child(2) {
    animation-delay: 0.15s;
}

.chat-widget-typing-dots .dot:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes chat-widget-typing-bounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    30% {
        transform: translateY(-5px);
        opacity: 1;
    }
}

.chat-widget-msg a.source-link {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 1px 8px;
    margin: 0 1px;
    border-radius: 999px;
    background: rgba(255, 196, 81, 0.25);
    color: #8a5b00;
    text-decoration: none;
    font-size: 0.92em;
    font-weight: 600;
}

.chat-widget-msg a.source-link::before {
    content: "↗";
    font-size: 0.9em;
}

.chat-widget-msg.user a.source-link {
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
}

#chat-widget-form {
    display: flex;
    border-top: 1px solid #e5e5e5;
    padding: 8px;
    gap: 8px;
}

#chat-widget-input {
    flex: 1;
    border: 1px solid #ccc;
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 14px;
}

#chat-widget-form button[type="submit"] {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #18305c;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 0 14px;
    cursor: pointer;
    transition: background 0.15s ease;
}

#chat-widget-form button[type="submit"] svg {
    fill: currentColor;
}

#chat-widget-form button[type="submit"]:hover:not(:disabled) {
    background: #0f1f3d;
}

#chat-widget-form button[type="submit"]:disabled {
    opacity: 0.5;
    cursor: default;
}
