/* ===================================
   AI Chatbot Professional Styles
   Exclusive Premium Design
   =================================== */

/* === Floating Chat Button === */
.ai-chat-fab {
    position: fixed;
    bottom: 90px;
    left: 20px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #047857 0%, #064E3B 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 8px 25px rgba(4, 120, 87, 0.4);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 9998;
    animation: bobFloat 3s ease-in-out infinite;
}

.ai-chat-fab:hover {
    transform: scale(1.1) translateY(-3px);
    box-shadow: 0 12px 35px rgba(4, 120, 87, 0.6);
}

.ai-pulse {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: #047857;
    opacity: 0.6;
    animation: pulse 2s infinite;
}

.ai-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #D97706;
    color: white;
    font-size: 0.65rem;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(217, 119, 6, 0.5);
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 0.6;
    }

    50% {
        transform: scale(1.15);
        opacity: 0;
    }
}

@keyframes bobFloat {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

/* === Chat Modal === */
.ai-chat-modal {
    position: fixed;
    bottom: 20px;
    left: 20px;
    width: 420px;
    height: 650px;
    background: white;
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: none;
    flex-direction: column;
    z-index: 9999;
    overflow: hidden;
    animation: slideUpFade 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.ai-chat-modal.active {
    display: flex;
}

.ai-chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

@keyframes slideUpFade {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* === Chat Header === */
.ai-chat-header {
    background: linear-gradient(135deg, #047857 0%, #064E3B 100%);
    padding: 1.2rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
}

.ai-chat-header::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
    animation: shimmer 3s linear infinite;
}

@keyframes shimmer {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.ai-header-content {
    display: flex;
    align-items: center;
    gap: 1rem;
    position: relative;
    z-index: 1;
}

.ai-avatar {
    position: relative;
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
}

.ai-avatar-ring {
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
    animation: rotate 3s linear infinite;
}

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.ai-header-text h3 {
    color: white;
    font-size: 1.1rem;
    margin: 0;
    font-weight: 800;
}

.ai-status {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.85rem;
    margin: 0.2rem 0 0 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #10B981;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.ai-close-btn {
    background: rgba(255, 255, 255, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.8rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    position: relative;
    z-index: 10;
    margin-left: 10px;
    backdrop-filter: blur(4px);
}

.ai-close-btn:hover {
    background: #EF4444;
    /* Red color on hover */
    border-color: #EF4444;
    transform: rotate(90deg) scale(1.1);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

/* === Messages Area === */
.ai-messages {
    flex: 1;
    min-height: 0;
    padding: 1.5rem;
    overflow-y: auto;
    overflow-x: hidden;
    background: #F9FAFB;
    scroll-behavior: smooth;
}

.ai-messages::-webkit-scrollbar {
    width: 6px;
}

.ai-messages::-webkit-scrollbar-thumb {
    background: #CBD5E1;
    border-radius: 10px;
}

.ai-welcome {
    background: linear-gradient(135deg, #ECFDF5 0%, #D1FAE5 100%);
    padding: 2rem 1.5rem;
    border-radius: 16px;
    text-align: center;
    margin-bottom: 1.5rem;
}

.welcome-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.ai-welcome h4 {
    color: #064E3B;
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
}

.ai-welcome p {
    color: #047857;
    font-size: 0.9rem;
}

.ai-message {
    display: flex;
    gap: 0.8rem;
    margin-bottom: 1.5rem;
    animation: fadeInUp 0.3s ease-out;
}

.ai-message.typing-indicator {
    animation: none;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.user-message {
    flex-direction: row-reverse;
}

.message-avatar {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #047857, #064E3B);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.message-content {
    flex: 1;
    max-width: 75%;
}

.user-message .message-content {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.message-text {
    background: white;
    padding: 0.9rem 1.1rem;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    line-height: 1.6;
    font-size: 0.95rem;
    color: #1F2937;
}

.user-message .message-text {
    background: linear-gradient(135deg, #047857 0%, #059669 100%);
    color: white;
    border-radius: 16px 16px 4px 16px;
}

.ai-message .message-text {
    border-radius: 16px 16px 16px 4px;
}

/* Typing Indicator */
.typing-dots {
    display: flex;
    gap: 5px;
    padding: 1rem;
    background: white;
    border-radius: 16px 16px 16px 4px;
    width: fit-content;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: #94A3B8;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.7;
    }

    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* === Result Cards === */
.ai-results-grid {
    display: grid;
    gap: 0.8rem;
    margin-top: 1rem;
}

.ai-result-card {
    background: white;
    border: 2px solid #E2E8F0;
    border-radius: 12px;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.3s;
}

.ai-result-card:hover {
    border-color: #047857;
    box-shadow: 0 4px 12px rgba(4, 120, 87, 0.15);
    transform: translateY(-2px);
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 0.5rem;
}

.result-header h4 {
    font-size: 1rem;
    color: #064E3B;
    margin: 0;
    flex: 1;
}

.result-badge {
    font-size: 0.65rem;
    padding: 3px 8px;
    border-radius: 8px;
    font-weight: 800;
    text-transform: uppercase;
}

.result-badge.vip {
    background: #FEF3C7;
    color: #92400E;
}

.result-badge.pro {
    background: #DBEAFE;
    color: #1E40AF;
}

.result-location,
.result-category {
    font-size: 0.85rem;
    color: #64748B;
    margin: 0.3rem 0;
}

.result-whatsapp {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: #25D366;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 700;
    margin-top: 0.8rem;
    transition: 0.3s;
}

.result-whatsapp:hover {
    background: #1fb855;
    transform: translateY(-1px);
}

/* === Quick Actions === */
.ai-quick-actions {
    padding: 1rem 1.5rem;
    background: white;
    border-top: 1px solid #E5E7EB;
    display: flex;
    gap: 0.6rem;
    overflow-x: auto;
}

.ai-quick-actions::-webkit-scrollbar {
    height: 4px;
}

.quick-btn {
    background: #F1F5F9;
    border: 1px solid #E2E8F0;
    color: #475569;
    padding: 0.6rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
}

.quick-btn:hover {
    background: #047857;
    color: white;
    border-color: #047857;
    transform: translateY(-2px);
}

/* === Input Area === */
.ai-input-container {
    background: white;
    border-top: 1px solid #E5E7EB;
    padding: 1rem 1.5rem;
}

.ai-input-wrapper {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    background: #F9FAFB;
    border: 2px solid #E2E8F0;
    border-radius: 24px;
    padding: 0.6rem 1rem;
    transition: 0.3s;
}

.ai-input-wrapper:focus-within {
    border-color: #047857;
    background: white;
}

#aiInput {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 0.95rem;
    outline: none;
    font-family: 'Almarai', sans-serif;
    color: #1F2937;
}

#aiInput::placeholder {
    color: #9CA3AF;
}

.ai-send-btn {
    background: linear-gradient(135deg, #047857 0%, #064E3B 100%);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.3s;
}

.ai-send-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(4, 120, 87, 0.3);
}

.ai-suggestions {
    margin-top: 0.5rem;
}

.suggestion-item {
    background: white;
    border: 1px solid #E2E8F0;
    padding: 0.6rem 1rem;
    border-radius: 8px;
    margin-bottom: 0.4rem;
    cursor: pointer;
    font-size: 0.9rem;
    color: #475569;
    transition: 0.3s;
}

.suggestion-item:hover {
    background: #F0FDF4;
    border-color: #047857;
    color: #047857;
}

/* === Mobile Responsive Optimization === */
@media (max-width: 768px) {
    .ai-chat-modal {
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: 100%;
        /* Full screen height */
        height: 100dvh;
        /* Dynamic viewport height for modern browsers */
        border-radius: 0;
        max-width: none;
        z-index: 99999;
        /* Ensure it's on top of everything */
    }

    .ai-chat-container {
        height: 100%;
        width: 100%;
    }

    .ai-chat-header {
        padding-top: max(1.2rem, env(safe-area-inset-top));
        /* Safe area for Notch */
        padding-bottom: 1rem;
    }

    .ai-messages {
        padding-bottom: 2rem;
    }

    /* Prevent iOS Zoom on input focus */
    .ai-input-wrapper {
        border-radius: 20px;
    }

    #aiInput {
        font-size: 16px;
        /* Prevents auto-zoom on iOS */
        padding: 8px 0;
    }

    .ai-chat-fab {
        bottom: 20px;
        right: 20px;
        left: auto;
        width: 55px;
        height: 55px;
        box-shadow: 0 4px 15px rgba(4, 120, 87, 0.4);
    }

    /* Mobile Quick Actions Scroll */
    .ai-quick-actions {
        padding-bottom: 1.5rem;
        /* Better thumb reach */
        -webkit-overflow-scrolling: touch;
    }

    /* Better Close Button Position on Mobile */
    .ai-close-btn {
        width: 40px;
        height: 40px;
        font-size: 2rem;
        background: rgba(255, 255, 255, 0.2);
    }

    .ai-input-container {
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
        /* Safe area for Home Indicator */
    }
}