#max-chat-widget, #max-chat-widget * {
    box-sizing: border-box;
    font-family: "Overpass", -apple-system, BlinkMacSystemFont, sans-serif;
}

#max-chat-widget {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 999999;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
}

#max-chat-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #f9b11f;
    color: #1a1a1f;
    border: none;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(0, 22, 51, 0.28);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
#max-chat-toggle:hover {
    transform: scale(1.06);
    box-shadow: 0 10px 28px rgba(0, 22, 51, 0.34);
}
#max-chat-toggle svg { width: 28px; height: 28px; }

#max-chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #0056bb;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    padding: 4px 6px;
    border-radius: 999px;
    border: 2px solid #fff;
}

#max-chat-panel {
    width: 360px;
    max-width: calc(100vw - 32px);
    height: 520px;
    max-height: calc(100vh - 120px);
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 20px 48px rgba(0, 22, 51, 0.24);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    transition: opacity 0.18s ease, transform 0.18s ease;
}
#max-chat-panel[hidden] {
    display: none;
}
#max-chat-panel.max-chat-closing {
    opacity: 0;
    transform: scale(0.92) translateY(8px);
}

#max-chat-header {
    background: linear-gradient(120deg, #0056bb 0%, #0061d6 100%);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
#max-chat-header img {
    height: 22px;
    width: auto;
    display: block;
}
#max-chat-header-text {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
    flex-grow: 1;
}
#max-chat-header-text strong {
    font-size: 14px;
    font-weight: 700;
}
#max-chat-header-text span {
    font-size: 11px;
    opacity: 0.85;
}
#max-chat-close {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 6px;
    opacity: 0.85;
    border-radius: 8px;
}
#max-chat-close:hover { opacity: 1; background: rgba(255, 255, 255, 0.15); }

#max-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #fcf4df;
}

.max-chat-bubble {
    max-width: 82%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 13.5px;
    line-height: 1.4;
    white-space: pre-wrap;
    word-wrap: break-word;
}
.max-chat-bubble.bot {
    background: #fff;
    color: #1a1a1f;
    border: 1px solid #E2DCCB;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}
.max-chat-bubble.user {
    background: #0056bb;
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}
.max-chat-bubble.error {
    background: #fdecea;
    color: #7a1f1f;
    border: 1px solid #f3c4c0;
    align-self: flex-start;
}

#max-chat-typing {
    align-self: flex-start;
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    background: #fff;
    border: 1px solid #E2DCCB;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
}
#max-chat-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #ADADB1;
    animation: max-chat-bounce 1.2s infinite ease-in-out;
}
#max-chat-typing span:nth-child(2) { animation-delay: 0.15s; }
#max-chat-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes max-chat-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30% { transform: translateY(-4px); opacity: 1; }
}

#max-chat-form {
    flex-shrink: 0;
    display: flex;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid #E2DCCB;
    background: #fff;
}
#max-chat-input {
    flex: 1;
    border: 1px solid #D6D6D9;
    border-radius: 999px;
    padding: 10px 16px;
    font-size: 13.5px;
    color: #1a1a1f;
    outline: none;
}
#max-chat-input:focus { border-color: #0061d6; }
#max-chat-send {
    background: #f9b11f;
    color: #1a1a1f;
    border: none;
    border-radius: 999px;
    font-weight: 700;
    font-size: 12.5px;
    text-transform: uppercase;
    padding: 0 18px;
    cursor: pointer;
    transition: filter 0.15s ease;
}
#max-chat-send:hover { filter: brightness(0.95); }
#max-chat-send:disabled { opacity: 0.6; cursor: default; }

#max-chat-footer-note {
    font-size: 10px;
    color: #9ca3af;
    text-align: center;
    padding: 4px 12px 10px;
    background: #fff;
}

@media (max-width: 480px) {
    #max-chat-widget { right: 16px; bottom: 16px; }
    #max-chat-panel { width: calc(100vw - 24px); height: calc(100vh - 100px); }
}
