/* RealState Agent Chat Widget Styles */

:root {
    --rsa-primary-color: #0d9488 !important;
    --rsa-primary-hover: #0f766e !important;
    --rsa-teal: #0d9488;
    --rsa-green: #22c55e;
    --rsa-gradient: linear-gradient(135deg, #2BD4DF 0%, #48DD8E 100%);
    --rsa-text-color: #1f2937 !important;
    --rsa-text-light: #6b7280 !important;
    --rsa-bg-color: #fff !important;
    --rsa-bg-light: #f5f5f5 !important;
    --rsa-user-bubble: #F4F4F4;
    --rsa-border-color: #e5e7eb !important;
    --rsa-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    --rsa-radius: 12px;
    --rsa-panel-width: 420px;
}


/* Full-screen overlay: tablet/mobile only when chat is open; whole screen white, body scroll locked */
.rsa-chat-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 999998;
    background: #fff;
    pointer-events: auto;
}

@media (max-width: 1024px) {
    body.rsa-chat-panel-open .rsa-chat-overlay {
        display: block;
    }

    html.rsa-chat-panel-open,
    body.rsa-chat-panel-open {
        overflow: hidden;
        position: fixed;
        width: 100%;
        height: 100%;
    }
}

/* Widget Container - toggle button positioned in corner */
.rsa-chat-widget {
    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    pointer-events: none; /* allow clicks through; children re-enable as needed */
}

/* Override theme button styles (e.g. border: 1px solid #c36) – no borders on chat widget buttons */
.rsa-chat-widget button,
.rsa-chat-widget [type="button"],
.rsa-chat-widget [type="submit"] {
    border: none !important;
}

.rsa-chat-widget button:hover,
.rsa-chat-widget [type="button"]:hover,
.rsa-chat-widget [type="submit"]:hover {
    color: #fff !important;
    background: var(--rsa-gradient) !important;
}

.rsa-chat-widget .rsa-chat-scroll-to-bottom{
    background: #1f2937 !important;
    background-color: #1f2937 !important;
}

.rsa-chat-widget .rsa-chat-scroll-to-bottom:hover{
    background: #1f2937 !important;
    background-color: #1f2937 !important;
}

.rsa-chat-widget .rsa-chat-minimize:hover{
background: #EEFCF5 !important;
color: #000 !important;
}

/* Remove browser default focus outline (red ring) from all chat widget buttons */
.rsa-chat-widget button:focus,
.rsa-chat-widget button:focus-visible {
    outline: none;
    box-shadow: none;
}

.rsa-chat-widget .rsa-chat-toggle,
.rsa-chat-widget .rsa-chat-window,
.rsa-chat-widget .rsa-chat-overlay,
.rsa-chat-widget .rsa-chat-greeting {
    pointer-events: auto;
}

.rsa-chat-bottom-right {
    bottom: 20px;
    right: 20px;
    left: auto;
    top: auto;
}

.rsa-chat-bottom-left {
    bottom: 20px;
    left: 20px;
    right: auto;
    top: auto;
}

/* Toggle Button - HuisGenius gradient */
.rsa-chat-toggle {
    width: 60px;
    height: 60px;
    border-radius: 999px !important;
    background: var(--rsa-gradient) !important;
    color: #fff !important;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--rsa-shadow);
    transition: transform 0.2s, opacity 0.2s;
    position: relative;
}

.rsa-chat-toggle:hover {
    transform: scale(1.05);
    opacity: 0.95;
}

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

.rsa-chat-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #e53935;
    color: #fff;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Chat Window - right-side panel (body height); safe area for mobile (iOS Safari bar, home indicator) */
.rsa-chat-window {
    position: fixed;
    top: 0;
    right: 0;
    width: var(--rsa-panel-width);
    max-width: 100vw;
    height: 100vh;
    height: 100dvh;
    background: var(--rsa-bg-color);
    border-radius: 0;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateX(100%);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    z-index: 1000000;
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    box-sizing: border-box;
}

/* When closed, panel is off-screen and doesn't capture clicks */
.rsa-chat-window:not(.rsa-panel-open) {
    pointer-events: none;
}

.rsa-chat-window.rsa-panel-open {
    transform: translateX(0);
}

@keyframes rsaSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Header - HuisGenius: white background, logo + gradient title */
.rsa-chat-header {
    flex-shrink: 0;
    background: var(--rsa-bg-color);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.rsa-chat-header-brand {
    display: flex;
    align-items: center;
}

.rsa-chat-logo-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: inherit;
    line-height: 0;
}

.rsa-chat-logo {
    display: block;
    height: 20px;
    width: auto;
    max-height: 28px;
    object-fit: contain;
}

.rsa-chat-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.rsa-chat-minimize {
    background: none;
    border: none;
    border-radius: 999px !important;
    color: #000 !important;
    cursor: pointer;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
    width: 40px !important;
    height: 40px !important;
    display: flex !important;
    justify-content: center;
    padding: 0 !important;
}

.rsa-chat-minimize:hover {
    color: var(--rsa-text-color);
}

.rsa-chat-minimize svg {
    width: 20px;
    height: 20px;
}

/* Wrapper for messages + scroll-to-bottom button */
.rsa-chat-messages-wrap {
    position: relative;
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/* Messages Container – scrollable area (min-height: 0 required for flex child to scroll) */
.rsa-chat-messages {
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
}

.rsa-chat-scroll-to-bottom {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 5;
    width: 44px !important;
    height: 44px !important;
    border-radius: 999px !important;
    background: #1f2937 !important;
    background-color: #1f2937 !important;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 !important;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
    transition: opacity 0.2s, transform 0.2s;
}

.rsa-chat-scroll-to-bottom:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.4);
}

.rsa-chat-scroll-to-bottom img {
    width: 20px;
    height: 20px;
    transform: rotate(180deg);
    filter: brightness(0) invert(1);
}

/* Empty state – shown when there are no messages yet */
.rsa-chat-empty-state {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
}

.rsa-chat-empty-title {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--rsa-text-color);
    text-align: center;
    line-height: 1.4;
}

/* Message Bubbles */
.rsa-message {
    max-width: 90%;
    animation: rsaFadeIn 0.3s ease;
}

@keyframes rsaFadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.rsa-message-user {
    align-self: flex-end;
}

.rsa-message-assistant {
    align-self: flex-start;
    max-width: 95%;
}

/* Assistant: row with avatar (sparkle icon) + message body */
.rsa-message-inner {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.rsa-message-avatar {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rsa-message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.rsa-message-body {
    flex: 1;
    min-width: 0;
}

.rsa-message-content {
    padding: 12px 16px;
    border-radius: 16px;
    word-wrap: break-word;
}

.rsa-message-user .rsa-message-content {
    background: var(--rsa-user-bubble);
    color: var(--rsa-text-color);
    border-bottom-right-radius: 6px;
}

.rsa-message-assistant .rsa-message-content {
    background: var(--rsa-bg-color);
    color: var(--rsa-text-color);
    border: 0px solid var(--rsa-border-color);
    border-bottom-left-radius: 6px;
    padding: 0;
}

.rsa-message-time {
    font-size: 11px;
    color: var(--rsa-text-light);
    margin-top: 4px;
    padding: 0 4px;
    display: none;
}

.rsa-message-user .rsa-message-time {
    text-align: right;
}

.rsa-message-assistant .rsa-message-feedback {
    margin-top: 4px;
    margin-left: 0;
}

/* Typing Indicator */
.rsa-chat-typing {
    padding: 0 15px 10px;
}

.rsa-typing-dots {
    display: inline-flex;
    gap: 4px;
    padding: 12px 16px;
    padding-bottom: 0;
}

.rsa-typing-dots span {
    width: 8px;
    height: 8px;
    background: var(--rsa-gradient) !important;
    border-radius: 50%;
    animation: rsaTyping 1.4s infinite both;
}

.rsa-typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.rsa-typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes rsaTyping {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* Input Area – extra bottom padding on mobile so input stays above safe zone (iOS home indicator, browser bar) */
.rsa-chat-input-area {
    flex-shrink: 0;
    padding: 12px 15px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    background: var(--rsa-bg-color);
}

.rsa-chat-form {
    display: flex;
    gap: 10px;
    align-items: stretch;
}

.rsa-chat-input {
    flex: 1;
    border: 1px solid #BBBBBB;
    border-radius: 999px;
    padding: 12px 18px;
    font-size: 16px;
    resize: none;
    min-height: 44px;
    max-height: 100px;
    box-sizing: border-box;
    font-family: inherit;
    line-height: 1.4;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.rsa-chat-input::-webkit-scrollbar {
    display: none;
}

.rsa-chat-input:focus {
    outline: none;
    border-color: #BBBBBB;
}

.rsa-chat-send {
    width: 44px !important;
    height: 44px;
    padding: 0rem !important;
    border-radius: 999px !important;
    background: var(--rsa-gradient);
    color: #fff !important;
    border: none;
    cursor: pointer;
    display: flex !important;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity 0.2s, transform 0.2s;
}

.rsa-chat-credit {
    flex-shrink: 0;
    padding: 0px 12px 12px;
    font-size: 11px;
    color: #999;
    text-align: center;
    line-height: 1.3;
}

.rsa-chat-send:hover:not(:disabled) {
    opacity: 0.95;
    transform: scale(1.02);
}

.rsa-chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.rsa-chat-send svg {
    width: 20px;
    height: 20px;
}

/* Greeting Bubble */
.rsa-chat-greeting {
    position: absolute;
    bottom: 75px;
    background: var(--rsa-bg-color);
    padding: 12px 35px 12px 15px;
    border-radius: var(--rsa-radius);
    box-shadow: var(--rsa-shadow);
    max-width: 280px;
    animation: rsaSlideUp 0.3s ease;
}

.rsa-chat-bottom-right .rsa-chat-greeting {
    right: 0;
}

.rsa-chat-bottom-left .rsa-chat-greeting {
    left: 0;
}

.rsa-chat-greeting p {
    margin: 0;
    color: var(--rsa-text-color);
    font-size: 14px;
}

.rsa-greeting-close {
    position: absolute;
    top: 8px;
    right: 10px;
    background: none;
    border: none;
    font-size: 18px;
    color: var(--rsa-text-light);
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.rsa-greeting-close:hover {
    color: var(--rsa-text-color);
}

/* Lead Form */
.rsa-lead-form-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--rsa-bg-color);
    padding: 20px;
    display: flex;
    flex-direction: column;
    z-index: 10;
}

.rsa-lead-form {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.rsa-lead-form-title {
    margin: 0 0 20px;
    font-size: 18px;
    font-weight: 600;
    color: var(--rsa-text-color);
}

.rsa-form-group {
    margin-bottom: 15px;
}

.rsa-form-group input,
.rsa-form-group select {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--rsa-border-color);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    background: var(--rsa-bg-color);
}

.rsa-form-group input:focus,
.rsa-form-group select:focus {
    outline: none;
    border-color: var(--rsa-primary-color);
}

.rsa-form-actions {
    margin-top: auto;
    display: flex;
    gap: 10px;
}

.rsa-lead-form-cancel,
.rsa-lead-form-submit {
    flex: 1;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
}

.rsa-lead-form-cancel {
    background: var(--rsa-bg-light);
    border: none;
    color: var(--rsa-text-color);
}

.rsa-lead-form-cancel:hover {
    background: #e8e8e8;
}

.rsa-lead-form-submit {
    background: var(--rsa-primary-color);
    border: none;
    color: #fff;
}

.rsa-lead-form-submit:hover {
    background: var(--rsa-primary-hover);
}

.rsa-lead-form-submit:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Success State */
.rsa-lead-success {
    text-align: center;
    padding: 40px 20px;
}

.rsa-lead-success-icon {
    width: 60px;
    height: 60px;
    background: #4caf50;
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
}

.rsa-lead-success-icon svg {
    width: 30px;
    height: 30px;
}

.rsa-lead-success h4 {
    margin: 0 0 10px;
    color: var(--rsa-text-color);
}

.rsa-lead-success p {
    margin: 0;
    color: var(--rsa-text-light);
}

/* Error Message */
.rsa-error-message {
    background: #ffebee;
    color: #c62828;
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 13px;
    margin: 10px 15px;
}

/* Scrollbar */
.rsa-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.rsa-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.rsa-chat-messages::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.rsa-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}

/* Mobile Responsive - panel full width on small screens */
@media (max-width: 480px) {
    .rsa-chat-window {
        width: 100%;
        max-width: 100%;
    }

    .rsa-chat-greeting {
        left: 15px;
        right: 70px;
        bottom: 75px;
        max-width: none;
    }

    .rsa-chat-bottom-right .rsa-chat-greeting,
    .rsa-chat-bottom-left .rsa-chat-greeting {
        right: 70px;
        left: 15px;
    }
}

/* Feedback Buttons - light gray thumbs (HuisGenius style) */
.rsa-message-feedback {
    display: flex;
    gap: 4px;
    margin-top: 6px;
    transition: opacity 0.3s ease;
}

.rsa-feedback-btn {
    background: transparent;
    border: none;
    border-radius: 999px;
    padding: 5px 5px;
    cursor: pointer;
    color: #9ca3af;
    transition: color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rsa-feedback-btn:hover {
    border-color: var(--rsa-primary-color);
    color: var(--rsa-primary-color);
}

.rsa-feedback-up:hover {
    background: rgba(76, 175, 80, 0.1);
    border-color: #4caf50;
    color: #4caf50;
}

.rsa-chat-widget .rsa-feedback-down:hover {
    background: linear-gradient(135deg, #FF3D70 0%, #FF491D 100%) !important;
    border-color: #f44336;
    color: #f44336;
}

.rsa-feedback-thanks {
    font-size: 12px;
    color: var(--rsa-text-light);
    font-style: italic;
}

/* Streaming Message – white blinking cursor */
.rsa-message-streaming .rsa-message-content::after {
    content: '\2588';
    color: #fff;
    animation: rsaCursor 1s step-end infinite;
}

@keyframes rsaCursor {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* Property Links in Messages */
.rsa-message-content a.rsa-property-link {
    color: var(--rsa-primary-color);
    text-decoration: underline;
    word-break: break-all;
    transition: color 0.2s ease;
}

.rsa-message-content a.rsa-property-link:hover {
    color: var(--rsa-primary-hover);
    text-decoration: none;
}

.rsa-message-assistant .rsa-message-content a.rsa-property-link {
    color: var(--rsa-primary-color);
    font-weight: 500;
}

/* Property link icon */
.rsa-message-content a.rsa-property-link::before {
    content: '\1F3E0 '; /* House emoji */
    font-size: 12px;
}

.rsa-message-content a.rsa-property-card {
    display: flex;
    flex-direction: column;
    padding: 0;
    margin: 8px 0;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    text-decoration: none;
    word-break: normal;
    background: #fff;
    overflow: hidden;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    color: inherit;
}

.rsa-message-content a.rsa-property-card:hover {
    border-color: var(--rsa-primary-color);
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    text-decoration: none;
}

.rsa-message-content a.rsa-property-card::before {
    content: none;
}

.rsa-property-card-image-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 10;
    min-height: 120px;
    background: #f0f0f0;
    overflow: hidden;
}

.rsa-property-card-image-wrap::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 50%;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.7), transparent);
    pointer-events: none;
}

.rsa-property-card-image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.rsa-property-card-image-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background: #e8e8e8;
}

.rsa-property-card-price-overlay,
.rsa-property-card-view-overlay {
    position: absolute;
    bottom: 0;
    z-index: 1;
    padding: 10px 14px;
    color: #fff;
    font-weight: 600;
    line-height: 1.2;
    background: transparent;
}

.rsa-property-card-price-overlay {
    left: 0;
    font-size: 20px;
}

.rsa-property-card-view-overlay {
    right: 0;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.rsa-property-card-view-overlay svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.rsa-property-card-info {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px 16px 16px;
    min-width: 0;
}

.rsa-property-card-name {
    font-weight: 600;
    font-size: 13px;
    color: #1a1a1a;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rsa-property-card-city {
    font-size: 11px;
    font-weight: 400;
    color: #888;
    line-height: 1.3;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    margin-top: -0.5rem;
}

.rsa-property-card-specs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    color: #555;
    line-height: 1.3;
}

.rsa-property-card-spec {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-width: 0;
}

.rsa-property-card-spec-icon {
    width: 18px;
    height: 18px;
    object-fit: contain;
    flex-shrink: 0;
}

/* Legacy URL-only fallback */
.rsa-property-card-url {
    color: var(--rsa-primary-color);
    font-size: 12px;
    line-height: 1.4;
    word-break: break-all;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* Markdown rendering in chat messages */
.rsa-message-content strong {
    font-weight: 600;
}

.rsa-list-item {
    display: block;
    padding: 2px 0 2px 4px;
}

.rsa-list-num, .rsa-list-bullet {
    display: inline-block;
    width: 20px;
    color: var(--rsa-primary-color);
    font-weight: 600;
}

.rsa-link-arrow {
    color: var(--rsa-primary-color);
    font-weight: bold;
    margin-right: 2px;
}

/* "Why This Property?" Button */
.rsa-why-property-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    padding: 0;
    margin-left: 4px;
    background: linear-gradient(135deg, #f0f7ff 0%, #e3f0ff 100%);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    vertical-align: middle;
    transition: all 0.2s ease;
    color: var(--rsa-primary-color);
}

.rsa-why-property-btn:hover {
    background: var(--rsa-primary-color);
    color: #fff;
    transform: scale(1.1);
}

.rsa-why-property-btn:active {
    transform: scale(0.95);
}

.rsa-why-property-btn.loading {
    opacity: 0.6;
    cursor: wait;
    animation: rsa-btn-pulse 1s infinite;
}

.rsa-why-property-btn svg {
    width: 12px;
    height: 12px;
}

@keyframes rsa-btn-pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* Property Explanation Popup */
.rsa-property-explanation {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    z-index: 100;
    margin: 10px 0;
    animation: rsa-explanation-appear 0.3s ease-out;
    overflow: hidden;
}

@keyframes rsa-explanation-appear {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.rsa-property-explanation.fading {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.rsa-explanation-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 15px;
    background: linear-gradient(135deg, var(--rsa-primary-color) 0%, color-mix(in srgb, var(--rsa-primary-color) 85%, #000) 100%);
    color: #fff;
}

.rsa-explanation-title {
    font-weight: 600;
    font-size: 14px;
    flex: 1;
}

.rsa-explanation-score {
    background: rgba(255, 255, 255, 0.2);
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.rsa-explanation-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 0 5px;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.rsa-explanation-close:hover {
    opacity: 1;
}

.rsa-explanation-reasons {
    list-style: none;
    margin: 0;
    padding: 15px;
}

.rsa-explanation-reasons li {
    position: relative;
    padding: 8px 0 8px 24px;
    font-size: 13px;
    color: #333;
    border-bottom: 1px solid #f0f0f0;
}

.rsa-explanation-reasons li:last-child {
    border-bottom: none;
}

.rsa-explanation-reasons li::before {
    content: '\2713';
    position: absolute;
    left: 0;
    color: #28a745;
    font-weight: bold;
}

.rsa-explanation-summary {
    margin: 0;
    padding: 12px 15px;
    background: #f8f9fa;
    font-size: 12px;
    color: #666;
    border-top: 1px solid #e0e0e0;
}

/* Print - hide chat */
@media print {
    .rsa-chat-widget {
        display: none !important;
    }
}

/* ============================================
   PROACTIVE TRIGGER MESSAGES
   ============================================ */

/* Proactive message styling */
.rsa-message.proactive {
    animation: rsa-proactive-appear 0.5s ease-out;
}

.rsa-message.proactive .rsa-message-content {
    background: linear-gradient(135deg, var(--rsa-primary-color) 0%, color-mix(in srgb, var(--rsa-primary-color) 85%, #000) 100%);
    color: #fff;
    border: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

.rsa-message.proactive .rsa-message-content::after {
    border-right-color: var(--rsa-primary-color);
}

/* Highlight effect for new proactive messages */
.rsa-message.proactive.highlight {
    animation: rsa-proactive-pulse 1s ease-in-out 2;
}

@keyframes rsa-proactive-appear {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes rsa-proactive-pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.02);
    }
}

/* Proactive message avatar indicator */
.rsa-message.proactive .rsa-message-avatar {
    background: linear-gradient(135deg, var(--rsa-primary-color) 0%, color-mix(in srgb, var(--rsa-primary-color) 70%, #000) 100%);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.rsa-message.proactive .rsa-message-avatar::after {
    content: '';
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 12px;
    height: 12px;
    background: #4CAF50;
    border-radius: 50%;
    border: 2px solid #fff;
}

/* Attention grabber when chat opens with proactive message */
.rsa-chat-widget.has-proactive .rsa-chat-toggle {
    animation: rsa-toggle-attention 0.6s ease-in-out 3;
}

@keyframes rsa-toggle-attention {
    0%, 100% {
        transform: scale(1);
    }
    25% {
        transform: scale(1.1);
    }
    50% {
        transform: scale(0.95);
    }
    75% {
        transform: scale(1.05);
    }
}

/* Notification badge for proactive trigger */
.rsa-chat-toggle .rsa-proactive-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 20px;
    height: 20px;
    background: #FF5722;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 12px;
    font-weight: bold;
    animation: rsa-badge-bounce 0.5s ease-out;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

@keyframes rsa-badge-bounce {
    0% {
        transform: scale(0);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
    }
}
