/* =============================================================================
   AI Chat widget — floating assistant for the CV website.
   Matches the site's dark theme (see styles.css :root variables).
   The widget only becomes visible when the backend reports the chat is enabled.
   ============================================================================= */

.cvchat-fab {
    position: fixed;
    right: 1.5rem;
    bottom: 1.5rem;
    z-index: 1000;
    display: none;                 /* revealed by JS once chat is enabled */
    align-items: center;
    gap: 0.6rem;
    padding: 0.85rem 1.15rem;
    border: none;
    border-radius: 999px;
    cursor: pointer;
    color: #fff;
    font-family: var(--font-body, sans-serif);
    font-size: 0.95rem;
    font-weight: 600;
    background: var(--accent-gradient, linear-gradient(135deg, #1d9bf0, #71c9f8));
    box-shadow: 0 8px 24px rgba(29, 155, 240, 0.35);
    transition: transform var(--transition-fast, 0.2s), box-shadow var(--transition-fast, 0.2s);
}
.cvchat-fab:hover { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(29, 155, 240, 0.45); }
.cvchat-fab:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.cvchat-fab.cvchat-visible { display: inline-flex; }
.cvchat-fab svg { width: 20px; height: 20px; flex: none; }

.cvchat-panel {
    position: fixed;
    right: 1.5rem;
    bottom: 1.5rem;
    z-index: 1001;
    width: min(400px, calc(100vw - 3rem));
    height: min(600px, calc(100vh - 3rem));
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--border-accent, rgba(29, 155, 240, 0.4));
    border-radius: 18px;
    background: var(--bg-secondary, #15202b);
    box-shadow: var(--shadow-lg, 0 16px 48px rgba(0, 0, 0, 0.5));
    font-family: var(--font-body, sans-serif);
    color: var(--text-primary, #e7e9ea);
}
.cvchat-panel.cvchat-open { display: flex; animation: cvchat-pop 0.25s ease; }

@keyframes cvchat-pop {
    from { opacity: 0; transform: translateY(12px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.cvchat-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.9rem 1rem;
    background: linear-gradient(135deg, #192734 0%, #1c2938 100%);
    border-bottom: 1px solid var(--border-subtle, rgba(29, 155, 240, 0.15));
}
.cvchat-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    display: grid; place-items: center; flex: none;
    background: var(--accent-gradient, linear-gradient(135deg, #1d9bf0, #71c9f8));
    color: #fff; font-weight: 700;
}
.cvchat-title { display: flex; flex-direction: column; line-height: 1.2; flex: 1; min-width: 0; }
.cvchat-title strong { font-size: 0.98rem; }
.cvchat-title span { font-size: 0.75rem; color: var(--text-secondary, #8b98a5); }
.cvchat-close {
    background: none; border: none; cursor: pointer; color: var(--text-secondary, #8b98a5);
    font-size: 1.5rem; line-height: 1; padding: 0.2rem 0.4rem; border-radius: 8px;
}
.cvchat-close:hover { color: var(--text-primary, #e7e9ea); background: rgba(255, 255, 255, 0.06); }

.cvchat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.cvchat-msg {
    max-width: 85%;
    padding: 0.65rem 0.85rem;
    border-radius: 14px;
    font-size: 0.9rem;
    line-height: 1.45;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}
.cvchat-msg.cvchat-bot {
    align-self: flex-start;
    background: var(--bg-tertiary, #1c2938);
    border: 1px solid var(--border-subtle, rgba(29, 155, 240, 0.15));
    border-bottom-left-radius: 4px;
}
.cvchat-msg.cvchat-user {
    align-self: flex-end;
    background: var(--accent-dark, #1a8cd8);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.cvchat-msg.cvchat-error {
    align-self: center;
    background: rgba(220, 80, 80, 0.15);
    border: 1px solid rgba(220, 80, 80, 0.4);
    color: #ffb3b3;
    font-size: 0.82rem;
    text-align: center;
}

.cvchat-typing { display: inline-flex; gap: 4px; align-items: center; }
.cvchat-typing span {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--text-secondary, #8b98a5);
    animation: cvchat-blink 1.2s infinite ease-in-out both;
}
.cvchat-typing span:nth-child(2) { animation-delay: 0.2s; }
.cvchat-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes cvchat-blink { 0%, 80%, 100% { opacity: 0.2; } 40% { opacity: 1; } }

.cvchat-suggestions {
    display: flex; flex-wrap: wrap; gap: 0.4rem;
    padding: 0 1rem 0.5rem;
}
.cvchat-chip {
    padding: 0.4rem 0.7rem;
    border: 1px solid var(--border-accent, rgba(29, 155, 240, 0.4));
    border-radius: 999px;
    background: transparent;
    color: var(--accent-light, #4db5f9);
    font-size: 0.78rem;
    cursor: pointer;
    transition: background var(--transition-fast, 0.2s);
    font-family: inherit;
}
.cvchat-chip:hover { background: rgba(29, 155, 240, 0.12); }

.cvchat-input {
    display: flex; gap: 0.5rem;
    padding: 0.75rem;
    border-top: 1px solid var(--border-subtle, rgba(29, 155, 240, 0.15));
    background: var(--bg-primary, #0f1419);
}
.cvchat-input textarea {
    flex: 1;
    resize: none;
    max-height: 96px;
    min-height: 42px;
    padding: 0.6rem 0.75rem;
    border-radius: 12px;
    border: 1px solid var(--border-subtle, rgba(29, 155, 240, 0.15));
    background: var(--bg-secondary, #15202b);
    color: var(--text-primary, #e7e9ea);
    font-family: inherit;
    font-size: 0.9rem;
    line-height: 1.4;
}
.cvchat-input textarea:focus { outline: none; border-color: var(--accent-primary, #1d9bf0); }
.cvchat-send {
    flex: none;
    width: 42px; height: 42px;
    border: none; border-radius: 12px; cursor: pointer;
    display: grid; place-items: center;
    color: #fff;
    background: var(--accent-gradient, linear-gradient(135deg, #1d9bf0, #71c9f8));
}
.cvchat-send:disabled { opacity: 0.45; cursor: not-allowed; }
.cvchat-send svg { width: 20px; height: 20px; }

.cvchat-disclaimer {
    padding: 0 1rem 0.6rem;
    font-size: 0.68rem;
    color: var(--text-muted, #5c6d7e);
    text-align: center;
}

@media (max-width: 480px) {
    .cvchat-panel { right: 0; bottom: 0; width: 100vw; height: 100vh; border-radius: 0; }
    .cvchat-fab { right: 1rem; bottom: 1rem; }
    .cvchat-fab .cvchat-fab-label { display: none; }
}
