/* ============ CHAT WIDGET ============ */

.chat-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1000;
    font-family: var(--font-sans);
}

.chat-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--color-cta);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(217, 119, 87, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.chat-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(217, 119, 87, 0.5);
}

.chat-toggle .badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #E74C3C;
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 10px;
    display: none;
}

.chat-window {
    position: absolute;
    bottom: 76px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 48px);
    height: 540px;
    max-height: calc(100vh - 120px);
    background: var(--color-white);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(42, 37, 32, 0.2);
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--color-border);
}

.chat-window.open {
    display: flex;
    animation: chatSlideUp 0.3s ease;
}

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

.chat-header {
    background: linear-gradient(135deg, var(--color-accent) 0%, var(--color-warm) 100%);
    color: white;
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.chat-title {
    flex: 1;
}

.chat-title h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    line-height: 1.2;
}

.chat-title .status {
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 2px;
}

.chat-title .status::before {
    content: '';
    width: 6px;
    height: 6px;
    background: #4ADE80;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

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

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

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

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

.chat-message {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
    animation: messageIn 0.2s ease;
}

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

.chat-message.user {
    align-self: flex-end;
    background: var(--color-cta);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-message.bot {
    align-self: flex-start;
    background: white;
    color: var(--color-text);
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow-soft);
}

.chat-message.bot.error {
    background: rgba(217, 119, 87, 0.1);
    color: var(--color-cta-dark);
    border: 1px solid var(--color-cta);
}

.chat-message.bot .quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.chat-message.bot .quick-reply {
    background: var(--color-bg-soft);
    border: 1px solid var(--color-accent);
    color: var(--color-accent-dark);
    padding: 6px 12px;
    border-radius: 14px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
}

.chat-message.bot .quick-reply:hover {
    background: var(--color-accent);
    color: white;
}

.typing {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    align-self: flex-start;
    background: white;
    border-radius: 16px;
    box-shadow: var(--shadow-soft);
}

.typing span {
    width: 6px;
    height: 6px;
    background: var(--color-text-soft);
    border-radius: 50%;
    animation: typing 1.2s infinite;
}

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

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

.chat-input {
    border-top: 1px solid var(--color-border);
    padding: 12px;
    background: white;
    display: flex;
    gap: 8px;
    align-items: center;
}

.chat-input input {
    flex: 1;
    border: 1px solid var(--color-border);
    border-radius: 20px;
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    background: var(--color-bg);
    color: var(--color-text);
}

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

.chat-input input:disabled {
    opacity: 0.5;
}

.chat-send {
    background: var(--color-cta);
    color: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.chat-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.chat-send:hover:not(:disabled) {
    background: var(--color-cta-dark);
}

@media (max-width: 480px) {
    .chat-window {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }
    .chat-widget {
        bottom: 16px;
        right: 16px;
    }
}
