/* Chat widget styles scoped to the bottom-left launcher and panel. */
:root {
    --chat-widget-bg: #081c33;
    --chat-widget-border: rgba(132, 177, 226, 0.28);
    --chat-widget-shadow: 0 28px 64px rgba(2, 8, 20, 0.52);
    --chat-widget-accent: #f2cf73;
    --chat-widget-muted: #9cb1cb;
    --chat-widget-surface: #0a233d;
    --chat-widget-text: #d8eaff;
    --chat-widget-header-start: #041224;
    --chat-widget-header-end: #0b2d4f;
}

.chat-widget {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 1080;
    font-family: "Space Grotesk", "Segoe UI", sans-serif;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: calc(100vw - 32px);
}

.chat-widget__toggle {
    min-width: 180px;
    height: 56px;
    border-radius: 999px;
    border: 1px solid rgba(255, 223, 147, 0.72);
    background: linear-gradient(138deg, #f2cf73 0%, #d8a42a 52%, #8a5a15 100%);
    color: #10273d;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 1.35rem;
    font-weight: 700;
    box-shadow: 0 14px 30px rgba(214, 163, 40, 0.46);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    padding: 0 18px;
    max-width: 100%;
    white-space: nowrap;
}

.chat-widget__toggle:hover,
.chat-widget__toggle:focus-visible {
    transform: translateY(-2px);
    box-shadow: 0 18px 36px rgba(214, 163, 40, 0.56);
}

.chat-widget__panel {
    width: min(420px, 90vw);
    background: var(--chat-widget-bg);
    border: 1px solid var(--chat-widget-border);
    border-radius: 20px;
    box-shadow: var(--chat-widget-shadow);
    display: none;
    flex-direction: column;
    overflow: hidden;
    max-height: min(560px, 80vh);
}

.chat-widget.is-open .chat-widget__panel {
    display: flex;
}

.chat-widget__header {
    padding: 16px 18px;
    background: linear-gradient(118deg, var(--chat-widget-header-start), var(--chat-widget-header-end));
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(242, 207, 115, 0.2);
}

.chat-widget__title {
    font-weight: 700;
    color: var(--chat-widget-accent);
}

.chat-widget__subtitle {
    font-size: 0.85rem;
    color: rgba(241, 247, 255, 0.82);
}

.chat-widget__close {
    border: none;
    background: rgba(242, 207, 115, 0.08);
    color: #f7d888;
    font-size: 1rem;
    width: 32px;
    height: 32px;
    border-radius: 10px;
}

.chat-widget__messages {
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 320px;
    overflow-y: auto;
    background:
      radial-gradient(380px 220px at 100% 0%, rgba(242, 207, 115, 0.12), transparent 72%),
      linear-gradient(180deg, #0b2441, #081c34);
}

.chat-widget__message {
    padding: 10px 12px;
    border-radius: 14px;
    background: #0b2b4d;
    font-size: 0.9rem;
    color: var(--chat-widget-text);
    border: 1px solid rgba(132, 177, 226, 0.2);
    box-shadow: 0 8px 18px rgba(2, 8, 20, 0.25);
}

.chat-widget__message--user {
    align-self: flex-end;
    background: linear-gradient(138deg, #f2cf73 0%, #d8a42a 50%, #8a5a15 100%);
    border-color: rgba(138, 90, 21, 0.5);
    color: #0f253b;
    font-weight: 600;
}

.chat-widget__message--system {
    font-style: italic;
    color: var(--chat-widget-muted);
    background: #0d3157;
}

.chat-widget__form {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    padding: 14px 18px 18px;
    border-top: 1px solid var(--chat-widget-border);
    background: var(--chat-widget-surface);
}

.chat-widget__status {
    padding: 8px 18px 0;
    font-size: 0.75rem;
    color: var(--chat-widget-muted);
}

.chat-widget__status.is-online {
    color: #7ae2a6;
}

.chat-widget__status.is-connecting {
    color: #f0ce82;
}

.chat-widget__restart {
    margin: 8px 18px 0;
    border: 1px solid rgba(132, 177, 226, 0.3);
    border-radius: 999px;
    padding: 8px 16px;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    background: linear-gradient(135deg, #12395f, #0e2f4f);
    color: #dfedff;
    align-self: flex-start;
    display: none;
}

.chat-widget__restart.is-visible {
    display: inline-flex;
}

.chat-widget__typing {
    display: flex;
    gap: 6px;
    padding: 6px 18px 0;
    min-height: 16px;
    align-items: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.chat-widget__typing.is-visible {
    opacity: 1;
}

.chat-widget__typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #a8771d;
    animation: chat-typing 1.2s infinite ease-in-out;
}

.chat-widget__typing span:nth-child(2) {
    animation-delay: 0.2s;
}

.chat-widget__typing span:nth-child(3) {
    animation-delay: 0.4s;
}

.chat-widget__send:disabled,
.chat-widget__input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

@keyframes chat-typing {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
    40% { transform: translateY(-4px); opacity: 1; }
}

.chat-widget__input {
    border-radius: 12px;
    border: 1px solid rgba(132, 177, 226, 0.3);
    padding: 10px 12px;
    font-size: 0.9rem;
    background: #071b32;
    color: var(--chat-widget-text);
}

.chat-widget__input:focus {
    outline: none;
    border-color: rgba(214, 163, 40, 0.8);
    box-shadow: 0 0 0 3px rgba(214, 163, 40, 0.28);
}

.chat-widget__send {
    border: 1px solid rgba(255, 223, 147, 0.72);
    border-radius: 12px;
    padding: 0 14px;
    background: linear-gradient(138deg, #f2cf73 0%, #d8a42a 52%, #8a5a15 100%);
    color: #0f253b;
    display: grid;
    place-items: center;
    box-shadow: 0 8px 18px rgba(214, 163, 40, 0.35);
}

@media (max-width: 576px) {
    .chat-widget {
        right: 16px;
        bottom: 16px;
        max-width: calc(100vw - 32px);
    }

    .chat-widget__toggle {
        min-width: 0;
        width: 100%;
        height: 52px;
        font-size: 1.15rem;
        padding: 0 14px;
    }

    .chat-widget__toggle-text {
        font-size: 0.85rem;
    }

    .chat-widget__panel {
        width: 100%;
    }

    .chat-widget__messages {
        max-height: 240px;
    }
}

.chat-widget__toggle-text {
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.01em;
}
