/* ============================================
   WP Team Manager - Quick Chat Widget
   Colorful AI Bot Theme
   ============================================ */

:root {
    --wtm-chat-primary: #4a5568;
    --wtm-chat-accent: #0073aa;
    --wtm-chat-accent-dark: #005a87;
    --wtm-chat-surface: #ffffff;
    --wtm-chat-surface-alt: #f7fafc;
    --wtm-chat-border: #e2e8f0;
    --wtm-chat-text: #2d3748;
    --wtm-chat-text-muted: #718096;
    --wtm-chat-radius: 16px;
    --wtm-chat-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
    --wtm-chat-width: 380px;
    --wtm-chat-height: 520px;
    /* Bot gradient colors */
    --wtm-bot-1: #6366f1;
    --wtm-bot-2: #8b5cf6;
    --wtm-bot-3: #a78bfa;
    --wtm-bot-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a78bfa 100%);
}

/* ── Toggle Button ── */
.wtm-chat-toggle {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--wtm-bot-gradient);
    color: #fff;
    border: none;
    cursor: pointer;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
    font-size: 0;
    animation: wtm-chat-toggle-entrance 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes wtm-chat-toggle-entrance {
    from { transform: scale(0) rotate(-180deg); opacity: 0; }
    to { transform: scale(1) rotate(0deg); opacity: 1; }
}

.wtm-chat-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 28px rgba(99, 102, 241, 0.55);
}

.wtm-chat-toggle svg {
    width: 26px;
    height: 26px;
    fill: currentColor;
    transition: transform 0.3s ease;
}

.wtm-chat-toggle.wtm-chat-open svg {
    transform: rotate(90deg);
}

/* Notification dot */
.wtm-chat-toggle .wtm-chat-dot {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    background: #f43f5e;
    border-radius: 50%;
    border: 2.5px solid #fff;
    animation: wtm-chat-pulse-dot 2s ease-in-out infinite;
}

@keyframes wtm-chat-pulse-dot {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.25); opacity: 0.7; }
}

/* ── Chat Panel ── */
.wtm-chat-panel {
    position: fixed;
    bottom: 100px;
    right: 28px;
    width: var(--wtm-chat-width);
    height: var(--wtm-chat-height);
    background: var(--wtm-chat-surface);
    border-radius: var(--wtm-chat-radius);
    box-shadow: var(--wtm-chat-shadow);
    display: flex;
    flex-direction: column;
    z-index: 99998;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 1px solid var(--wtm-chat-border);
}

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

/* ── Header ── */
.wtm-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 16px;
    background: var(--wtm-bot-gradient);
    color: #fff;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

.wtm-chat-header::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 120px;
    height: 120px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 50%;
}

.wtm-chat-header::after {
    content: '';
    position: absolute;
    bottom: -40%;
    left: -10%;
    width: 80px;
    height: 80px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 50%;
}

.wtm-chat-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
    z-index: 1;
}

.wtm-chat-header-avatar {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    backdrop-filter: blur(4px);
}

.wtm-chat-header-avatar svg {
    width: 20px;
    height: 20px;
    fill: #fff;
}

.wtm-chat-header-title {
    font-size: 14px;
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: 0.01em;
}

.wtm-chat-header-subtitle {
    font-size: 11px;
    opacity: 0.85;
    font-weight: 400;
}

.wtm-chat-header-actions {
    display: flex;
    gap: 4px;
    position: relative;
    z-index: 1;
}

.wtm-chat-header-btn {
    width: 30px;
    height: 30px;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, transform 0.2s ease;
    font-size: 0;
}

.wtm-chat-header-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.wtm-chat-header-btn svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

/* ── Messages Area ── */
.wtm-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
    background: var(--wtm-chat-surface-alt);
}

.wtm-chat-messages::-webkit-scrollbar { width: 5px; }
.wtm-chat-messages::-webkit-scrollbar-track { background: transparent; }
.wtm-chat-messages::-webkit-scrollbar-thumb { background: var(--wtm-chat-border); border-radius: 10px; }
.wtm-chat-messages::-webkit-scrollbar-thumb:hover { background: var(--wtm-chat-text-muted); }

/* ── Message Bubbles ── */
.wtm-chat-msg {
    display: flex;
    gap: 8px;
    max-width: 88%;
    animation: wtm-chat-msg-in 0.3s ease;
}

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

.wtm-chat-msg-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.wtm-chat-msg-avatar {
    width: 30px;
    height: 30px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    flex-shrink: 0;
    margin-top: 2px;
}

.wtm-chat-msg-bot .wtm-chat-msg-avatar {
    background: var(--wtm-bot-gradient);
    color: #fff;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.wtm-chat-msg-user .wtm-chat-msg-avatar {
    background: linear-gradient(135deg, #64748b, #475569);
    color: #fff;
}

.wtm-chat-msg-bot .wtm-chat-msg-avatar svg,
.wtm-chat-msg-user .wtm-chat-msg-avatar svg {
    width: 18px;
    height: 18px;
    fill: #fff;
}

.wtm-chat-msg-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 13px;
    line-height: 1.55;
    word-break: break-word;
}

.wtm-chat-msg-bot .wtm-chat-msg-bubble {
    background: var(--wtm-chat-surface);
    color: var(--wtm-chat-text);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--wtm-chat-border);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.wtm-chat-msg-user .wtm-chat-msg-bubble {
    background: var(--wtm-bot-gradient);
    color: #fff;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.25);
}

.wtm-chat-msg-bubble code {
    background: rgba(99, 102, 241, 0.08);
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 12px;
    font-family: 'Monaco', 'Menlo', monospace;
    color: var(--wtm-bot-1);
}

.wtm-chat-msg-user .wtm-chat-msg-bubble code {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.wtm-chat-msg-bubble a {
    color: var(--wtm-bot-1);
    text-decoration: none;
    font-weight: 600;
}

.wtm-chat-msg-bubble a:hover { text-decoration: underline; }
.wtm-chat-msg-user .wtm-chat-msg-bubble a { color: #fff; }

/* ── Typing Indicator ── */
.wtm-chat-typing {
    display: flex;
    gap: 4px;
    padding: 12px 14px;
    align-items: center;
}

.wtm-chat-typing-dot {
    width: 7px;
    height: 7px;
    background: var(--wtm-bot-2);
    border-radius: 50%;
    animation: wtm-chat-bounce 1.4s ease-in-out infinite;
}

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

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

/* ── Quick Link Buttons ── */
.wtm-chat-quick-links {
    display: flex;
    gap: 6px;
    padding: 0 0 8px;
    flex-wrap: wrap;
}

.wtm-chat-quick-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 12px;
    background: var(--wtm-chat-surface);
    border: 1.5px solid var(--wtm-chat-border);
    border-radius: 10px;
    font-size: 12px;
    font-weight: 500;
    color: var(--wtm-chat-text);
    text-decoration: none;
    transition: all 0.2s ease;
    cursor: pointer;
    white-space: nowrap;
}

.wtm-chat-quick-link svg { flex-shrink: 0; }

.wtm-chat-quick-link:hover {
    border-color: var(--wtm-bot-1);
    color: var(--wtm-bot-1);
    background: rgba(99, 102, 241, 0.04);
    transform: translateY(-1px);
}

/* ── Quick Reply Chips ── */
.wtm-chat-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 4px 0 8px;
}

.wtm-chat-chip {
    padding: 6px 12px;
    background: var(--wtm-chat-surface);
    border: 1.5px solid var(--wtm-chat-border);
    border-radius: 20px;
    font-size: 12px;
    color: var(--wtm-bot-1);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    font-weight: 500;
}

.wtm-chat-chip:hover {
    background: var(--wtm-bot-gradient);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
    transform: translateY(-1px);
}

/* ── Input Area ── */
.wtm-chat-input-wrap {
    padding: 12px 14px;
    border-top: 1px solid var(--wtm-chat-border);
    display: flex;
    gap: 8px;
    align-items: center;
    background: var(--wtm-chat-surface);
    flex-shrink: 0;
}

.wtm-chat-input {
    flex: 1;
    padding: 10px 14px;
    border: 1.5px solid var(--wtm-chat-border);
    border-radius: 24px;
    font-size: 13px;
    color: var(--wtm-chat-text);
    background: var(--wtm-chat-surface-alt);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.wtm-chat-input::placeholder { color: var(--wtm-chat-text-muted); }

.wtm-chat-input:focus {
    border-color: var(--wtm-bot-1);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.wtm-chat-send {
    width: 40px;
    height: 40px;
    border: none;
    background: var(--wtm-bot-gradient);
    color: #fff;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    flex-shrink: 0;
    font-size: 0;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.wtm-chat-send:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}

.wtm-chat-send:active { transform: scale(0.95); }

.wtm-chat-send svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
    transform: rotate(-30deg);
    margin-left: 2px;
}

.wtm-chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ── Link Footer in Bot Messages ── */
.wtm-chat-msg-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
    padding: 5px 10px;
    background: rgba(99, 102, 241, 0.08);
    border-radius: 8px;
    font-size: 12px;
    color: var(--wtm-bot-1);
    text-decoration: none;
    font-weight: 500;
    transition: background 0.2s ease;
}

.wtm-chat-msg-link:hover { background: rgba(99, 102, 241, 0.15); }

/* ── Responsive ── */
@media (max-width: 768px) {
    .wtm-chat-panel {
        bottom: 0;
        right: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
        border: none;
    }
    .wtm-chat-toggle { bottom: 20px; right: 20px; }
}

@media (max-width: 480px) {
    .wtm-chat-header { padding: 12px 14px; }
    .wtm-chat-messages { padding: 12px; }
    .wtm-chat-input-wrap { padding: 10px 12px; }
}

/* ── Dark Mode ── */
@media (prefers-color-scheme: dark) {
    :root {
        --wtm-chat-surface: #1a1a2e;
        --wtm-chat-surface-alt: #16213e;
        --wtm-chat-text: #e0e0e0;
        --wtm-chat-text-muted: #a0a0a0;
        --wtm-chat-border: #2a2a4a;
    }
    .wtm-chat-msg-bot .wtm-chat-msg-bubble {
        background: #1e1e3a;
        border-color: #2a2a4a;
    }
    .wtm-chat-input {
        background: #1e1e3a;
        border-color: #2a2a4a;
        color: #e0e0e0;
    }
    .wtm-chat-input::placeholder { color: #606080; }
    .wtm-chat-typing-dot { background: var(--wtm-bot-3); }
    .wtm-chat-quick-link {
        background: #1e1e3a;
        border-color: #2a2a4a;
        color: #e0e0e0;
    }
    .wtm-chat-quick-link:hover {
        background: rgba(99, 102, 241, 0.15);
        border-color: var(--wtm-bot-1);
        color: var(--wtm-bot-3);
    }
}

/* ── Reduced Motion ── */
@media (prefers-reduced-motion: reduce) {
    .wtm-chat-panel,
    .wtm-chat-msg,
    .wtm-chat-toggle,
    .wtm-chat-typing-dot,
    .wtm-chat-dot {
        animation: none !important;
        transition-duration: 0.01ms !important;
    }
}
