/* Talva Chat — Persistent Dashboard Companion
   Namespaced with tc- to avoid collisions with existing styles */

/* ── Collapsed trigger ─────────────────────────────────────────── */
.tc-trigger {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9998;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px 10px 14px;
    background: var(--accent, #6366f1);
    color: #fff;
    border: none;
    border-radius: 24px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.35);
    transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
    user-select: none;
}
.tc-trigger:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 24px rgba(99, 102, 241, 0.45);
}
.tc-trigger:active {
    transform: translateY(0);
}
.tc-trigger.tc-hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px);
}
.tc-trigger-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.tc-trigger-dot {
    position: absolute;
    top: -3px;
    right: -3px;
    width: 10px;
    height: 10px;
    background: #f43f5e;
    border-radius: 50%;
    border: 2px solid #fff;
    display: none;
}
.tc-trigger.tc-has-notification .tc-trigger-dot {
    display: block;
}

/* ── Panel container ───────────────────────────────────────────── */
.tc-panel {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    width: 400px;
    height: 520px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(16px) scale(0.97);
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
}
.tc-panel.tc-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* ── Header ────────────────────────────────────────────────────── */
.tc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid #f0f0f0;
    flex-shrink: 0;
}
.tc-header-title {
    font-size: 16px;
    font-weight: 700;
    color: #111;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
.tc-header-subtitle {
    font-size: 12px;
    color: #888;
    margin-left: 8px;
    font-weight: 400;
}
.tc-minimize-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 8px;
    color: #888;
    font-size: 18px;
    line-height: 1;
    transition: background 0.15s, color 0.15s;
}
.tc-minimize-btn:hover {
    background: #f5f5f5;
    color: #333;
}

/* ── Messages area ─────────────────────────────────────────────── */
.tc-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}
.tc-messages::-webkit-scrollbar {
    width: 4px;
}
.tc-messages::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 4px;
}

/* Welcome state (no messages yet) */
.tc-welcome {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px;
    text-align: center;
}
.tc-welcome-icon {
    width: 48px;
    height: 48px;
    background: var(--accent-light, #eef2ff);
    color: var(--accent, #6366f1);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin-bottom: 16px;
}
.tc-welcome h3 {
    font-size: 17px;
    font-weight: 700;
    color: #111;
    margin: 0 0 6px;
}
.tc-welcome p {
    font-size: 14px;
    color: #888;
    margin: 0;
    line-height: 1.5;
}
.tc-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 20px;
    justify-content: center;
}
.tc-suggestion {
    padding: 7px 14px;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    font-size: 13px;
    color: #555;
    cursor: pointer;
    background: #fff;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
    font-family: inherit;
}
.tc-suggestion:hover {
    border-color: var(--accent, #6366f1);
    color: var(--accent, #6366f1);
    background: var(--accent-light, #eef2ff);
}

/* ── Message bubbles ───────────────────────────────────────────── */
.tc-msg {
    display: flex;
    gap: 8px;
    max-width: 92%;
    animation: tc-fadeIn 0.2s ease;
}
.tc-msg-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}
.tc-msg-assistant {
    align-self: flex-start;
}
.tc-msg-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
.tc-msg-user .tc-msg-bubble {
    background: var(--accent, #6366f1);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.tc-msg-assistant .tc-msg-bubble {
    background: #f5f5f7;
    color: #222;
    border-bottom-left-radius: 4px;
}
.tc-msg-time {
    font-size: 11px;
    color: #aaa;
    margin-top: 4px;
    padding: 0 4px;
}
.tc-msg-assistant .tc-msg-time {
    text-align: left;
}
.tc-msg-user .tc-msg-time {
    text-align: right;
}

/* ── Typing indicator ──────────────────────────────────────────── */
.tc-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 16px;
    align-self: flex-start;
}
.tc-typing-dot {
    width: 7px;
    height: 7px;
    background: #ccc;
    border-radius: 50%;
    animation: tc-bounce 1.4s ease-in-out infinite;
}
.tc-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.tc-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes tc-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-5px); }
}
@keyframes tc-fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── Load more ─────────────────────────────────────────────────── */
.tc-load-more {
    text-align: center;
    padding: 8px;
}
.tc-load-more button {
    background: none;
    border: none;
    color: var(--accent, #6366f1);
    font-size: 13px;
    cursor: pointer;
    padding: 4px 12px;
    border-radius: 8px;
    transition: background 0.15s;
}
.tc-load-more button:hover {
    background: var(--accent-light, #eef2ff);
}

/* ── Input area ────────────────────────────────────────────────── */
.tc-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid #f0f0f0;
    flex-shrink: 0;
    background: #fff;
}
.tc-input {
    flex: 1;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
    max-height: 100px;
    min-height: 20px;
    line-height: 1.4;
    transition: border-color 0.15s;
    background: #fafafa;
}
.tc-input:focus {
    border-color: var(--accent, #6366f1);
    background: #fff;
}
.tc-input::placeholder {
    color: #aaa;
}
.tc-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--accent, #6366f1);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s, opacity 0.15s;
}
.tc-send-btn:hover {
    background: #4f46e5;
}
.tc-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.tc-send-btn svg {
    width: 16px;
    height: 16px;
}

/* ── Dividers (onboarding context markers) ─────────────────────── */
.tc-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    font-size: 12px;
    color: #aaa;
}
.tc-divider::before,
.tc-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #eee;
}

/* ── Phase B: Action links ─────────────────────────────────────── */
.tc-action-link {
    padding: 4px 0;
}
.tc-nav-btn {
    display: inline-block;
    padding: 8px 16px;
    background: var(--accent, #6366f1);
    color: #fff;
    border-radius: 10px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    transition: background 0.15s;
}
.tc-nav-btn:hover {
    background: #4f46e5;
}

/* ── Phase C: Onboarding mode ──────────────────────────────────── */
.tc-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 9997;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.tc-overlay-active {
    opacity: 1;
    pointer-events: auto;
}
.tc-panel.tc-onboarding-mode {
    width: 520px;
    height: 600px;
    bottom: 50%;
    right: 50%;
    transform: translate(50%, 50%) scale(1);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.05);
}
.tc-panel.tc-onboarding-mode.tc-open {
    transform: translate(50%, 50%) scale(1);
}

/* ── Mobile ────────────────────────────────────────────────────── */
@media (max-width: 600px) {
    .tc-panel {
        bottom: 0;
        right: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
    }
    .tc-panel.tc-onboarding-mode {
        width: 100%;
        height: 100%;
        bottom: 0;
        right: 0;
        transform: none;
        border-radius: 0;
    }
    .tc-panel.tc-onboarding-mode.tc-open {
        transform: none;
    }
    .tc-trigger {
        bottom: 16px;
        right: 16px;
    }
}
