/* Matilda Chatbot Widget - Onapers Real Homes */
.matilda-widget {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 9998;
    font-family: 'Poppins', sans-serif;
}

.matilda-teaser {
    position: absolute;
    right: 72px;
    bottom: 14px;
    display: flex;
    align-items: center;
    gap: 0;
    opacity: 0;
    transform: translateX(8px);
    transition: opacity 0.35s ease, transform 0.35s ease;
    pointer-events: none;
    white-space: nowrap;
}

.matilda-teaser.is-visible {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
}

.matilda-teaser.is-hidden {
    opacity: 0 !important;
    transform: translateX(8px) !important;
    pointer-events: none !important;
}

.matilda-teaser-text {
    background: #fff;
    color: #1a1f35;
    font-size: 13px;
    font-weight: 600;
    padding: 10px 14px;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(26, 31, 53, 0.18);
    border: 1px solid rgba(255, 137, 4, 0.25);
    cursor: pointer;
    animation: matilda-teaser-bounce 2.5s ease-in-out infinite;
}

.matilda-teaser-arrow {
    width: 0;
    height: 0;
    border-top: 7px solid transparent;
    border-bottom: 7px solid transparent;
    border-left: 8px solid #fff;
    filter: drop-shadow(1px 0 1px rgba(255, 137, 4, 0.15));
}

@keyframes matilda-teaser-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

.matilda-toggle {
    position: relative;
    width: 62px;
    height: 62px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    background: linear-gradient(135deg, #FF8904 0%, #fbbf24 100%);
    color: #fff;
    box-shadow: 0 8px 28px rgba(255, 137, 4, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.matilda-toggle-pulse {
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid rgba(255, 137, 4, 0.45);
    animation: matilda-pulse 2s ease-out infinite;
    pointer-events: none;
}

@keyframes matilda-pulse {
    0% { transform: scale(1); opacity: 0.8; }
    100% { transform: scale(1.25); opacity: 0; }
}

.matilda-toggle.is-open .matilda-toggle-pulse {
    display: none;
}

.matilda-toggle:hover {
    transform: translateY(-2px) scale(1.03);
    box-shadow: 0 12px 32px rgba(255, 137, 4, 0.5);
}

.matilda-toggle svg {
    width: 28px;
    height: 28px;
}

.matilda-toggle.is-open svg.chat-icon { display: none; }
.matilda-toggle:not(.is-open) svg.close-icon { display: none; }

.matilda-panel {
    position: absolute;
    right: 0;
    bottom: 76px;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 520px;
    max-height: calc(100vh - 120px);
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 20px 60px rgba(26, 31, 53, 0.25);
    border: 1px solid rgba(255, 137, 4, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 1;
    transform: translateY(0) scale(1);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.matilda-panel.is-hidden {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
    pointer-events: none;
}

.matilda-header {
    background: linear-gradient(135deg, #1a1f35 0%, #141824 100%);
    color: #fff;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 2px solid rgba(255, 137, 4, 0.35);
}

.matilda-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #FF8904, #fbbf24);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
    flex-shrink: 0;
}

.matilda-header-text strong {
    display: block;
    font-size: 15px;
}

.matilda-header-text span {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
}

.matilda-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.matilda-status::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #00ff88;
    box-shadow: 0 0 6px #00ff88;
}

.matilda-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.matilda-message {
    max-width: 88%;
    padding: 12px 14px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.65;
    white-space: pre-wrap;
    word-break: break-word;
}

.matilda-message.bot {
    align-self: flex-start;
    background: #fff;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
}

.matilda-message.user {
    align-self: flex-end;
    background: linear-gradient(135deg, #FF8904, #fbbf24);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.matilda-message.typing {
    color: #64748b;
    font-style: italic;
}

.matilda-input-wrap {
    display: flex;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid #e2e8f0;
    background: #fff;
}

.matilda-input {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    padding: 10px 16px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.matilda-input:focus {
    border-color: #FF8904;
    box-shadow: 0 0 0 3px rgba(255, 137, 4, 0.15);
}

.matilda-send {
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #FF8904, #fbbf24);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.15s;
}

.matilda-send:hover { transform: scale(1.05); }
.matilda-send:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.matilda-send svg { width: 18px; height: 18px; }

@media (max-width: 480px) {
    .matilda-widget { right: 16px; bottom: 16px; }
    .matilda-teaser {
        right: 68px;
        bottom: 10px;
    }
    .matilda-teaser-text {
        font-size: 12px;
        padding: 8px 12px;
    }
    .matilda-panel {
        width: calc(100vw - 32px);
        height: calc(100vh - 100px);
    }
}
