/* ============================================
   Floating Chat Widget - Grace Fields
   Accessible from all pages
   ============================================ */

/* Chat Widget Button */
.chat-widget-button {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #B19CD9 0%, #9B59B6 100%);
    border: none;
    box-shadow: 0 4px 20px rgba(177, 156, 217, 0.5);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 1060; /* Aligned with z-index system (popover level) */
    color: white;
    font-size: 1.5rem;
}

.chat-widget-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(177, 156, 217, 0.7);
}

.chat-widget-button:focus {
    outline: 3px solid rgba(177, 156, 217, 0.5);
    outline-offset: 3px;
}

.chat-widget-button i {
    transition: transform 0.3s ease;
}

.chat-widget-button.open i {
    transform: rotate(180deg);
}

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

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

/* Chat Widget Container */
.chat-widget-container {
    position: fixed;
    bottom: 100px;
    right: 2rem;
    width: 380px;
    height: 600px;
    background: var(--bg-primary, #ffffff);
    border-radius: 12px; /* Aligned with radius-xl */
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: none;
    flex-direction: column;
    z-index: 1070; /* Aligned with z-index system (tooltip level - above button) */
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

.chat-widget-container.open {
    display: flex;
}

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

/* Dark Mode Support */
body.dark-mode .chat-widget-container {
    background: var(--bg-primary-dark, #1a202c);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Chat Widget Header */
.chat-widget-header {
    background: linear-gradient(135deg, #B19CD9 0%, #9B59B6 100%);
    color: white;
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

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

.chat-widget-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.chat-widget-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

.chat-widget-subtitle {
    font-size: 0.75rem;
    opacity: 0.9;
    margin: 0;
}

.chat-widget-close {
    background: transparent;
    border: none;
    color: white;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: background 0.2s ease;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

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

body.dark-mode .chat-widget-messages {
    background: var(--bg-secondary-dark, #2d3748);
}

/* Chat Widget Input */
.chat-widget-input-container {
    padding: 1rem;
    border-top: 1px solid var(--border-color, #e2e8f0);
    background: var(--bg-primary, #ffffff);
    flex-shrink: 0;
}

body.dark-mode .chat-widget-input-container {
    background: var(--bg-primary-dark, #1a202c);
    border-top-color: rgba(255, 255, 255, 0.1);
}

.chat-widget-input-wrapper {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
}

.chat-widget-input {
    flex: 1;
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: var(--radius-md, 8px); /* Use design system */
    padding: 0.75rem;
    font-size: 0.9rem;
    resize: none;
    max-height: 100px;
    min-height: 44px;
}

body.dark-mode .chat-widget-input {
    background: var(--bg-secondary-dark, #2d3748);
    border-color: rgba(255, 255, 255, 0.1);
    color: var(--text-primary-dark, #f7fafc);
}

.chat-widget-send-btn {
    background: linear-gradient(135deg, #B19CD9 0%, #9B59B6 100%);
    color: white;
    border: none;
    border-radius: var(--radius-md, 8px); /* Use design system */
    padding: 0.75rem 1rem;
    min-width: 44px;
    min-height: 44px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-widget-send-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(177, 156, 217, 0.4);
}

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

/* Message Bubbles */
.chat-widget-message {
    display: flex;
    gap: 0.75rem;
    animation: fadeIn 0.3s ease;
}

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

.chat-widget-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #B19CD9 0%, #9B59B6 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.chat-widget-message.user .chat-widget-message-avatar {
    background: linear-gradient(135deg, #31B2E0 0%, #4ECDC4 100%);
}

.chat-widget-message-content {
    flex: 1;
    max-width: 75%;
}

.chat-widget-message-bubble {
    background: white;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-xl, 12px); /* Use design system */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    word-wrap: break-word;
}

body.dark-mode .chat-widget-message-bubble {
    background: var(--bg-primary-dark, #1a202c);
    color: var(--text-primary-dark, #f7fafc);
}

.chat-widget-message.user .chat-widget-message-bubble {
    background: linear-gradient(135deg, #31B2E0 0%, #4ECDC4 100%);
    color: white;
}

.chat-widget-message-time {
    font-size: 0.7rem;
    color: var(--text-secondary, #718096);
    margin-top: 0.25rem;
}

/* Typing Indicator */
.chat-widget-typing {
    display: flex;
    gap: 0.75rem;
    padding: 0.5rem 0;
}

.chat-widget-typing-dots {
    display: flex;
    gap: 0.25rem;
    padding: 0.75rem 1rem;
    background: white;
    border-radius: var(--radius-xl, 12px); /* Use design system */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

body.dark-mode .chat-widget-typing-dots {
    background: var(--bg-primary-dark, #1a202c);
}

.chat-widget-typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #B19CD9;
    animation: typingDot 1.4s infinite;
}

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

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

@keyframes typingDot {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-10px);
    }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .chat-widget-container {
        bottom: 80px;
        right: 1rem;
        left: 1rem;
        width: auto;
        height: 500px;
    }

    .chat-widget-button {
        bottom: 1rem;
        right: 1rem;
    }
}

