﻿/* ═══════════════════════════════════════
   Stoling — chat.css
   ─────────────────────────────────────────
   Stoling AI Chatbot styles.
   All classes prefixed with ch- to avoid conflicts.
   ═══════════════════════════════════════ */

/* ── Container ── */
.ch-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 72px);
    max-width: 860px;
    margin: 0 auto;
    position: relative;
    background: var(--bg, #0a0a0f);
}

/* ── Reconnection Bar ── */
.ch-reconnect-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: rgba(255, 165, 0, 0.15);
    border-bottom: 1px solid rgba(255, 165, 0, 0.3);
    color: #ffa500;
    text-align: center;
    padding: 6px 12px;
    font-size: 0.8rem;
    transform: translateY(-100%);
    transition: transform 0.3s ease;
}

.ch-reconnect-bar.is-visible {
    transform: translateY(0);
}

/* ── Header ── */
.ch-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(255, 255, 255, 0.02);
    backdrop-filter: blur(12px);
}

.ch-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ch-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #7c3aed, #a855f7);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.ch-avatar-icon {
    line-height: 1;
}

.ch-header-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ch-title {
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
    margin: 0;
}

.ch-status {
    font-size: 0.75rem;
    color: #4ade80;
}

.ch-status--reconnecting {
    color: #ffa500;
}

.ch-new-session-btn {
    background: rgba(124, 58, 237, 0.15);
    border: 1px solid rgba(124, 58, 237, 0.3);
    color: #a78bfa;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ch-new-session-btn:hover {
    background: rgba(124, 58, 237, 0.25);
    border-color: rgba(124, 58, 237, 0.5);
}

/* ── Messages Area ── */
.ch-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

.ch-messages::-webkit-scrollbar {
    width: 6px;
}

.ch-messages::-webkit-scrollbar-track {
    background: transparent;
}

.ch-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

/* ── Chat Bubbles ── */
.ch-bubble {
    max-width: 80%;
    animation: ch-fadeIn 0.3s ease;
}

.ch-bubble--user {
    align-self: flex-end;
}

.ch-bubble--assistant {
    align-self: flex-start;
}

.ch-bubble-content {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 0.9rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.ch-bubble--user .ch-bubble-content {
    background: linear-gradient(135deg, #7c3aed, #6d28d9);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.ch-bubble--assistant .ch-bubble-content {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.9);
    border-bottom-left-radius: 4px;
    backdrop-filter: blur(8px);
}

/* ── Typing Indicator ── */
.ch-typing {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 0 20px 8px;
}

.ch-typing.is-visible {
    display: flex;
}

.ch-typing-dots {
    display: flex;
    gap: 4px;
}

.ch-typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #a78bfa;
    animation: ch-bounce 1.4s infinite ease-in-out;
}

.ch-typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.ch-typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

.ch-typing-text {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
}

/* ── Error Messages ── */
.ch-error {
    align-self: center;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.8rem;
    text-align: center;
    animation: ch-fadeIn 0.3s ease;
}

/* ── Product Chips (inline buttons) ── */
.ch-product-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 6px 0;
    align-self: flex-start;
    max-width: 85%;
}

.ch-product-chips:empty {
    display: none;
}

/* ── Support Link ── */
.ch-support-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: #a78bfa;
    text-decoration: underline;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.2s;
}

.ch-support-link:hover {
    color: #c4b5fd;
}

.ch-product-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: rgba(124, 58, 237, 0.1);
    border: 1px solid rgba(124, 58, 237, 0.3);
    border-radius: 20px;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.8rem;
}

.ch-product-chip:hover {
    background: rgba(124, 58, 237, 0.2);
    border-color: rgba(124, 58, 237, 0.6);
    transform: translateY(-1px);
}

.ch-chip-icon {
    font-size: 0.85rem;
}

.ch-chip-name {
    font-weight: 500;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ch-chip-price {
    color: #a78bfa;
    font-weight: 600;
    font-size: 0.75rem;
}

.ch-chip-arrow {
    color: rgba(124, 58, 237, 0.8);
    font-size: 0.9rem;
    margin-left: 2px;
}

/* ── Input Bar ── */
.ch-input-bar {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 16px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(255, 255, 255, 0.02);
    backdrop-filter: blur(12px);
}

.ch-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 12px 16px;
    color: #fff;
    font-size: 0.9rem;
    resize: none;
    min-height: 44px;
    max-height: 120px;
    line-height: 1.4;
    transition: border-color 0.2s ease;
    font-family: inherit;
}

.ch-input:focus {
    outline: none;
    border-color: rgba(124, 58, 237, 0.5);
}

.ch-input::placeholder {
    color: rgba(255, 255, 255, 0.35);
}

.ch-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ch-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, #7c3aed, #6d28d9);
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.ch-send-btn:hover {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    transform: scale(1.05);
}

.ch-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.ch-send-btn svg {
    width: 20px;
    height: 20px;
}

/* ── Animations ── */
@keyframes ch-fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes ch-bounce {

    0%,
    80%,
    100% {
        transform: scale(0.6);
        opacity: 0.4;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .ch-container {
        height: calc(100vh - 60px);
        max-width: 100%;
    }

    .ch-header {
        padding: 12px 16px;
    }

    .ch-messages {
        padding: 16px;
    }

    .ch-bubble {
        max-width: 90%;
    }

    .ch-product-chips {
        max-width: 95%;
    }

    .ch-input-bar {
        padding: 12px 16px;
    }

    .ch-new-session-btn {
        padding: 6px 10px;
        font-size: 0.75rem;
    }
}

@media (min-width: 1200px) {
    .ch-container {
        border-left: 1px solid rgba(255, 255, 255, 0.04);
        border-right: 1px solid rgba(255, 255, 255, 0.04);
    }
}