/**
 * Generic AI Support frontend chat styles.
 */

.gas-chat-widget {
    --gas-primary-color: #2271b1;
    position: fixed;
    z-index: 999999;
    bottom: 24px;
    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        Helvetica,
        Arial,
        sans-serif;
}

.gas-chat-widget.gas-position-right {
    right: 24px;
}

.gas-chat-widget.gas-position-left {
    left: 24px;
}

.gas-chat-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 58px;
    height: 58px;
    margin-left: auto;
    padding: 0;
    color: #ffffff;
    background: var(--gas-primary-color);
    border: 0;
    border-radius: 50%;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
    cursor: pointer;
    transition:
        transform 0.2s ease,
        box-shadow 0.2s ease;
}

.gas-position-left .gas-chat-toggle {
    margin-right: auto;
    margin-left: 0;
}

.gas-chat-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
}

.gas-chat-toggle:focus-visible,
.gas-chat-close:focus-visible,
.gas-chat-send:focus-visible,
.gas-chat-input:focus-visible {
    outline: 3px solid rgba(34, 113, 177, 0.25);
    outline-offset: 2px;
}

.gas-chat-toggle-close {
    display: none;
}

.gas-chat-open .gas-chat-toggle-icon {
    display: none;
}

.gas-chat-open .gas-chat-toggle-close {
    display: inline-flex;
}

.gas-chat-panel {
    display: flex;
    flex-direction: column;
    width: min(380px, calc(100vw - 32px));
    height: min(580px, calc(100vh - 120px));
    margin-bottom: 14px;
    overflow: hidden;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 18px;
    box-shadow: 0 16px 50px rgba(0, 0, 0, 0.24);
}

.gas-position-right .gas-chat-panel {
    margin-left: auto;
}

.gas-position-left .gas-chat-panel {
    margin-right: auto;
}

.gas-chat-panel[hidden] {
    display: none;
}

.gas-chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 68px;
    padding: 14px 16px;
    color: #ffffff;
    background: var(--gas-primary-color);
}

.gas-chat-header-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
    background: rgba(255, 255, 255, 0.18);
    border-radius: 50%;
}

.gas-chat-header-content {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
}

.gas-chat-title {
    overflow: hidden;
    font-size: 16px;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gas-chat-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 3px;
    font-size: 12px;
    opacity: 0.9;
}

.gas-chat-status-dot {
    width: 8px;
    height: 8px;
    background: #69db7c;
    border-radius: 50%;
    box-shadow: 0 0 0 3px rgba(105, 219, 124, 0.18);
}

.gas-chat-close {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 36px;
    width: 36px;
    height: 36px;
    padding: 0;
    color: #ffffff;
    background: transparent;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
}

.gas-chat-close:hover {
    background: rgba(255, 255, 255, 0.14);
}

.gas-chat-messages {
    flex: 1;
    padding: 18px 16px;
    overflow-x: hidden;
    overflow-y: auto;
    background: #f7f8fa;
    scroll-behavior: smooth;
}

.gas-message {
    display: flex;
    width: 100%;
    margin-bottom: 12px;
}

.gas-message:last-child {
    margin-bottom: 0;
}

.gas-message-assistant,
.gas-message-error {
    justify-content: flex-start;
}

.gas-message-user {
    justify-content: flex-end;
}

.gas-message-bubble {
    max-width: 82%;
    padding: 10px 13px;
    color: #1d2327;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 15px 15px 15px 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    font-size: 14px;
    line-height: 1.5;
    overflow-wrap: anywhere;
    white-space: normal;
}

.gas-message-user .gas-message-bubble {
    color: #ffffff;
    background: var(--gas-primary-color);
    border-color: transparent;
    border-radius: 15px 15px 4px 15px;
}

.gas-message-error .gas-message-bubble {
    color: #8a1f11;
    background: #fff2f0;
    border-color: #f2b8b5;
}

.gas-chat-typing {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    color: #646970;
    background: #f7f8fa;
    font-size: 12px;
}

.gas-chat-typing[hidden] {
    display: none;
}

.gas-chat-typing-dots {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.gas-chat-typing-dots span {
    width: 5px;
    height: 5px;
    background: currentColor;
    border-radius: 50%;
    animation: gasTypingDot 1.2s infinite ease-in-out;
}

.gas-chat-typing-dots span:nth-child(2) {
    animation-delay: 0.15s;
}

.gas-chat-typing-dots span:nth-child(3) {
    animation-delay: 0.3s;
}

.gas-chat-form {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 12px;
    background: #ffffff;
    border-top: 1px solid #e8eaed;
}

.gas-chat-input {
    flex: 1;
    min-height: 42px;
    max-height: 120px;
    margin: 0;
    padding: 10px 12px;
    resize: none;
    color: #1d2327;
    background: #ffffff;
    border: 1px solid #c3c4c7;
    border-radius: 12px;
    box-shadow: none;
    font: inherit;
    font-size: 14px;
    line-height: 1.4;
}

.gas-chat-input:focus {
    border-color: var(--gas-primary-color);
    box-shadow: 0 0 0 1px var(--gas-primary-color);
}

.gas-chat-input:disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

.gas-chat-input-error {
    border-color: #d63638;
    box-shadow: 0 0 0 1px #d63638;
}

.gas-chat-send {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
    padding: 0;
    color: #ffffff;
    background: var(--gas-primary-color);
    border: 0;
    border-radius: 12px;
    cursor: pointer;
    transition:
        transform 0.15s ease,
        opacity 0.15s ease;
}

.gas-chat-send:hover {
    transform: translateY(-1px);
}

.gas-chat-send:disabled {
    cursor: not-allowed;
    opacity: 0.55;
    transform: none;
}

.gas-chat-footer {
    padding: 8px 12px;
    color: #777777;
    background: #ffffff;
    border-top: 1px solid #f0f0f1;
    font-size: 10px;
    line-height: 1.35;
    text-align: center;
}

@keyframes gasTypingDot {
    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.4;
    }

    30% {
        transform: translateY(-4px);
        opacity: 1;
    }
}

@media screen and (max-width: 600px) {
    .gas-chat-widget {
        right: 12px;
        bottom: 12px;
        left: 12px;
    }

    .gas-chat-widget.gas-position-right,
    .gas-chat-widget.gas-position-left {
        right: 12px;
        left: 12px;
    }

    .gas-chat-panel {
        width: 100%;
        height: min(620px, calc(100vh - 90px));
        margin-right: 0;
        margin-bottom: 10px;
        margin-left: 0;
        border-radius: 16px;
    }

    .gas-chat-toggle,
    .gas-position-left .gas-chat-toggle {
        width: 54px;
        height: 54px;
        margin-right: 0;
        margin-left: auto;
    }

    .gas-chat-header {
        min-height: 62px;
        padding: 12px 14px;
    }

    .gas-chat-messages {
        padding: 14px 12px;
    }

    .gas-message-bubble {
        max-width: 88%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .gas-chat-toggle,
    .gas-chat-send,
    .gas-chat-messages {
        transition: none;
        scroll-behavior: auto;
    }

    .gas-chat-typing-dots span {
        animation: none;
    }
}