/* ============================================
   Chat Widget - Paper Material Style
   ============================================ */

.chat-widget-bubble {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    background: var(--primary);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 900;
    box-shadow: var(--shadow-lg), 3px 3px 0 var(--primary-dark);
    transition: var(--transition);
    border: none;
    color: white;
    font-size: 1.4rem;
}

.chat-widget-bubble:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: var(--shadow-xl), 4px 4px 0 var(--primary-dark);
}

.chat-widget-bubble.active {
    border-radius: var(--radius-md);
    background: var(--secondary);
    box-shadow: var(--shadow-lg), 3px 3px 0 var(--secondary-dark);
}

.chat-widget-window {
    position: fixed;
    bottom: 92px;
    right: 24px;
    width: 380px;
    height: 520px;
    background: var(--card-white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl), var(--shadow-paper);
    border: 1px solid rgba(0,0,0,0.06);
    z-index: 899;
    display: none;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    animation: widget-open 0.25s ease forwards;
}

@keyframes widget-open {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

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

.chat-widget-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: var(--primary);
    color: white;
    border-bottom: 3px solid var(--primary-dark);
}

.chat-widget-header-avatar {
    width: 36px;
    height: 36px;
    background: rgba(255,255,255,0.15);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.chat-widget-header-info h4 {
    font-size: 0.9rem;
    font-weight: 700;
}

.chat-widget-header-info span {
    font-size: 0.75rem;
    opacity: 0.7;
}

.chat-widget-header-close {
    margin-left: auto;
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 1.2rem;
    opacity: 0.7;
    transition: var(--transition);
    padding: 4px;
}

.chat-widget-header-close:hover {
    opacity: 1;
}

.chat-widget-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--paper-bg);
}

.chat-widget-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: var(--radius-lg);
    font-size: 0.85rem;
    line-height: 1.5;
    box-shadow: var(--shadow-xs);
}

.chat-widget-msg.bot {
    background: var(--card-white);
    border: 1px solid rgba(0,0,0,0.05);
    border-bottom-left-radius: 4px;
    align-self: flex-start;
}

.chat-widget-msg.user {
    background: var(--primary);
    color: white;
    border-bottom-right-radius: 4px;
    align-self: flex-end;
    box-shadow: var(--shadow-sm), 2px 2px 0 rgba(61,90,128,0.2);
}

.chat-widget-msg a {
    color: #3D5A80;
    font-weight: 600;
    text-decoration: underline;
}

.chat-widget-msg.user a {
    color: #b8d4f0;
}

.chat-widget-input {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid rgba(0,0,0,0.06);
    background: var(--card-white);
}

.chat-widget-input input {
    flex: 1;
    padding: 10px 14px;
    border: 2px solid rgba(0,0,0,0.08);
    border-radius: var(--radius-md);
    font-family: var(--font);
    font-size: 0.85rem;
    background: var(--paper-bg);
    color: var(--text);
    outline: none;
    transition: var(--transition);
}

.chat-widget-input input:focus {
    border-color: var(--primary);
    background: var(--card-white);
}

.chat-widget-input button {
    padding: 10px 14px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 700;
    box-shadow: var(--shadow-xs), 2px 2px 0 var(--primary-dark);
    transition: var(--transition);
    font-family: var(--font);
}

.chat-widget-input button:hover {
    background: var(--primary-dark);
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    align-self: flex-start;
}

.typing-indicator span {
    width: 7px;
    height: 7px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typing-bounce 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) { animation-delay: 0s; }
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

@media (max-width: 480px) {
    .chat-widget-window {
        right: 8px;
        left: 8px;
        bottom: 84px;
        width: auto;
        height: 70vh;
    }
}
