/* Makaziflo AI Chat Widget */

:root {
    --chat-primary: #0a1628;
    --chat-accent: #b8860b;
    --chat-bg: #ffffff;
    --chat-user-bg: #0a1628;
    --chat-bot-bg: #f1f5f9;
    --chat-text: #1a2b3c;
    --chat-muted: #6b7a8d;
    --chat-border: #e2e8f0;
    --chat-shadow: 0 20px 60px rgba(10, 22, 40, 0.25);
}

/* Toggle Button */
.chat-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--chat-primary);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(10, 22, 40, 0.3);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 22px;
}

.chat-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(10, 22, 40, 0.4);
}

.chat-toggle.active {
    background: var(--chat-accent);
    transform: rotate(90deg);
}

.chat-toggle .badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 18px;
    height: 18px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

/* Chat Window */
.chat-window {
    position: fixed;
    bottom: 92px;
    right: 24px;
    width: 400px;
    max-width: calc(100vw - 48px);
    height: 560px;
    max-height: calc(100vh - 140px);
    background: var(--chat-bg);
    border-radius: 16px;
    box-shadow: var(--chat-shadow);
    z-index: 9997;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid var(--chat-border);
}

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

/* Header */
.chat-header {
    background: var(--chat-primary);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.chat-header-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--chat-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.chat-header-info h3 {
    font-size: 14px;
    font-weight: 700;
    margin: 0;
    font-family: 'Poppins', sans-serif;
}

.chat-header-info p {
    font-size: 11px;
    opacity: 0.7;
    margin: 2px 0 0 0;
}

.chat-header-status {
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    display: inline-block;
    margin-right: 4px;
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Messages Area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
    width: 4px;
}

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

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

/* Message Bubble */
.chat-msg {
    display: flex;
    gap: 8px;
    max-width: 88%;
    animation: msg-in 0.25s ease-out;
}

@keyframes msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

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

.chat-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    flex-shrink: 0;
    margin-top: 2px;
}

.chat-msg.bot .chat-msg-avatar {
    background: var(--chat-accent);
    color: white;
}

.chat-msg.user .chat-msg-avatar {
    background: var(--chat-primary);
    color: white;
}

.chat-msg-bubble {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.5;
    word-wrap: break-word;
}

.chat-msg.bot .chat-msg-bubble {
    background: var(--chat-bot-bg);
    color: var(--chat-text);
    border-bottom-left-radius: 4px;
}

.chat-msg.user .chat-msg-bubble {
    background: var(--chat-user-bg);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-msg-bubble a {
    color: var(--chat-accent);
    text-decoration: underline;
}

.chat-msg.user .chat-msg-bubble a {
    color: #93c5fd;
}

.chat-msg-bubble p {
    margin: 0 0 8px 0;
}

.chat-msg-bubble p:last-child {
    margin-bottom: 0;
}

.chat-msg-bubble strong {
    font-weight: 600;
}

.chat-msg-bubble code {
    background: rgba(0,0,0,0.06);
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 12px;
}

.chat-msg-time {
    font-size: 10px;
    color: var(--chat-muted);
    margin-top: 4px;
    text-align: right;
}

.chat-msg.user .chat-msg-time {
    text-align: left;
}

/* Typing Indicator */
.chat-typing {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    background: var(--chat-bot-bg);
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    width: fit-content;
}

.chat-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--chat-muted);
    animation: typing-bounce 1.2s infinite;
}

.chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing span:nth-child(3) { animation-delay: 0.3s; }

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

/* Suggestions */
.chat-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 16px;
    border-top: 1px solid var(--chat-border);
}

.chat-suggestion {
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid var(--chat-border);
    background: white;
    color: var(--chat-primary);
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.chat-suggestion:hover {
    background: var(--chat-primary);
    color: white;
    border-color: var(--chat-primary);
}

/* Input Area */
.chat-input-area {
    padding: 12px 16px;
    border-top: 1px solid var(--chat-border);
    display: flex;
    gap: 8px;
    align-items: flex-end;
    background: white;
    flex-shrink: 0;
}

.chat-input {
    flex: 1;
    border: 1px solid var(--chat-border);
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 13px;
    font-family: 'Manrope', sans-serif;
    resize: none;
    max-height: 80px;
    line-height: 1.4;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input:focus {
    border-color: var(--chat-accent);
}

.chat-input::placeholder {
    color: var(--chat-muted);
}

.chat-send {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--chat-primary);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
    font-size: 14px;
}

.chat-send:hover {
    background: var(--chat-accent);
}

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

/* Responsive */
@media (max-width: 480px) {
    .chat-window {
        right: 0;
        bottom: 0;
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    .chat-toggle {
        bottom: 16px;
        right: 16px;
    }
}

/* Markdown in messages */
.chat-msg-bubble ul,
.chat-msg-bubble ol {
    margin: 4px 0;
    padding-left: 20px;
}

.chat-msg-bubble li {
    margin-bottom: 2px;
}

/* Property cards in chat */
.chat-property-card {
    background: white;
    border: 1px solid var(--chat-border);
    border-radius: 8px;
    padding: 10px;
    margin-top: 8px;
}

.chat-property-card .name {
    font-weight: 600;
    font-size: 13px;
    color: var(--chat-primary);
}

.chat-property-card .details {
    font-size: 11px;
    color: var(--chat-muted);
    margin-top: 4px;
}

.chat-property-card .link {
    display: inline-block;
    margin-top: 6px;
    font-size: 11px;
    color: var(--chat-accent);
    text-decoration: none;
    font-weight: 600;
}

.chat-notifications {
    font-size: 12px;
    line-height: 1.5;
}

.chat-notification {
    padding: 4px 0;
    border-bottom: 1px solid var(--chat-border);
    font-size: 12px;
}

.chat-notification:last-child {
    border-bottom: none;
}