/* CSS Variables for Theme Management */
:root {
    --ai-chat-accent: #6366f1;
    --ai-chat-secondary: #8b5cf6;
    --ai-chat-bg-primary: #ffffff;
    --ai-chat-bg-secondary: #f7f7f8;
    --ai-chat-border: rgba(255, 255, 255, 0.8);
    --ai-chat-shadow: rgba(0, 0, 0, 0.1);
    --ai-chat-text-primary: #333333;
    --ai-chat-text-secondary: #666666;
}

/* AI Chat Widget Styles */
#ai-chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
}

/* Floating Action Button (FAB) - Gradient */
.ai-chat-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--ai-chat-accent) 0%, var(--ai-chat-secondary) 100%);
    border: none;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    animation: pulse-soft 3s infinite;
    position: relative;
    overflow: hidden;
}

.ai-chat-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0) 100%);
    opacity: 0;
    transition: opacity 0.3s;
}

.ai-chat-btn:hover::before {
    opacity: 1;
}

.ai-chat-btn svg {
    color: white;
    width: 32px;
    height: 32px;
    position: relative;
    z-index: 1;
}

@keyframes pulse-soft {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 4px 20px rgba(99, 102, 241, 0.3);
    }
    50% {
        transform: scale(1.02);
        box-shadow: 0 8px 28px rgba(99, 102, 241, 0.4);
    }
}

.ai-chat-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 10px 35px rgba(99, 102, 241, 0.5);
    animation: none;
}

.ai-chat-btn.hidden {
    opacity: 0;
    transform: scale(0);
    pointer-events: none;
}

/* Chat Box - Glassmorphism */
.ai-chat-box {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 380px;
    height: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.9);
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    transform-origin: bottom right;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    overflow: hidden;
}

.ai-chat-box.active {
    height: 600px;
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* Header - Clean and Modern */
.ai-chat-header {
    background: var(--ai-chat-bg-primary);
    color: var(--ai-chat-text-primary);
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 20px 20px 0 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    position: relative;
}

.ai-chat-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.ai-chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--ai-chat-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.2);
    flex-shrink: 0;
}

.ai-chat-avatar svg {
    width: 20px;
    height: 20px;
    color: white;
}

.ai-chat-header-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ai-chat-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--ai-chat-text-primary);
}

.ai-chat-status {
    font-size: 12px;
    color: var(--ai-chat-text-secondary);
    font-weight: 400;
}

.ai-chat-close-btn {
    background: rgba(0, 0, 0, 0.05);
    border: none;
    color: var(--ai-chat-text-secondary);
    font-size: 20px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    flex-shrink: 0;
}

.ai-chat-close-btn:hover {
    background: rgba(0, 0, 0, 0.1);
    transform: scale(1.05);
}

/* Loading Bar */
.ai-chat-loading-bar {
    display: none;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: rgba(0, 0, 0, 0.05);
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.3s;
}

.ai-chat-loading-bar.active {
    opacity: 1;
}

.ai-chat-loading-bar-fill {
    height: 100%;
    background: var(--ai-chat-accent);
    animation: loading-fill 1.5s infinite;
}

@keyframes loading-fill {
    0% {
        width: 0%;
        margin-left: 0;
    }
    50% {
        width: 70%;
        margin-left: 15%;
    }
    100% {
        width: 0%;
        margin-left: 100%;
    }
}

/* Phone Screen */
.ai-chat-phone-screen {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.ai-chat-phone-content {
    flex: 1;
    padding: 40px 24px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.ai-chat-phone-content p {
    margin-bottom: 24px;
    color: var(--ai-chat-text-primary);
    font-size: 15px;
    font-weight: 500;
}

#ai-chat-phone-input {
    width: 100%;
    max-width: 280px;
    padding: 14px 18px;
    border: 2px solid rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    font-size: 15px;
    text-align: center;
    margin-bottom: 16px;
    transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    font-family: inherit;
    background: var(--ai-chat-bg-secondary);
}

#ai-chat-phone-input:focus {
    outline: none;
    border-color: var(--ai-chat-accent);
    background: white;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.ai-chat-submit-btn {
    width: 100%;
    max-width: 280px;
    padding: 14px 24px;
    background: var(--ai-chat-accent);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    font-family: inherit;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.2);
}

.ai-chat-submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.ai-chat-submit-btn:active {
    transform: translateY(0);
}

.ai-chat-submit-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Chat Screen */
.ai-chat-screen {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Messages Container */
.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #fafafa;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.ai-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.ai-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.ai-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
}

.ai-chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.15);
}

/* Welcome State */
.ai-chat-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    gap: 16px;
}

.ai-chat-welcome-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--ai-chat-accent) 0%, #8b5cf6 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.3);
}

@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

.ai-chat-welcome-icon svg {
    width: 40px;
    height: 40px;
    color: white;
}

.ai-chat-welcome h4 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--ai-chat-text-primary);
}

.ai-chat-welcome p {
    margin: 0;
    font-size: 14px;
    color: var(--ai-chat-text-secondary);
    max-width: 280px;
}

/* Message Bubbles - Neumorphism */
.ai-chat-message {
    display: flex;
    animation: message-slide-up 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

@keyframes message-slide-up {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ai-message {
    justify-content: flex-start;
}

.user-message {
    justify-content: flex-end;
}

.message-content {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    position: relative;
}

.ai-message .message-content {
    background: white;
    color: var(--ai-chat-text-primary);
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.user-message .message-content {
    background: var(--ai-chat-accent);
    color: white;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.2);
}

/* Typing Indicator */
.ai-chat-typing {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: white;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    width: fit-content;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.ai-chat-typing span {
    width: 8px;
    height: 8px;
    background: var(--ai-chat-accent);
    border-radius: 50%;
    animation: typing-wave 1.4s infinite ease-in-out both;
}

.ai-chat-typing span:nth-child(1) {
    animation-delay: -0.32s;
}

.ai-chat-typing span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes typing-wave {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Loading Animation (Three Dots) */
.ai-chat-loading {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: white;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    width: fit-content;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.ai-chat-loading span {
    width: 8px;
    height: 8px;
    background: var(--ai-chat-accent);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.ai-chat-loading span:nth-child(1) {
    animation-delay: -0.32s;
}

.ai-chat-loading span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

/* Input Container - Clean Footer */
.ai-chat-input-container {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    background: var(--ai-chat-bg-primary);
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: 0 0 20px 20px;
}

.ai-chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid rgba(0, 0, 0, 0.08);
    border-radius: 16px;
    font-size: 14px;
    outline: none;
    transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    font-family: inherit;
    background: var(--ai-chat-bg-secondary);
    color: var(--ai-chat-text-primary);
    resize: none;
    max-height: 100px;
}

.ai-chat-input:focus {
    border-color: var(--ai-chat-accent);
    background: white;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.ai-chat-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--ai-chat-accent);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.2);
}

.ai-chat-send-btn svg {
    width: 20px;
    height: 20px;
    color: white;
}

.ai-chat-send-btn svg path {
    fill: white;
}

.ai-chat-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.ai-chat-send-btn:active {
    transform: scale(0.98);
}

.ai-chat-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

/* Helper Text */
.ai-chat-helper-text {
    padding: 0 20px 12px;
    font-size: 11px;
    color: var(--ai-chat-text-secondary);
    text-align: center;
    background: var(--ai-chat-bg-primary);
}

/* Mobile Responsive */
@media (max-width: 480px) {
    #ai-chat-widget {
        right: 10px;
        bottom: 10px;
    }
    
    .ai-chat-box {
        width: calc(100vw - 20px);
        right: 10px;
        bottom: 10px;
    }
    
    .ai-chat-box.active {
        height: calc(100vh - 20px);
        max-height: 700px;
    }
}
