/* Chatbot Widget Styles */

/* Variables */
:root {
    --chatbot-primary: #2563eb;
    --chatbot-primary-dark: #1e40af;
    --chatbot-bg: #ffffff;
    --chatbot-bg-light: #f3f4f6;
    --chatbot-text: #1f2937;
    --chatbot-text-muted: #6b7280;
    --chatbot-border: #e5e7eb;
    --chatbot-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    --chatbot-radius: 16px;
}

/* Widget Container */
.chatbot-widget {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 9999;
    font-family: 'Cairo', sans-serif;
}

/* Toggle Button */
.chatbot-toggle-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--chatbot-primary), var(--chatbot-primary-dark));
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: var(--chatbot-shadow);
    transition: all 0.3s ease;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chatbot-toggle-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 45px rgba(0, 0, 0, 0.2);
}

.chatbot-toggle-btn.active .chatbot-icon-open {
    display: none;
}

.chatbot-toggle-btn.active .chatbot-icon-close {
    display: block !important;
}

/* Badge */
.chatbot-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
}

/* Chat Window */
.chatbot-window {
    position: absolute;
    bottom: 80px;
    left: 0;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 550px;
    max-height: calc(100vh - 120px);
    background: var(--chatbot-bg);
    border-radius: var(--chatbot-radius);
    box-shadow: var(--chatbot-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: chatbot-slide-up 0.3s ease;
}

@keyframes chatbot-slide-up {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Header */
.chatbot-header {
    background: linear-gradient(135deg, var(--chatbot-primary), var(--chatbot-primary-dark));
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chatbot-header-info {
    display: flex;
    align-items: center;
    font-size: 1.1rem;
    font-weight: 600;
}

.chatbot-header-actions {
    display: flex;
    gap: 8px;
}

.chatbot-action-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

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

/* Messages Container */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: var(--chatbot-bg-light);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Message Bubble */
.chatbot-message {
    max-width: 85%;
    animation: chatbot-message-in 0.3s ease;
}

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

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

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

.chatbot-message-content {
    padding: 12px 16px;
    border-radius: 16px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.chatbot-message.bot .chatbot-message-content {
    background: var(--chatbot-bg);
    color: var(--chatbot-text);
    border-bottom-right-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.chatbot-message.user .chatbot-message-content {
    background: var(--chatbot-primary);
    color: white;
    border-bottom-left-radius: 4px;
}

.chatbot-message-time {
    font-size: 0.7rem;
    color: var(--chatbot-text-muted);
    margin-top: 4px;
    padding: 0 8px;
}

.chatbot-message.user .chatbot-message-time {
    text-align: left;
}

/* Typing Indicator */
.chatbot-typing {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: var(--chatbot-bg);
    border-radius: 16px;
    width: fit-content;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.chatbot-typing span {
    width: 8px;
    height: 8px;
    background: var(--chatbot-text-muted);
    border-radius: 50%;
    animation: chatbot-typing-dot 1.4s infinite;
}

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

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

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

/* Buttons */
.chatbot-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.chatbot-btn {
    padding: 10px 16px;
    border-radius: 20px;
    border: 2px solid var(--chatbot-primary);
    background: var(--chatbot-bg);
    color: var(--chatbot-primary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

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

.chatbot-btn i {
    font-size: 1rem;
}

/* Property Cards */
.chatbot-cards {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 12px;
    width: 100%;
}

.chatbot-property-card {
    background: var(--chatbot-bg);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
}

.chatbot-property-image {
    position: relative;
    height: 120px;
}

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

.chatbot-property-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    background: #22c55e;
    color: white;
}

.chatbot-property-badge.rent {
    background: #f59e0b;
}

.chatbot-property-info {
    padding: 12px;
}

.chatbot-property-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0 0 4px;
    color: var(--chatbot-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chatbot-property-location {
    font-size: 0.8rem;
    color: var(--chatbot-text-muted);
    margin: 0 0 8px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.chatbot-property-price {
    font-size: 1rem;
    font-weight: 700;
    color: var(--chatbot-primary);
    margin: 0 0 8px;
}

.chatbot-property-features {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

.chatbot-property-features .feature {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8rem;
    color: var(--chatbot-text-muted);
}

.chatbot-property-link {
    width: 100%;
    text-align: center;
    padding: 8px;
    font-size: 0.85rem;
}

/* Visit Request Cards */
.chatbot-visit-card {
    background: var(--chatbot-bg);
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-top: 8px;
}

.chatbot-visit-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.chatbot-visit-property {
    font-weight: 600;
    color: var(--chatbot-text);
}

.chatbot-visit-info p {
    margin: 4px 0;
    font-size: 0.85rem;
    color: var(--chatbot-text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
}

.chatbot-visit-info i {
    width: 16px;
    text-align: center;
}

.chatbot-visit-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.chatbot-visit-actions .btn {
    flex: 1;
}

/* Input Area */
.chatbot-input-area {
    padding: 12px 16px;
    background: var(--chatbot-bg);
    border-top: 1px solid var(--chatbot-border);
}

.chatbot-form {
    display: flex;
    gap: 8px;
    align-items: center;
}

.chatbot-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--chatbot-border);
    border-radius: 24px;
    font-size: 0.95rem;
    font-family: 'Cairo', sans-serif;
    outline: none;
    transition: border-color 0.2s;
}

.chatbot-input:focus {
    border-color: var(--chatbot-primary);
}

.chatbot-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--chatbot-primary);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.chatbot-send-btn:hover {
    background: var(--chatbot-primary-dark);
    transform: scale(1.05);
}

.chatbot-send-btn:disabled {
    background: var(--chatbot-border);
    cursor: not-allowed;
    transform: none;
}

/* Responsive - Tablet */
@media (max-width: 768px) {
    .chatbot-widget {
        bottom: 16px;
        left: 16px;
    }

    .chatbot-toggle-btn {
        width: 56px;
        height: 56px;
        font-size: 1.3rem;
    }

    .chatbot-window {
        width: 340px;
        height: 500px;
        bottom: 75px;
    }
}

/* Responsive - Mobile */
@media (max-width: 576px) {
    .chatbot-widget {
        bottom: 12px;
        left: 12px;
        right: 12px;
    }

    .chatbot-toggle-btn {
        width: 52px;
        height: 52px;
        font-size: 1.2rem;
    }

    .chatbot-window {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        animation: chatbot-slide-up-mobile 0.3s ease;
    }

    @keyframes chatbot-slide-up-mobile {
        from {
            opacity: 0;
            transform: translateY(100%);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    .chatbot-header {
        padding: 14px 16px;
    }

    .chatbot-messages {
        padding: 12px;
    }

    .chatbot-message {
        max-width: 90%;
    }

    .chatbot-input-area {
        padding: 10px 12px;
        /* Account for mobile keyboard */
        padding-bottom: calc(10px + env(safe-area-inset-bottom));
    }

    .chatbot-input {
        padding: 10px 14px;
        font-size: 1rem;
    }

    .chatbot-btn {
        padding: 8px 12px;
        font-size: 0.85rem;
    }

    .chatbot-property-card {
        flex-direction: row;
    }

    .chatbot-property-image {
        width: 100px;
        height: auto;
        min-height: 100px;
    }

    .chatbot-property-info {
        flex: 1;
        padding: 10px;
    }

    .chatbot-property-title {
        font-size: 0.9rem;
    }

    .chatbot-property-price {
        font-size: 0.95rem;
    }

    .chatbot-property-features {
        gap: 8px;
    }
}

/* Touch device optimizations */
@media (hover: none) {
    .chatbot-toggle-btn:hover {
        transform: none;
    }

    .chatbot-btn:hover {
        background: var(--chatbot-bg);
        color: var(--chatbot-primary);
    }

    .chatbot-btn:active {
        background: var(--chatbot-primary);
        color: white;
    }

    .chatbot-send-btn:hover {
        transform: none;
    }

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

/* RTL Specific */
[dir="rtl"] .chatbot-widget {
    left: auto;
    right: 20px;
}

[dir="rtl"] .chatbot-window {
    left: auto;
    right: 0;
}

[dir="rtl"] .chatbot-message.bot .chatbot-message-content {
    border-bottom-right-radius: 16px;
    border-bottom-left-radius: 4px;
}

[dir="rtl"] .chatbot-message.user .chatbot-message-content {
    border-bottom-left-radius: 16px;
    border-bottom-right-radius: 4px;
}

[dir="rtl"] .chatbot-message.user .chatbot-message-time {
    text-align: right;
}

[dir="rtl"] .chatbot-badge {
    right: auto;
    left: -5px;
}

[dir="rtl"] .chatbot-property-badge {
    right: auto;
    left: 8px;
}

@media (max-width: 576px) {
    [dir="rtl"] .chatbot-widget {
        left: 12px;
        right: 12px;
    }
}

/* Dark mode support (if needed in future) */
@media (prefers-color-scheme: dark) {
    /* Can add dark mode styles here */
}

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