/* Chat Bubble */
#aichat-bubble {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #66cbea91 0%, #f562c9 100%);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
    transition: all 0.3s ease;
}

#aichat-bubble:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

#aichat-bubble svg {
    width: 28px;
    height: 28px;
    fill: white;
}

/* Initial Notification */
#aichat-notification {
    position: fixed;
    bottom: 90px;
    right: 20px;
    max-width: 300px;
    background: white;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 9997;
    display: none;
    cursor: pointer;
    transition: all 0.3s ease;
}

#aichat-notification:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.aichat-notification-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.aichat-notification-title {
    font-weight: 600;
    font-size: 14px;
    color: #1a202c;
}

#aichat-notification-close {
    background: none;
    border: none;
    font-size: 20px;
    color: #a0aec0;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

#aichat-notification-close:hover {
    color: #4a5568;
}

.aichat-notification-text {
    font-size: 13px;
    color: #4a5568;
    line-height: 1.5;
}

/* Chat Widget */
#aichat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 380px;
    height: 550px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: scale(0.8) translateY(20px);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

#aichat-widget.open {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: all;
}

/* Header */
#aichat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px 20px;
    border-radius: 16px 16px 0 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.aichat-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.aichat-logo {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.aichat-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.aichat-logo svg {
    width: 20px;
    height: 20px;
    fill: #667eea;
}

.aichat-header-text h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.aichat-header-text p {
    margin: 0;
    font-size: 12px;
    opacity: 0.9;
}

#aichat-close {
    background: rgba(255, 255, 255, 0.2);
    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;
}

#aichat-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Messages Area */
#aichat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f7fafc;
}

#aichat-messages::-webkit-scrollbar {
    width: 6px;
}

#aichat-messages::-webkit-scrollbar-track {
    background: transparent;
}

#aichat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

#aichat-messages::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* Message Styles */
.aichat-message {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 12px;
    line-height: 1.5;
    font-size: 14px;
    word-wrap: break-word;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.aichat-user-message {
    background: linear-gradient(135deg, #72c1e6a4 0%, #8289f1 100%);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.aichat-bot-message {
    background: white;
    color: #2d3748;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.aichat-message-text {
    margin-bottom: 0;
}

.aichat-message-text strong {
    font-weight: 600;
    color: inherit;
}

.aichat-message-text em {
    font-style: italic;
}

.aichat-message-text a {
    color: #4F46E5;
    text-decoration: underline;
}

.aichat-message-text a:hover {
    color: #3730a3;
}

.aichat-list-item {
    margin: 4px 0;
    padding-left: 8px;
}

/* Buttons */
.aichat-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.aichat-button {
    display: inline-block;
    padding: 10px 16px;
    background: linear-gradient(135deg, #d4428ba4 0%, #e45763 100%);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    text-align: center;
    transition: all 0.2s;
}

.aichat-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
    color: white;
}

/* Typing Indicator */
.aichat-typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: white;
    border-radius: 12px;
    align-self: flex-start;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.aichat-typing-indicator span {
    width: 8px;
    height: 8px;
    background: #cbd5e0;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.aichat-typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.aichat-typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-10px);
    }
}

/* Input Area */
#aichat-input-area {
    padding: 16px 20px;
    border-top: 1px solid #e2e8f0;
    background: white;
    border-radius: 0 0 16px 16px;
}

.aichat-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

#aichat-input {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 14px;
    resize: none;
    max-height: 100px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    transition: border-color 0.2s;
}

#aichat-input:focus {
    outline: none;
    border-color: #667eea;
}

.aichat-input-buttons {
    display: flex;
    gap: 8px;
}

#aichat-mic, #aichat-send {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

#aichat-mic {
    background: #f7fafc;
    color: #4a5568;
}

#aichat-mic:hover {
    background: #edf2f7;
}

#aichat-mic.recording {
    background: #fc8181;
    color: white;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

#aichat-send {
    background: linear-gradient(135deg, #ee659e8f 0%, #e6416a 100%);
    color: white;
}

#aichat-send:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
}

#aichat-mic svg, #aichat-send svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* Responsive */
@media (max-width: 480px) {
    #aichat-widget {
        width: 100vw;
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height for mobile browsers */
        right: 0;
        bottom: 0;
        border-radius: 0;
        max-height: 100vh;
        max-height: 100dvh;
    }
    
    #aichat-widget.open {
        transform: scale(1) translateY(0);
    }
    
    #aichat-bubble {
        bottom: 16px;
        right: 16px;
        width: 56px;
        height: 56px;
    }
    
    #aichat-bubble svg {
        width: 24px;
        height: 24px;
    }
    
    #aichat-notification {
        right: 16px;
        bottom: 80px;
        max-width: calc(100vw - 32px);
    }
    
    #aichat-messages {
        padding: 12px;
    }
    
    .aichat-message {
        font-size: 15px;
        max-width: 85%;
    }
    
    #aichat-input {
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .aichat-button {
        font-size: 13px;
        padding: 10px 16px;
    }
}

/* GDPR Badge (optional) */
.aichat-gdpr-badge {
    font-size: 11px;
    color: #a0aec0;
    text-align: center;
    padding: 8px;
    border-top: 1px solid #e2e8f0;
}