/* ═══════════════════════════════════════════════════
   WESTELECOM Chat Widget — Styles
   Modern, clean design with WESTELECOM branding
   ═══════════════════════════════════════════════════ */

:root {
    --wc-primary: #0066FF;
    --wc-primary-dark: #0052CC;
    --wc-primary-light: #E6F0FF;
    --wc-success: #00C853;
    --wc-warning: #FFB300;
    --wc-danger: #FF3D00;
    --wc-text: #1A1A2E;
    --wc-text-secondary: #6B7280;
    --wc-text-light: #9CA3AF;
    --wc-bg: #FFFFFF;
    --wc-bg-secondary: #F3F4F6;
    --wc-border: #E5E7EB;
    --wc-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
    --wc-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --wc-radius: 16px;
    --wc-radius-sm: 10px;
    --wc-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --wc-transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Bubble Button ──────────────────────────────── */
.wc-bubble {
    position: fixed;
    bottom: calc(80px + env(safe-area-inset-bottom));
    right: 16px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--wc-primary);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0, 102, 255, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--wc-transition);
    z-index: 99998;
    outline: none;
}

.wc-bubble { transition: opacity 150ms ease, transform 150ms ease; opacity: 0; animation: mfbSlideIn 400ms ease-out 1.5s forwards; }
.wc-bubble:active { opacity: 0.85; transform: scale(0.94); }
.wc-bubble:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(0, 102, 255, 0.5);
}

.wc-bubble svg {
    width: 28px;
    height: 28px;
    transition: transform var(--wc-transition);
}

.wc-bubble.wc-open svg.wc-icon-chat {
    display: none;
}
.wc-bubble.wc-open svg.wc-icon-close {
    display: block;
}
.wc-bubble:not(.wc-open) svg.wc-icon-close {
    display: none;
}

/* Badge */
.wc-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--wc-danger);
    color: white;
    font-size: 11px;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    display: none;
}
.wc-badge.wc-visible { display: flex; }

/* ── Chat Window ────────────────────────────────── */
.wc-window {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 560px;
    max-height: calc(100vh - 120px);
    background: var(--wc-bg);
    border-radius: var(--wc-radius);
    box-shadow: var(--wc-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 99999;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all var(--wc-transition);
    font-family: var(--wc-font);
}

.wc-window.wc-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* ── Header ─────────────────────────────────────── */
.wc-header {
    background: var(--wc-primary);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.wc-header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.wc-header-avatar svg {
    width: 22px;
    height: 22px;
}

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

.wc-header-title {
    font-size: 15px;
    font-weight: 600;
    margin: 0;
    line-height: 1.3;
}

.wc-header-status {
    font-size: 12px;
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 5px;
}

.wc-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--wc-success);
    display: inline-block;
}

.wc-header-close {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 4px;
    opacity: 0.7;
    transition: opacity 0.2s;
}
.wc-header-close:hover { opacity: 1; }
.wc-header-close svg { width: 20px; height: 20px; }

/* ── Messages Area ──────────────────────────────── */
.wc-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--wc-bg-secondary);
    scroll-behavior: smooth;
}

.wc-messages::-webkit-scrollbar { width: 5px; }
.wc-messages::-webkit-scrollbar-track { background: transparent; }
.wc-messages::-webkit-scrollbar-thumb { background: #D1D5DB; border-radius: 3px; }

/* ── Message Bubbles ────────────────────────────── */
.wc-msg {
    max-width: 82%;
    padding: 10px 14px;
    border-radius: var(--wc-radius-sm);
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    animation: wc-msg-in 0.2s ease-out;
}

@keyframes wc-msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Client message */
.wc-msg-client {
    background: var(--wc-primary);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

/* AI message */
.wc-msg-ai {
    background: var(--wc-bg);
    color: var(--wc-text);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    box-shadow: var(--wc-shadow-sm);
}

/* Agent message */
.wc-msg-agent {
    background: var(--wc-bg);
    color: var(--wc-text);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    border-left: 3px solid var(--wc-success);
    box-shadow: var(--wc-shadow-sm);
}

/* System message */
.wc-msg-system {
    background: transparent;
    color: var(--wc-text-light);
    font-size: 12px;
    text-align: center;
    align-self: center;
    padding: 4px 12px;
    max-width: 100%;
}

/* Message metadata */
.wc-msg-meta {
    font-size: 11px;
    margin-top: 4px;
    opacity: 0.6;
}
.wc-msg-client .wc-msg-meta { text-align: right; }

.wc-msg-sender {
    font-size: 11px;
    font-weight: 600;
    color: var(--wc-text-secondary);
    margin-bottom: 3px;
}

/* ── Typing Indicator ───────────────────────────── */
.wc-typing {
    display: none;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    background: var(--wc-bg);
    border-radius: var(--wc-radius-sm);
    align-self: flex-start;
    box-shadow: var(--wc-shadow-sm);
}

.wc-typing.wc-visible { display: flex; }

.wc-typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--wc-text-light);
    animation: wc-typing-bounce 1.2s infinite;
}
.wc-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.wc-typing-dot:nth-child(3) { animation-delay: 0.4s; }

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

/* ── Input Area ─────────────────────────────────── */
.wc-input-area {
    padding: 12px 16px;
    background: var(--wc-bg);
    border-top: 1px solid var(--wc-border);
    display: flex;
    align-items: flex-end;
    gap: 8px;
    flex-shrink: 0;
}

.wc-input {
    flex: 1;
    border: 1px solid var(--wc-border);
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    font-family: var(--wc-font);
    resize: none;
    max-height: 100px;
    line-height: 1.4;
    outline: none;
    transition: border-color 0.2s;
    background: var(--wc-bg-secondary);
}

.wc-input:focus {
    border-color: var(--wc-primary);
    background: var(--wc-bg);
}

.wc-input::placeholder {
    color: var(--wc-text-light);
}

.wc-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--wc-primary);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.wc-send-btn:hover { background: var(--wc-primary-dark); }
.wc-send-btn:disabled { opacity: 0.4; cursor: default; }
.wc-send-btn svg { width: 18px; height: 18px; }

/* ── Welcome Screen ─────────────────────────────── */
.wc-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
    text-align: center;
    flex: 1;
}

.wc-welcome-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--wc-primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}

.wc-welcome-icon svg { width: 32px; height: 32px; color: var(--wc-primary); }

.wc-welcome h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--wc-text);
    margin: 0 0 8px;
}

.wc-welcome p {
    font-size: 14px;
    color: var(--wc-text-secondary);
    margin: 0 0 20px;
    line-height: 1.5;
}

.wc-welcome-btn {
    background: var(--wc-primary);
    color: white;
    border: none;
    padding: 12px 28px;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.wc-welcome-btn:hover { background: var(--wc-primary-dark); transform: translateY(-1px); }

/* ── Powered by ─────────────────────────────────── */
.wc-powered {
    text-align: center;
    padding: 6px;
    font-size: 11px;
    color: var(--wc-text-light);
    background: var(--wc-bg);
    border-top: 1px solid var(--wc-border);
    flex-shrink: 0;
}
.wc-powered a { color: var(--wc-primary); text-decoration: none; }

/* ── Mobile responsive ──────────────────────────── */
@media (max-width: 480px) {
    .wc-window {
        bottom: 0;
        right: 0;
        width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .wc-bubble {
        bottom: 16px;
        right: 16px;
        width: 56px;
        height: 56px;
    }
}

/* ── Markdown in messages ───────────────────────── */
.wc-msg a { color: inherit; text-decoration: underline; }
.wc-msg-client a { color: white; }
.wc-msg code {
    background: rgba(0,0,0,0.06);
    padding: 2px 5px;
    border-radius: 4px;
    font-size: 13px;
}
.wc-msg-client code { background: rgba(255,255,255,0.2); }
.wc-msg strong { font-weight: 600; }
.wc-msg ul, .wc-msg ol { margin: 4px 0; padding-left: 20px; }
.wc-msg li { margin: 2px 0; }


@keyframes mfbSlideIn {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}
