/* ── Google Font ── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; }

/* ── Chat Widget Container ── */
#chatbot-container {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 9999;
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* ── Floating Toggle Button ── */
#chat-toggle {
    width: 62px;
    height: 62px;
    border-radius: 50%;
    background: linear-gradient(140deg, #1a3a5c 0%, #2a6fc2 100%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 24px rgba(26, 58, 92, 0.45);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    position: absolute;
    bottom: 0;
    right: 0;
}

#chat-toggle::before {
    content: '';
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 2px solid rgba(42, 111, 194, 0.35);
    animation: pulse-ring 2.4s ease-out infinite;
}

@keyframes pulse-ring {
    0%   { transform: scale(0.92); opacity: 0.8; }
    60%  { transform: scale(1.18); opacity: 0; }
    100% { transform: scale(1.18); opacity: 0; }
}

#chat-toggle:hover {
    transform: scale(1.07);
    box-shadow: 0 8px 32px rgba(26, 58, 92, 0.55);
}

#chat-toggle.chat-open::before {
    animation: none;
    opacity: 0;
}

/* ── Chat Window ── */
#chat-window {
    width: 400px;
    border-radius: 20px;
    overflow: hidden;
    box-shadow:
        0 2px 8px rgba(0,0,0,0.06),
        0 12px 40px rgba(0,0,0,0.14),
        0 0 0 1px rgba(0,0,0,0.04);
    display: flex;
    flex-direction: column;
    position: fixed;
    bottom: 108px;
    top: 20px;
    right: 28px;
    background: #ffffff;
    animation: slideUp 0.3s cubic-bezier(0.34, 1.36, 0.64, 1);
}

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

/* ── Header ── */
#chat-header {
    background: linear-gradient(140deg, #0f2740 0%, #1a3a5c 55%, #1e4d7b 100%);
    color: white;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.header-avatar {
    position: relative;
    flex-shrink: 0;
}

#header-logo {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    object-fit: contain;
    background: white;
    padding: 3px;
    display: block;
}

.online-dot {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 11px;
    height: 11px;
    background: #22c55e;
    border-radius: 50%;
    border: 2px solid #1a3a5c;
}

#header-info {
    flex: 1;
    min-width: 0;
}

#header-title {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.2px;
    line-height: 1.2;
}

#header-subtitle {
    font-size: 11.5px;
    opacity: 0.72;
    margin-top: 2px;
    font-weight: 400;
}

#lang-toggle-btn {
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.28);
    color: white;
    height: 30px;
    min-width: 34px;
    padding: 0 10px;
    border-radius: 15px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

#lang-toggle-btn:hover {
    background: rgba(255,255,255,0.24);
}

#close-btn {
    background: rgba(255,255,255,0.1);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
    padding: 0;
}

#close-btn:hover { background: rgba(255,255,255,0.22); }

/* ── Messages Area ── */
#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    background: #f0f2f5;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
}

/* ── Message Bubbles ── */
#chat-messages .user-message,
#chat-messages .bot-message {
    padding: 10px 14px;
    max-width: 88%;
    font-size: 14px;
    line-height: 1.55;
    word-wrap: break-word;
    position: relative;
}

#chat-messages .user-message {
    background: linear-gradient(135deg, #1a3a5c, #1e5190);
    color: white;
    align-self: flex-end;
    border-radius: 18px 18px 4px 18px;
    box-shadow: 0 2px 8px rgba(26, 58, 92, 0.28);
}

#chat-messages .bot-message {
    background: #ffffff;
    color: #1a1a2e;
    align-self: flex-start;
    border-radius: 4px 18px 18px 18px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08), 0 2px 12px rgba(0,0,0,0.05);
}

#chat-messages .error-message {
    background: #fff1f2;
    color: #9f1239;
    border: 1px solid #fecdd3;
    border-radius: 12px;
}

/* ── Markdown inside bot messages ── */
.bot-message .md-h2 {
    display: block;
    font-size: 14.5px;
    font-weight: 700;
    margin: 10px 0 5px;
    color: #0f2740;
}

.bot-message .md-h3 {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin: 8px 0 4px;
    color: #1a3a5c;
}

.bot-message ul,
.bot-message ol {
    margin: 4px 0;
    padding-left: 18px;
}

.bot-message li { margin: 3px 0; }

.bot-message .md-hr {
    border: none;
    border-top: 1.5px solid #e5e7eb;
    margin: 14px 0;
}

.bot-message li.sub-item {
    margin-left: 14px;
    list-style-type: circle;
}

/* ── RTL support ── */
.bot-message[dir="rtl"] { text-align: right; }

.bot-message[dir="rtl"] ul,
.bot-message[dir="rtl"] ol {
    padding-left: 0;
    padding-right: 18px;
}

.bot-message[dir="rtl"] li.sub-item {
    margin-left: 0;
    margin-right: 14px;
}

/* RTL inside property section cards */
[dir="rtl"] .property-title,
[dir="rtl"] .property-details {
    text-align: right;
    direction: rtl;
}

[dir="rtl"] .property-details ul,
[dir="rtl"] .property-details ol {
    padding-left: 0;
    padding-right: 18px;
}

/* ── Language selection buttons ── */
.language-buttons {
    display: flex;
    gap: 10px;
    margin-top: 14px;
}

.lang-btn {
    flex: 1;
    padding: 10px 14px;
    border: 2px solid #1a3a5c;
    border-radius: 12px;
    background: white;
    color: #1a3a5c;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.lang-btn:hover:not(:disabled) {
    background: #1a3a5c;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(26,58,92,0.2);
}

/* ── Typing indicator ── */
.typing-indicator {
    display: flex;
    gap: 5px;
    padding: 12px 16px;
    background: #ffffff;
    border-radius: 4px 18px 18px 18px;
    align-self: flex-start;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    width: fit-content;
}

.typing-indicator span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #9ca3af;
    animation: typing-bounce 1.4s ease-in-out infinite;
}

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

@keyframes typing-bounce {
    0%, 60%, 100% { opacity: 0.4; transform: translateY(0); }
    30%            { opacity: 1;   transform: translateY(-5px); }
}

/* ── Input Area ── */
#chat-input-area {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    background: #ffffff;
    border-top: 1px solid #e9ecef;
    gap: 8px;
    flex-shrink: 0;
}

#chat-input-area input[type="text"] {
    flex: 1;
    border: 1.5px solid #e5e7eb;
    border-radius: 22px;
    padding: 10px 16px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #f8fafc;
    color: #1a1a2e;
    font-family: inherit;
    min-width: 0;
}

#chat-input-area input[type="text"]:focus {
    border-color: #1a3a5c;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(26,58,92,0.08);
}

#chat-input-area input[type="text"]::placeholder {
    color: #9ca3af;
}

#sendButton {
    width: 42px;
    height: 42px;
    min-width: 42px;
    border-radius: 50%;
    background: linear-gradient(140deg, #1a3a5c, #2a6fc2);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
    padding: 0;
    box-shadow: 0 2px 10px rgba(26,58,92,0.3);
}

#sendButton:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 16px rgba(26,58,92,0.4);
}

#sendButton:active { transform: scale(0.96); }

/* ── Property Image Carousel ── */
.property-carousel {
    position: relative;
    width: 100%;
    margin: 10px 0 4px;
    border-radius: 14px 14px 0 0;
    overflow: hidden;
    background: #e5e7eb;
}

.carousel-track {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    height: 190px;
}

.carousel-track::-webkit-scrollbar { display: none; }

.carousel-track img {
    flex: 0 0 100%;
    width: 100%;
    height: 180px;
    object-fit: cover;
    scroll-snap-align: start;
}

.carousel-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(255,255,255,0.92);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    color: #1a3a5c;
    box-shadow: 0 2px 8px rgba(0,0,0,0.18);
    transition: background 0.2s, transform 0.2s;
    z-index: 2;
}

.carousel-nav:hover {
    background: #ffffff;
    transform: translateY(-50%) scale(1.08);
}

.carousel-nav.prev { left: 8px; }
.carousel-nav.next { right: 8px; }

.carousel-dots {
    display: flex;
    justify-content: center;
    gap: 5px;
    padding: 7px 0 3px;
    background: #ffffff;
}

.carousel-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #d1d5db;
    border: none;
    padding: 0;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
}

.carousel-dot.active {
    background: #1a3a5c;
    transform: scale(1.3);
}

/* ── Property Section (one project block) ── */
.property-section {
    background: #ffffff;
    border-radius: 14px;
    padding: 12px 12px 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.06);
    border: 1px solid #eef2f7;
    margin-bottom: 10px;
    overflow: hidden;
}

.property-title {
    font-size: 15px;
    font-weight: 700;
    color: #0f2740;
    margin-bottom: 6px;
}

.property-details {
    margin-top: 8px;
    font-size: 13.5px;
}

/* ── Property Media Block ── */
.property-media-block {
    margin: 8px -12px 0; /* bleed to card edges, gap after title */
    overflow: hidden;
    border: none;
}

/* ── PDF Download Button ── */
.pdf-download-btn {
    justify-content: center;
    font-size: 13.5px;
    font-weight: 600;
    background: #f1f5f9;
    border-top: 1px solid #e5e7eb;
}

.pdf-download-btn:hover {
    background: #e2e8f0;
}

.pdf-download-btn svg { flex-shrink: 0; }

/* ── Load More Button ── */
.load-more-btn {
    display: block;
    width: 100%;
    padding: 10px 16px;
    margin-top: 12px;
    background: #1e3a5f;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}
.load-more-btn:hover {
    background: #2c5282;
}

/* ── Scrollbar ── */
#chat-messages::-webkit-scrollbar { width: 5px; }
#chat-messages::-webkit-scrollbar-track { background: transparent; }
#chat-messages::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}
#chat-messages::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* ── Responsive ── */
@media (max-width: 540px) {
    #chatbot-container {
        right: 16px;
        bottom: 16px;
    }

    #chat-window {
        width: calc(100vw - 24px);
        right: 12px;
        left: 12px;
        top: 10px;
        bottom: 90px;
        border-radius: 16px;
    }
}

/* ── Suggestions Bar ── */
#suggestions-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 12px;
    border-top: 1px solid #f0f0f0;
    background: #fff;
    overflow-x: auto;
}
.suggestion-chip {
    white-space: nowrap;
    padding: 6px 14px;
    border: 1.5px solid #dde3ea;
    border-radius: 20px;
    background: #f7f9fb;
    color: #1a3a5c;
    font-size: 12.5px;
    cursor: pointer;
    transition: all 0.18s;
    flex-shrink: 0;
}
.suggestion-chip:hover {
    background: #1a3a5c;
    color: #fff;
    border-color: #1a3a5c;
}
.suggestion-chip.highlight {
    background: #1a3a5c;
    color: #fff;
    border-color: #1a3a5c;
}
.suggestion-chip.highlight:hover {
    background: #0f2540;
    border-color: #0f2540;
}

/* ── Commission Unit Selection ── */
.commission-unit-selection {
    margin-top: 10px;
}
.commission-select-label {
    font-size: 13px;
    color: #555;
    margin-bottom: 8px;
}
.unit-type-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.unit-type-btn {
    padding: 6px 14px;
    border: 1px solid #1a3a5c;
    border-radius: 16px;
    background: white;
    color: #1a3a5c;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}
.unit-type-btn:hover {
    background: #1a3a5c;
    color: white;
}
