/* ==================== Chat Widget Styles ==================== */
.chat-widget {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 9999;
    font-family: inherit;
}

/* ==================== Chat Toggle Button ==================== */
.chat-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--accent-gradient);
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.chat-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 40px rgba(99, 102, 241, 0.4);
}

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

.chat-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    animation: pulse 2s infinite;
}

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

/* ==================== Chat Container ==================== */
.chat-container {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 600px;
    background: var(--bg-primary);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.chat-container.active {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* ==================== Chat Header ==================== */
.chat-header {
    background: var(--accent-gradient);
    color: white;
    padding: 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 16px 16px 0 0;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.chat-header-info img {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    border: 2px solid white;
    object-fit: cover;
}

.chat-header-info h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.chat-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    opacity: 0.9;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    animation: blink 2s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.chat-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.chat-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ==================== Chat Messages ==================== */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: var(--bg-secondary);
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

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

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--accent-primary);
}

/* ==================== Chat Message ==================== */
.chat-message {
    display: flex;
    gap: 0.75rem;
    animation: slideIn 0.3s ease;
}

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

.user-message {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
    object-fit: cover;
}

.user-avatar {
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.9rem;
}

.message-content {
    max-width: 75%;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.bot-message .message-content {
    align-items: flex-start;
}

.user-message .message-content {
    align-items: flex-end;
}

.message-content p {
    margin: 0;
    padding: 0.875rem 1rem;
    border-radius: 12px;
    line-height: 1.5;
    font-size: 0.95rem;
}

.bot-message .message-content p {
    background: var(--bg-primary);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

.user-message .message-content p {
    background: var(--accent-gradient);
    color: white;
    border-bottom-right-radius: 4px;
}

.message-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
    padding: 0 0.5rem;
}

/* ==================== Typing Indicator ==================== */
.typing-indicator .message-content {
    background: var(--bg-primary);
    padding: 0.875rem 1rem;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
}

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

.typing-dots span {
    width: 8px;
    height: 8px;
    background: var(--text-secondary);
    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;
    }
}

/* ==================== Chat Input Container ==================== */
.chat-input-container {
    background: var(--bg-primary);
    padding: 1rem;
    border-top: 1px solid var(--bg-tertiary);
}

/* ==================== Quick Questions ==================== */
.quick-questions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.quick-question {
    padding: 0.5rem 0.875rem;
    background: var(--bg-secondary);
    border: 1px solid var(--bg-tertiary);
    border-radius: 20px;
    font-size: 0.85rem;
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.quick-question:hover {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
    transform: translateY(-2px);
}

/* ==================== Chat Input Form ==================== */
.chat-input-form {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.chat-input {
    flex: 1;
    padding: 0.875rem 1rem;
    background: var(--bg-secondary);
    border: 2px solid transparent;
    border-radius: 24px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    transition: var(--transition);
}

.chat-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    background: var(--bg-primary);
}

.chat-input::placeholder {
    color: var(--text-secondary);
}

.chat-send {
    width: 44px;
    height: 44px;
    background: var(--accent-gradient);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.chat-send:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

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

/* ==================== Responsive Design ==================== */
@media (max-width: 640px) {
    .chat-widget {
        bottom: 1rem;
        right: 1rem;
    }
    
    .chat-container {
        width: calc(100vw - 2rem);
        height: calc(100vh - 100px);
        bottom: 70px;
        right: -1rem;
    }
    
    .chat-toggle {
        width: 56px;
        height: 56px;
        font-size: 1.35rem;
    }
    
    .quick-questions {
        flex-direction: column;
    }
    
    .quick-question {
        width: 100%;
        text-align: center;
    }
}

/* ==================== Dark Mode Adjustments ==================== */
[data-theme="dark"] .chat-messages {
    background: var(--bg-primary);
}

[data-theme="dark"] .bot-message .message-content p {
    background: var(--bg-secondary);
}

[data-theme="dark"] .typing-indicator .message-content {
    background: var(--bg-secondary);
}

/* ==================== Accessibility ==================== */
.chat-toggle:focus,
.chat-close:focus,
.chat-send:focus,
.quick-question:focus,
.chat-input:focus {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

/* ==================== Print Styles ==================== */
@media print {
    .chat-widget {
        display: none !important;
    }
}
