/* AI Chat Widget Styles */
.chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    font-family: 'Montserrat', Arial, sans-serif;
}

/* Greeting bubble */
.chat-greeting {
    position: absolute;
    right: 0;
    bottom: 70px; /* sit above the 60px toggle with ~10px gap */
    background: #fff;
    color: #1f2937;
    border-radius: 10px; /* more rectangular */
    box-shadow: 0 10px 30px rgba(0,0,0,.15);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    flex-direction: row;
    gap: 14px;
    width: 260px;
    max-width: calc(100vw - 120px);
}
.chat-greeting .greeting-avatar img{
    width: 44px; height: 44px; border-radius: 50%; display:block; box-shadow: 0 2px 8px rgba(0,0,0,.12);
}
.chat-greeting .greeting-content{ display:block; }
.chat-greeting .greeting-text{
    font-size:16px;
    line-height:1.45;
    font-weight: 600;
    color:#1f2937;
    display: -webkit-box;
    -webkit-line-clamp: 2; /* limit to two lines */
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.chat-greeting .greeting-tail{
    position:absolute; bottom:-8px; right:28px; width:16px; height:16px; background:#fff; transform: rotate(45deg);
    box-shadow: 4px 4px 12px rgba(0,0,0,.08);
}

.chat-toggle {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--accent-gold, #e6c800), var(--primary-green, #1b5e20));
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(44, 90, 160, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.chat-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(44, 90, 160, 0.4);
}

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

.chat-icon {
    width: 24px;
    height: 24px;
    fill: white;
    transition: transform 0.3s ease;
}

.chat-toggle.active .chat-icon {
    transform: rotate(45deg);
}

.chat-toggle .notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4757;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    animation: pulse 2s infinite;
}

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

.chat-container {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 350px;
    height: 500px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(20px) scale(0.9);
    opacity: 0;
    transition: all 0.3s ease;
}

.chat-container.active {
    display: flex;
    transform: translateY(0) scale(1);
    opacity: 1;
}

.chat-header {
    background: linear-gradient(135deg, var(--primary-green, #1b5e20) 0%, var(--deep-emerald, #064e3b) 100%);
    color: white;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.chat-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    opacity: 0.9;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.chat-message {
    display: flex;
    gap: 10px;
    animation: slideIn 0.3s ease;
}

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

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
    flex-shrink: 0;
}

.message-avatar.user {
    background: #e2e8f0;
    color: #475569;
}

.message-avatar.assistant {
    background: #fff;
    color: transparent;
    border: 1px solid #e5e7eb;
    overflow: hidden;
}
.message-avatar.assistant img{ width:100%; height:100%; object-fit: cover; border-radius: 50%; display:block; }

.message-content {
    flex: 1;
    background: white;
    padding: 12px 16px;
    border-radius: 18px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    position: relative;
}

.message-content.user {
    background: linear-gradient(135deg, var(--accent-gold, #e6c800), var(--primary-green, #1b5e20));
    color: white;
    margin-left: auto;
    max-width: 80%;
}

.message-content.assistant {
    background: white;
    color: #374151;
    max-width: 85%;
}

.message-image {
    max-width: 100%;
    border-radius: 12px;
    margin-top: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: white;
    border-radius: 18px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    max-width: 85%;
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: #9ca3af;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

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

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

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

.chat-input-container {
    padding: 16px 12px;
    background: white;
    border-top: 1px solid #e2e8f0;
    display: block;
}

/* Make the textbox wrapper grow to occupy more horizontal space */
.chat-input-container > div { width: 100%; }

.chat-input-row{
    display: flex;
    gap: 10px;
    align-items: center;
}

.chat-input {
    flex: 1;
    border: 2px solid #e2e8f0;
    border-radius: 25px;
    padding: 16px 20px;
    font-size: 16px;
    font-family: inherit;
    resize: none;
    overflow: hidden; /* hide scrollbars */
    min-height: 64px;
    outline: none;
    transition: border-color 0.3s ease;
}

.chat-input:focus {
    border-color: #2c5aa0;
}

.chat-input::placeholder {
    color: #9ca3af;
}

.chat-send-btn {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--accent-gold, #e6c800), var(--primary-green, #1b5e20));
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.chat-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(44, 90, 160, 0.3);
}

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

.chat-actions {
    display: flex;
    gap: 10px;
    margin: 0 0 10px 0;
}

.chat-action-btn {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 12px;
    color: #475569;
    cursor: pointer;
    transition: all 0.3s ease;
}

.chat-action-btn:hover {
    background: #e2e8f0;
    color: #2c5aa0;
}

.chat-action-btn.active {
    background: #2c5aa0;
    color: white;
    border-color: #2c5aa0;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .chat-widget {
        bottom: 15px;
        right: 15px;
    }
    
    .chat-container {
        width: calc(100vw - 30px);
        height: calc(100vh - 100px);
        bottom: 85px;
        right: 0;
        border-radius: 20px 20px 0 0;
    }
    .chat-greeting{ right: 0; bottom: 70px; max-width: calc(100vw - 120px); }
    
    .chat-toggle {
        width: 50px;
        height: 50px;
    }
    
    .chat-icon {
        width: 20px;
        height: 20px;
    }
}

/* Scrollbar Styling */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

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

.chat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Loading Animation */
.loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #2c5aa0;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Error Message Styling */
.error-message {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    margin: 10px 0;
}

/* Success Message Styling */
.success-message {
    background: #f0fdf4;
    color: #16a34a;
    border: 1px solid #bbf7d0;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    margin: 10px 0;
}
