
.chat-container {
    background-color: #fff;
    border-radius: 18px;
    box-shadow: 0 12px 40px rgba(15, 23, 42, 0.18), 0 2px 8px rgba(15, 23, 42, 0.08);
    flex-direction: column;
    position: fixed;
    bottom: 90px;
    right: 20px;
    height: 90%;
    max-height: 620px;
    width: 100%;
    max-width: 380px;
    z-index: 10000;
    display: none;
    overflow: hidden;
    border: 1px solid rgba(15, 23, 42, 0.06);
    animation: chat-panel-in 0.22s ease-out;
}

@keyframes chat-panel-in {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@media (min-width: 768px) {
    .chat-container {
        height: 620px;
        width: 380px;
    }
}

@media (max-width: 768px) {
    .chat-button {
        position: fixed;
        bottom: 116px !important;
        right: 20px;
        min-width: 56px;
        height: 56px;
        padding: 0 16px 0 12px;
        background-color: #007bff;
        border-radius: 28px;
        display: flex;
        justify-content: center;
        align-items: center;
        cursor: pointer;
        box-shadow: 0 8px 24px rgba(15, 23, 42, 0.22);
        z-index: 10001;
        user-select: none;
        color: #fff;
    }
}

@media (max-width: 376px) {
    .chat-container {
        right: 8px;
        left: 8px;
        max-width: none;
        width: auto;
        bottom: 72px;
    }

    .chat-button {
        bottom: 50px;
        right: 12px;
        min-width: 48px;
        height: 48px;
        padding: 0 10px 0 8px;
    }

    .chat-button.is-panel-open {
        width: 48px;
        height: 48px;
        min-width: 48px;
        padding: 0;
    }

    .chat-button-text {
        font-size: 0.85rem;
    }

    .chat-button-icon {
        width: 20px;
        height: 20px;
    }
}

.chat-header {
    background-color: #007bff;
    color: #fff;
    padding: 10px 12px 10px 14px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex: 0 0 56px;
    height: 56px;
    min-height: 56px;
    max-height: 56px;
    overflow: hidden;
    box-sizing: border-box;
}

.chat-header-brand {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    min-width: 0;
    overflow: hidden;
}

.chat-header-avatar-wrap {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    max-width: 36px;
    max-height: 36px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.35);
    box-sizing: border-box;
}

.chat-header-avatar,
.chat-header-avatar-wrap img {
    width: 36px !important;
    height: 36px !important;
    max-width: 36px !important;
    max-height: 36px !important;
    border-radius: 50%;
    object-fit: cover;
    object-position: top center;
    display: block;
    flex-shrink: 0;
}

.chat-container.is-open {
    display: flex !important;
}

.chat-header-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.2;
}

.chat-header-title {
    text-align: left;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.chat-header-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 3px;
    font-size: 0.75rem;
    font-weight: 500;
    opacity: 0.95;
}

.chat-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #86efac;
    box-shadow: 0 0 0 3px rgba(134, 239, 172, 0.28);
    flex-shrink: 0;
}

.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

.chat-header-btn {
    background: transparent;
    border: none;
    color: #fff;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.15s ease;
}

.chat-header-btn:hover {
    background: rgba(255, 255, 255, 0.18);
}

.chat-header-btn:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.7);
    outline-offset: 1px;
}

.chat-header-btn svg {
    width: 18px;
    height: 18px;
    display: block;
}

.chat-messages {
    flex: 1;
    min-height: 0;
    padding: 16px 14px 12px;
    overflow-y: auto;
    background:
        linear-gradient(180deg, #f8fafc 0%, #ffffff 48px);
    scroll-behavior: smooth;
}

.chat-message {
    margin-bottom: 14px;
    display: flex;
    align-items: flex-start;
    gap: 0;
}

.chat-message.user {
    justify-content: flex-end;
}

.chat-message.bot {
    justify-content: flex-start;
    flex-wrap: wrap;
    align-items: flex-start;
}

.chat-message .message-body {
    display: flex;
    flex-direction: column;
    max-width: 78%;
    min-width: 0;
}

.chat-message.user .message-body {
    align-items: flex-end;
}

.chat-message.bot .message-body {
    align-items: flex-start;
}

.profile-icon {
    width: 32px;
    height: 32px;
    min-width: 32px;
    overflow: hidden;
    border-radius: 50%;
    flex-shrink: 0;
    margin: 0 8px 0 0;
}

.profile-icon img {
    width: 32px !important;
    height: 32px !important;
    max-width: 32px !important;
    max-height: 32px !important;
    border-radius: 50%;
    object-fit: cover;
    object-position: top center;
    display: block;
    margin: 0;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
}

.chat-message.bot .chat-message-actions {
    flex-basis: 100%;
    width: 100%;
    margin-top: 8px;
    margin-left: 0;
    padding-left: 40px;
    box-sizing: border-box;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chat-action-link {
    display: inline-block;
    padding: 8px 14px;
    border-radius: 999px;
    color: #fff !important;
    font-size: 0.86rem;
    font-weight: 600;
    text-decoration: none !important;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.14);
    transition: filter 0.15s ease, transform 0.15s ease;
}

.chat-action-link:hover {
    filter: brightness(1.06);
    transform: translateY(-1px);
}

button.chat-action-link {
    border: none;
    cursor: pointer;
    font: inherit;
    text-align: center;
}

.message-content {
    max-width: 100%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 0.9rem;
    line-height: 1.45;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}

.chat-message.bot .message-content {
    background-color: #f1f5f9;
    color: #1e293b;
    border-bottom-left-radius: 6px;
}

.chat-message.user .message-content {
    background-color: #007bff;
    color: #fff;
    border-bottom-right-radius: 6px;
}

.message-meta {
    margin-top: 4px;
    padding: 0 4px;
    font-size: 0.68rem;
    line-height: 1;
    color: #94a3b8;
    font-weight: 500;
    letter-spacing: 0.02em;
}

.chat-message.user .message-meta {
    text-align: right;
}

.chat-message.bot .message-meta {
    text-align: left;
}

/* Typing / waiting state */
.typing-indicator {
    display: flex;
    align-items: flex-start;
    margin: 0 0 14px;
    gap: 0;
}

.typing-indicator .profile-icon img {
    margin-right: 8px;
}

.typing-bubble {
    background: #f1f5f9;
    border-radius: 16px;
    border-bottom-left-radius: 6px;
    padding: 10px 14px;
    display: inline-flex;
    flex-direction: column;
    gap: 6px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.typing-label {
    font-size: 0.72rem;
    color: #64748b;
    font-weight: 500;
}

.typing-dots {
    display: flex;
    align-items: center;
    gap: 5px;
    height: 12px;
}

.typing-dots span {
    width: 7px;
    height: 7px;
    background-color: #94a3b8;
    border-radius: 50%;
    animation: chat-typing-bounce 1.2s infinite ease-in-out;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.15s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes chat-typing-bounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.45;
    }
    30% {
        transform: translateY(-4px);
        opacity: 1;
    }
}

.chat-input {
    padding: 12px 14px 14px;
    background-color: #fff;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.chat-input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.chat-input textarea {
    flex: 1;
    width: auto;
    min-height: 44px;
    max-height: 120px;
    resize: none;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 10px 12px;
    outline: none;
    background-color: #f8fafc;
    color: #0f172a;
    box-sizing: border-box;
    font: inherit;
    font-size: 0.92rem;
    line-height: 1.4;
}

.chat-input textarea::placeholder {
    color: #94a3b8;
}

.chat-input textarea:focus {
    border-color: #94a3b8;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.12);
}

.chat-input textarea:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.chat-send-btn {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    margin-top: 0 !important;
    border: none;
    border-radius: 12px !important;
    background-color: #007bff;
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 !important;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.16);
    transition: filter 0.15s ease, transform 0.15s ease;
}

.chat-send-btn:hover:not(:disabled) {
    filter: brightness(0.94);
}

.chat-send-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    box-shadow: none;
}

.chat-send-btn svg {
    width: 18px;
    height: 18px;
    display: block;
}

.chat-input-hint {
    margin-top: 6px;
    font-size: 0.68rem;
    color: #94a3b8;
    text-align: center;
}

.chat-button {
    position: fixed;
    bottom: 75px;
    right: 20px;
    min-width: 56px;
    height: 56px;
    padding: 0 16px 0 12px;
    background-color: #007bff;
    border-radius: 28px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.22);
    z-index: 10001;
    user-select: none;
    color: #fff;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.chat-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.26);
}

.chat-button-open-state {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-button-icon {
    flex-shrink: 0;
    color: #fff;
}

.chat-button-text {
    color: #fff;
    font-weight: 600;
    font-size: 0.95rem;
    white-space: nowrap;
}

.chat-button-close-state {
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    line-height: 1;
    font-weight: 300;
    color: #fff;
}

/* Panel open: use header minimise/close — hide FAB so it cannot cover the input */
.chat-button.is-panel-open {
    display: none !important;
}

.chat-button.is-panel-open .chat-button-open-state {
    display: none;
}

.chat-button.is-panel-open .chat-button-close-state {
    display: flex;
}

/* Minimised: panel hidden, FAB stays as Chat (not X) */
.chat-button.is-minimised {
    display: flex !important;
}

.chat-button.is-minimised .chat-button-open-state {
    display: flex;
}

.chat-button.is-minimised .chat-button-close-state {
    display: none;
}
