/* ═══════════════════════════════════════════
   Chat Widget — RW Coldstore
   ═══════════════════════════════════════════ */

/* ── Trigger Button ── */
.chat-trigger {
    position: fixed;
    bottom: 32px;
    right: 32px;
    width: 56px;
    height: 56px;
    background: var(--blue-600);
    color: #fff;
    border: none;
    cursor: pointer;
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 24px rgba(29, 78, 216, 0.3);
    transition: all 0.3s var(--ease);
}

.chat-trigger:hover {
    background: #2563eb;
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(29, 78, 216, 0.4);
}

.chat-trigger svg {
    width: 24px;
    height: 24px;
    transition: transform 0.3s var(--ease);
}

.chat-trigger .chat-icon-close {
    display: none;
}

.chat-trigger.active .chat-icon-open {
    display: none;
}

.chat-trigger.active .chat-icon-close {
    display: block;
}

/* Cookie banner offset */
.chat-trigger.chat-cookie-offset {
    bottom: 110px;
}

/* Back-to-top shift */
.chat-widget-loaded .back-to-top {
    right: 100px;
}

/* ── Chat Panel ── */
.chat-panel {
    position: fixed;
    bottom: 100px;
    right: 32px;
    width: 360px;
    max-height: 480px;
    background: var(--blue-950);
    border: 1px solid var(--border);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
    z-index: 9998;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transform: translateY(16px);
    transition: all 0.3s var(--ease);
    pointer-events: none;
}

.chat-panel.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

.chat-panel.chat-cookie-offset {
    bottom: 178px;
}

/* ── Header ── */
.chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: var(--blue-850);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.chat-avatar {
    width: 36px;
    height: 36px;
    background: var(--blue-600);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-avatar span {
    font-size: 0.75rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.03em;
}

.chat-header-info {
    flex: 1;
    min-width: 0;
}

.chat-header-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: #fff;
    line-height: 1.3;
}

.chat-header-status {
    font-size: 0.72rem;
    color: var(--slate-400);
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-status-dot {
    width: 6px;
    height: 6px;
    background: #22c55e;
    border-radius: 50%;
    display: inline-block;
}

.chat-close {
    width: 32px;
    height: 32px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--slate-400);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s var(--ease);
}

.chat-close:hover {
    border-color: var(--border-hover);
    color: #fff;
}

.chat-close svg {
    width: 14px;
    height: 14px;
}

/* ── Messages Area ── */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scrollbar-width: thin;
    scrollbar-color: var(--border-hover) transparent;
}

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

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

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

/* ── Message Bubble ── */
.chat-msg {
    max-width: 88%;
    padding: 12px 16px;
    font-size: 0.85rem;
    line-height: 1.6;
    opacity: 0;
    transform: translateY(8px);
    animation: chatMsgIn 0.3s var(--ease) forwards;
}

.chat-msg-bot {
    background: var(--blue-900);
    border: 1px solid var(--border);
    color: var(--slate-300);
    align-self: flex-start;
}

.chat-msg-user {
    background: var(--blue-600);
    color: #fff;
    align-self: flex-end;
    font-weight: 500;
}

@keyframes chatMsgIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Typing Indicator ── */
.chat-typing {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 14px 18px;
    background: var(--blue-900);
    border: 1px solid var(--border);
    align-self: flex-start;
    max-width: 72px;
}

.chat-typing-dot {
    width: 6px;
    height: 6px;
    background: var(--slate-500);
    border-radius: 50%;
    animation: chatBounce 1.2s ease-in-out infinite;
}

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

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

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

/* ── Replies Area ── */
.chat-replies {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
    max-height: 220px;
    overflow-y: auto;
}

.chat-replies-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chat-reply-btn {
    background: transparent;
    border: 1px solid var(--border-hover);
    color: var(--slate-300);
    font-family: var(--font), sans-serif;
    font-size: 0.8rem;
    font-weight: 500;
    padding: 8px 14px;
    cursor: pointer;
    transition: all 0.2s var(--ease);
    text-align: left;
    line-height: 1.4;
}

.chat-reply-btn:hover {
    border-color: var(--blue-500);
    color: var(--blue-400);
    background: rgba(59, 130, 246, 0.05);
}

/* ── CTA Buttons ── */
.chat-cta-wrap {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
}

.chat-cta-btn {
    display: block;
    width: 100%;
    padding: 12px 20px;
    background: var(--blue-600);
    color: #fff;
    font-family: var(--font), sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all 0.25s var(--ease);
}

.chat-cta-btn:hover {
    background: #2563eb;
    transform: translateY(-1px);
}

.chat-cta-secondary {
    display: block;
    width: 100%;
    padding: 10px 20px;
    background: transparent;
    color: var(--slate-400);
    font-family: var(--font), sans-serif;
    font-size: 0.8rem;
    font-weight: 500;
    text-align: center;
    text-decoration: none;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s var(--ease);
}

.chat-cta-secondary:hover {
    border-color: var(--border-hover);
    color: var(--slate-300);
}

/* ── Skip Link ── */
.chat-skip {
    display: block;
    text-align: center;
    padding: 8px 0 0;
    font-size: 0.72rem;
    color: var(--slate-500);
    text-decoration: none;
    transition: color 0.2s var(--ease);
}

.chat-skip:hover {
    color: var(--blue-400);
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .chat-trigger {
        bottom: 20px;
        right: 20px;
        width: 50px;
        height: 50px;
    }

    .chat-trigger.chat-cookie-offset {
        bottom: 90px;
    }

    .chat-panel {
        width: calc(100vw - 32px);
        right: 16px;
        bottom: 82px;
        max-height: 70vh;
    }

    .chat-panel.chat-cookie-offset {
        bottom: 152px;
    }

    .chat-widget-loaded .back-to-top {
        right: 84px;
    }
}
