/* ═══════════════════════════════════════════════════════════════════
   AQAR MARKET AI CHATBOT - Modern Real Estate Assistant
   A beautiful, friendly chatbot interface for property search
   ═══════════════════════════════════════════════════════════════════ */

/* CSS Variables for easy theming */
:root {
    --chatbot-primary: #2563eb;
    --chatbot-primary-dark: #1d4ed8;
    --chatbot-primary-light: #3b82f6;
    --chatbot-secondary: #10b981;
    --chatbot-accent: #f59e0b;
    --chatbot-bg: #ffffff;
    --chatbot-bg-dark: #f8fafc;
    --chatbot-text: #1e293b;
    --chatbot-text-light: #64748b;
    --chatbot-border: #e2e8f0;
    --chatbot-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    --chatbot-radius: 20px;
    --chatbot-radius-sm: 12px;
    --chatbot-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* RTL Support */
[dir="rtl"] .aqar-chatbot,
html[lang="ar"] .aqar-chatbot {
    --chatbot-direction: rtl;
}

/* ═══════════════════════════════════════════════════════════════════
   CHATBOT TOGGLE BUTTON
   ═══════════════════════════════════════════════════════════════════ */

.chatbot-toggle {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 65px;
    height: 65px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-primary-dark) 100%);
    border: none;
    cursor: pointer;
    box-shadow: 0 8px 32px rgba(37, 99, 235, 0.4);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--chatbot-transition);
    animation: chatbot-pulse 2s infinite;
}

[dir="rtl"] .chatbot-toggle,
html[lang="ar"] .chatbot-toggle {
    right: auto;
    left: 30px;
}

.chatbot-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 40px rgba(37, 99, 235, 0.5);
}

.chatbot-toggle:active {
    transform: scale(0.95);
}

.chatbot-toggle svg {
    width: 32px;
    height: 32px;
    fill: white;
    transition: var(--chatbot-transition);
}

.chatbot-toggle.active svg.chat-icon {
    display: none;
}

.chatbot-toggle svg.close-icon {
    display: none;
}

.chatbot-toggle.active svg.close-icon {
    display: block;
}

.chatbot-toggle .notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 22px;
    height: 22px;
    background: var(--chatbot-accent);
    border-radius: 50%;
    font-size: 11px;
    font-weight: 700;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: chatbot-bounce 1s infinite;
}

@keyframes chatbot-pulse {
    0%, 100% {
        box-shadow: 0 8px 32px rgba(37, 99, 235, 0.4);
    }
    50% {
        box-shadow: 0 8px 32px rgba(37, 99, 235, 0.6), 0 0 0 10px rgba(37, 99, 235, 0.1);
    }
}

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

/* ═══════════════════════════════════════════════════════════════════
   CHATBOT CONTAINER
   ═══════════════════════════════════════════════════════════════════ */

.aqar-chatbot {
    position: fixed;
    bottom: 110px;
    right: 30px;
    width: 400px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 150px);
    background: var(--chatbot-bg);
    border-radius: var(--chatbot-radius);
    box-shadow: var(--chatbot-shadow);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: var(--chatbot-transition);
    font-family: 'Segoe UI', 'Cairo', 'Noto Sans Arabic', system-ui, sans-serif;
}

[dir="rtl"] .aqar-chatbot,
html[lang="ar"] .aqar-chatbot {
    right: auto;
    left: 30px;
    direction: rtl;
}

.aqar-chatbot.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* ═══════════════════════════════════════════════════════════════════
   CHATBOT HEADER
   ═══════════════════════════════════════════════════════════════════ */

.chatbot-header {
    background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-primary-dark) 100%);
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    position: relative;
    overflow: hidden;
}

.chatbot-header::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 100%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    animation: header-glow 8s linear infinite;
}

@keyframes header-glow {
    0%, 100% {
        transform: translateX(0) translateY(0);
    }
    50% {
        transform: translateX(-30%) translateY(10%);
    }
}

.chatbot-avatar {
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
    flex-shrink: 0;
}

.chatbot-avatar svg {
    width: 28px;
    height: 28px;
    fill: white;
}

.chatbot-avatar .status-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: var(--chatbot-secondary);
    border: 2px solid white;
    border-radius: 50%;
}

.chatbot-info {
    flex: 1;
    position: relative;
    z-index: 1;
}

.chatbot-info h3 {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    color: white;
    letter-spacing: -0.3px;
}

.chatbot-info p {
    margin: 3px 0 0;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.85);
}

.chatbot-actions {
    display: flex;
    gap: 8px;
    position: relative;
    z-index: 1;
}

.chatbot-action-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--chatbot-transition);
}

.chatbot-action-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

.chatbot-action-btn svg {
    width: 18px;
    height: 18px;
    fill: white;
}

/* ═══════════════════════════════════════════════════════════════════
   CHATBOT MESSAGES AREA
   ═══════════════════════════════════════════════════════════════════ */

.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: var(--chatbot-bg-dark);
    scroll-behavior: smooth;
}

.chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

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

.chatbot-messages::-webkit-scrollbar-thumb {
    background: var(--chatbot-border);
    border-radius: 3px;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: var(--chatbot-text-light);
}

/* Message Bubbles */
.message {
    display: flex;
    gap: 10px;
    max-width: 85%;
    animation: message-appear 0.3s ease-out;
}

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

.message.bot {
    align-self: flex-start;
}

.message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

[dir="rtl"] .message.user,
html[lang="ar"] .message.user {
    flex-direction: row;
}

.message-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.message.bot .message-avatar {
    background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-primary-dark) 100%);
}

.message.user .message-avatar {
    background: linear-gradient(135deg, var(--chatbot-secondary) 0%, #059669 100%);
}

.message-avatar svg {
    width: 18px;
    height: 18px;
    fill: white;
}

.message-content {
    padding: 14px 18px;
    border-radius: var(--chatbot-radius-sm);
    line-height: 1.55;
    font-size: 14px;
    position: relative;
}

.message.bot .message-content {
    background: var(--chatbot-bg);
    color: var(--chatbot-text);
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

[dir="rtl"] .message.bot .message-content,
html[lang="ar"] .message.bot .message-content {
    border-bottom-left-radius: var(--chatbot-radius-sm);
    border-bottom-right-radius: 4px;
}

.message.user .message-content {
    background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-primary-dark) 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

[dir="rtl"] .message.user .message-content,
html[lang="ar"] .message.user .message-content {
    border-bottom-right-radius: var(--chatbot-radius-sm);
    border-bottom-left-radius: 4px;
}

.message-time {
    font-size: 11px;
    color: var(--chatbot-text-light);
    margin-top: 6px;
    text-align: right;
}

.message.user .message-time {
    color: rgba(255, 255, 255, 0.7);
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 5px;
    padding: 14px 18px;
    background: var(--chatbot-bg);
    border-radius: var(--chatbot-radius-sm);
    border-bottom-left-radius: 4px;
    width: fit-content;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--chatbot-primary);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

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

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

@keyframes typing {
    0%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    50% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

/* ═══════════════════════════════════════════════════════════════════
   PROPERTY LISTINGS CARDS
   ═══════════════════════════════════════════════════════════════════ */

.listings-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 12px;
}

.listing-card {
    background: var(--chatbot-bg);
    border-radius: var(--chatbot-radius-sm);
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    transition: var(--chatbot-transition);
    border: 1px solid var(--chatbot-border);
}

.listing-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.listing-card-inner {
    display: flex;
    gap: 12px;
    padding: 12px;
}

.listing-image {
    width: 80px;
    height: 80px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--chatbot-bg-dark);
}

.listing-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.listing-image .no-image {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--chatbot-bg-dark) 0%, var(--chatbot-border) 100%);
}

.listing-image .no-image svg {
    width: 32px;
    height: 32px;
    fill: var(--chatbot-text-light);
}

.listing-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.listing-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--chatbot-text);
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.listing-price {
    font-size: 15px;
    font-weight: 700;
    color: var(--chatbot-primary);
    margin: 0;
}

.listing-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 12px;
    color: var(--chatbot-text-light);
}

.listing-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.listing-meta svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
}

.listing-location {
    font-size: 12px;
    color: var(--chatbot-text-light);
    display: flex;
    align-items: center;
    gap: 4px;
}

.listing-location svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
}

.listing-cta {
    display: block;
    text-align: center;
    padding: 10px;
    background: var(--chatbot-bg-dark);
    color: var(--chatbot-primary);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    transition: var(--chatbot-transition);
    border-top: 1px solid var(--chatbot-border);
}

.listing-cta:hover {
    background: var(--chatbot-primary);
    color: white;
}

/* ═══════════════════════════════════════════════════════════════════
   QUICK SUGGESTIONS
   ═══════════════════════════════════════════════════════════════════ */

.suggestions-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.suggestion-chip {
    padding: 8px 14px;
    background: var(--chatbot-bg);
    border: 1px solid var(--chatbot-border);
    border-radius: 20px;
    font-size: 13px;
    color: var(--chatbot-text);
    cursor: pointer;
    transition: var(--chatbot-transition);
    white-space: nowrap;
}

.suggestion-chip:hover {
    background: var(--chatbot-primary);
    border-color: var(--chatbot-primary);
    color: white;
    transform: translateY(-1px);
}

/* ═══════════════════════════════════════════════════════════════════
   CHATBOT INPUT AREA
   ═══════════════════════════════════════════════════════════════════ */

.chatbot-input-area {
    padding: 16px 20px;
    background: var(--chatbot-bg);
    border-top: 1px solid var(--chatbot-border);
}

.chatbot-input-wrapper {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.chatbot-input {
    flex: 1;
    padding: 14px 18px;
    border: 2px solid var(--chatbot-border);
    border-radius: 25px;
    font-size: 14px;
    color: var(--chatbot-text);
    background: var(--chatbot-bg-dark);
    outline: none;
    transition: var(--chatbot-transition);
    resize: none;
    max-height: 120px;
    min-height: 48px;
    line-height: 1.4;
    font-family: inherit;
}

.chatbot-input:focus {
    border-color: var(--chatbot-primary);
    background: var(--chatbot-bg);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

.chatbot-input::placeholder {
    color: var(--chatbot-text-light);
}

.chatbot-send-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-primary-dark) 100%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--chatbot-transition);
    flex-shrink: 0;
}

.chatbot-send-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.4);
}

.chatbot-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.chatbot-send-btn svg {
    width: 22px;
    height: 22px;
    fill: white;
    transition: var(--chatbot-transition);
}

[dir="rtl"] .chatbot-send-btn svg,
html[lang="ar"] .chatbot-send-btn svg {
    transform: scaleX(-1);
}

/* ═══════════════════════════════════════════════════════════════════
   WELCOME SCREEN
   ═══════════════════════════════════════════════════════════════════ */

.chatbot-welcome {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px;
    text-align: center;
    background: var(--chatbot-bg-dark);
}

.welcome-icon {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-primary-dark) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    animation: welcome-pop 0.5s ease-out;
}

@keyframes welcome-pop {
    0% {
        transform: scale(0);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

.welcome-icon svg {
    width: 40px;
    height: 40px;
    fill: white;
}

.chatbot-welcome h4 {
    font-size: 20px;
    font-weight: 700;
    color: var(--chatbot-text);
    margin: 0 0 10px;
}

.chatbot-welcome p {
    font-size: 14px;
    color: var(--chatbot-text-light);
    margin: 0 0 24px;
    line-height: 1.6;
}

.welcome-suggestions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

.welcome-suggestion-btn {
    padding: 10px 18px;
    background: var(--chatbot-bg);
    border: 1px solid var(--chatbot-border);
    border-radius: 25px;
    font-size: 13px;
    color: var(--chatbot-text);
    cursor: pointer;
    transition: var(--chatbot-transition);
}

.welcome-suggestion-btn:hover {
    background: var(--chatbot-primary);
    border-color: var(--chatbot-primary);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

/* ═══════════════════════════════════════════════════════════════════
   MOBILE RESPONSIVE
   ═══════════════════════════════════════════════════════════════════ */

@media (max-width: 480px) {
    .chatbot-toggle {
        bottom: 20px;
        right: 20px;
        width: 58px;
        height: 58px;
    }

    [dir="rtl"] .chatbot-toggle,
    html[lang="ar"] .chatbot-toggle {
        right: auto;
        left: 20px;
    }

    .aqar-chatbot {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    [dir="rtl"] .aqar-chatbot,
    html[lang="ar"] .aqar-chatbot {
        right: 0;
        left: 0;
    }

    .chatbot-header {
        padding: 16px;
        border-radius: 0;
    }

    .chatbot-messages {
        padding: 16px;
    }

    .message {
        max-width: 90%;
    }

    .chatbot-input-area {
        padding: 12px 16px 20px;
    }

    .listing-card-inner {
        flex-direction: column;
    }

    .listing-image {
        width: 100%;
        height: 120px;
    }
}

/* ═══════════════════════════════════════════════════════════════════
   DARK MODE SUPPORT (Optional)
   ═══════════════════════════════════════════════════════════════════ */

@media (prefers-color-scheme: dark) {
    .aqar-chatbot.dark-mode {
        --chatbot-bg: #1e293b;
        --chatbot-bg-dark: #0f172a;
        --chatbot-text: #f1f5f9;
        --chatbot-text-light: #94a3b8;
        --chatbot-border: #334155;
    }
}

/* ═══════════════════════════════════════════════════════════════════
   LOADING STATE
   ═══════════════════════════════════════════════════════════════════ */

.chatbot-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--chatbot-border);
    border-top-color: var(--chatbot-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ═══════════════════════════════════════════════════════════════════
   ERROR STATE
   ═══════════════════════════════════════════════════════════════════ */

.message.error .message-content {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

/* ═══════════════════════════════════════════════════════════════════
   ANIMATIONS FOR ENHANCED UX
   ═══════════════════════════════════════════════════════════════════ */

.fade-in {
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.slide-up {
    animation: slideUp 0.3s ease-out;
}

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

