/* Techcraft AI Assistant Styles */

/* CSS variables injected by JS from plugin settings */
:root {
    --tcsi-chat-primary:  #2F5FD0;
    --tcsi-chat-primary-dk: #1A3472;
    --tcsi-chat-accent:   #5B8AF5;
    --tcsi-chat-accent-lt:#C7D8FC;
    /* rgb triples so the shadows and hairlines below can follow the brand
       colours at their own alphas instead of hardcoding them */
    --tcsi-chat-primary-rgb: 47,95,208;
    --tcsi-chat-accent-rgb:  91,138,245;
    --tcsi-chat-bg:       #F4F5F8;
    --tcsi-chat-white:    #ffffff;
    --tcsi-chat-border:   rgba(91,138,245,0.28);
    /* Body-text tones: neutral on purpose, not tinted toward the brand
       colour, so they keep their contrast whatever primary is set to. */
    --tcsi-chat-ink:      #0A1E44;
    --tcsi-chat-muted:    #5C6679;
}

/* FAB Container */
.tcsi-chat-fab {
    position: fixed;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
    bottom: 28px;
    right: 28px;
}
.tcsi-chat-fab.position-left { right: auto; left: 28px; align-items: flex-start; }

/* Hint bubble */
.tcsi-chat-hint {
    background: var(--tcsi-chat-white);
    border: 1.5px solid var(--tcsi-chat-primary);
    border-radius: 12px;
    padding: 10px 16px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--tcsi-chat-ink);
    white-space: nowrap;
    box-shadow: 0 8px 28px rgba(var(--tcsi-chat-primary-rgb),0.2);
    animation: tcsiBubbleIn 0.5s ease 2s both;
    position: relative;
    font-family: system-ui, sans-serif;
}
.tcsi-chat-hint::after {
    content: '';
    position: absolute;
    bottom: -7px;
    right: 18px;
    width: 12px; height: 12px;
    background: var(--tcsi-chat-white);
    border-right: 1.5px solid var(--tcsi-chat-primary);
    border-bottom: 1.5px solid var(--tcsi-chat-primary);
    transform: rotate(45deg);
}
@keyframes tcsiBubbleIn {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* FAB Toggle Button.
   Default is a 52px circle. When a launcher label is configured the button
   becomes a pill carrying a spark dot and that label; it collapses back to a
   circle while the panel is open. */
.tcsi-chat-toggle {
    width: 52px; height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--tcsi-chat-primary-dk), var(--tcsi-chat-primary));
    border: none;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.6rem;
    box-shadow: 0 6px 24px rgba(var(--tcsi-chat-primary-rgb),0.45),
                0 0 0 3px rgba(var(--tcsi-chat-accent-rgb),0.3);
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
}
.tcsi-chat-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 32px rgba(var(--tcsi-chat-primary-rgb),0.55),
                0 0 0 4px rgba(var(--tcsi-chat-accent-rgb),0.45);
}
.tcsi-chat-badge {
    position: absolute;
    top: -3px; right: -3px;
    width: 18px; height: 18px;
    border-radius: 50%;
    background: var(--tcsi-chat-accent);
    border: 2px solid var(--tcsi-chat-bg);
    animation: tcsiPulse 2s infinite;
}
@keyframes tcsiPulse {
    0%,100% { transform: scale(1); opacity: 1; }
    50%      { transform: scale(0.65); opacity: 0.7; }
}

/* Pill variant */
.tcsi-chat-toggle.has-label { width: auto; padding: 0 22px; gap: 10px; border-radius: 999px; }
.tcsi-chat-toggle.has-label .tcsi-chat-toggle-glyph { display: none; }
.tcsi-chat-spark {
    flex: 0 0 auto;
    width: 9px; height: 9px; border-radius: 50%;
    background: var(--tcsi-chat-accent);
    box-shadow: 0 0 0 4px rgba(var(--tcsi-chat-accent-rgb), 0.25);
}
.tcsi-chat-label {
    color: #fff; font-size: 0.95rem; font-weight: 600;
    letter-spacing: -0.01em; white-space: nowrap; line-height: 1;
    font-family: system-ui, sans-serif;
}
.tcsi-chat-toggle.has-label.is-open { width: 52px; padding: 0; gap: 0; }
.tcsi-chat-toggle.is-open .tcsi-chat-spark,
.tcsi-chat-toggle.is-open .tcsi-chat-label { display: none; }

/* Launcher row: WhatsApp (optional) sits beside the toggle, centres aligned,
   so the site does not have to guess the pill's width to position it. */
.tcsi-chat-launchers { display: flex; align-items: center; gap: 12px; }
.tcsi-chat-fab.position-left .tcsi-chat-launchers { flex-direction: row-reverse; }
.tcsi-chat-wa {
    flex: 0 0 auto;
    width: 52px; height: 52px; border-radius: 50%;
    background: #1EBE5D;
    display: flex; align-items: center; justify-content: center;
    text-decoration: none;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 6px 20px rgba(30,190,93,0.35);
}
.tcsi-chat-wa:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(30,190,93,0.45); }
.tcsi-chat-wa svg { width: 27px; height: 27px; fill: #fff; }

/* Chat Window */
.tcsi-chat-window {
    position: fixed;
    bottom: 104px;
    right: 28px;
    width: 380px;
    height: 560px;
    background: var(--tcsi-chat-white);
    border: 1.5px solid rgba(var(--tcsi-chat-primary-rgb),0.2);
    border-radius: 22px;
    box-shadow: 0 32px 80px rgba(var(--tcsi-chat-primary-rgb),0.22),
                0 0 0 1px rgba(var(--tcsi-chat-accent-rgb),0.15);
    z-index: 99998;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.85) translateY(24px);
    opacity: 0;
    pointer-events: none;
    transform-origin: bottom right;
    transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.tcsi-chat-window.is-open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: all;
}
.tcsi-chat-fab.position-left .tcsi-chat-window {
    right: auto;
    left: 28px;
    transform-origin: bottom left;
}

/* Header */
.tcsi-chat-header {
    background: linear-gradient(135deg, var(--tcsi-chat-primary-dk), var(--tcsi-chat-primary));
    padding: 18px 20px;
    display: flex; align-items: center; gap: 12px;
    flex-shrink: 0;
    border-bottom: 2px solid rgba(var(--tcsi-chat-accent-rgb),0.3);
}
.tcsi-chat-avatar {
    width: 42px; height: 42px; border-radius: 50%;
    background: rgba(var(--tcsi-chat-accent-rgb),0.2);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.15rem; flex-shrink: 0; position: relative;
}
.tcsi-chat-avatar-ring {
    position: absolute; bottom: 1px; right: 1px;
    width: 11px; height: 11px; border-radius: 50%;
    background: var(--tcsi-chat-accent);
    border: 2px solid var(--tcsi-chat-primary-dk);
}
.tcsi-chat-name   { font-weight: 700; font-size: 0.92rem; color: #fff; font-family: system-ui, sans-serif; }
.tcsi-chat-status { font-size: 0.7rem; color: var(--tcsi-chat-accent-lt); font-family: system-ui, sans-serif; }
.tcsi-chat-close  {
    margin-left: auto;
    background: rgba(255,255,255,0.1);
    border: none; color: rgba(255,255,255,0.8);
    cursor: pointer; font-size: 1rem;
    width: 30px; height: 30px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.2s;
}
.tcsi-chat-close:hover { background: rgba(255,255,255,0.22); }

/* Messages */
.tcsi-chat-messages {
    flex: 1; overflow-y: auto; padding: 20px;
    display: flex; flex-direction: column; gap: 14px;
    background: var(--tcsi-chat-bg);
    scrollbar-width: thin;
    scrollbar-color: var(--tcsi-chat-border) transparent;
}
.tcsi-chat-msg {
    max-width: 86%;
    animation: tcsiMsgIn 0.28s ease;
    font-family: system-ui, sans-serif;
}
@keyframes tcsiMsgIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}
.tcsi-chat-msg.bot  { align-self: flex-start; }
.tcsi-chat-msg.user { align-self: flex-end; }

.tcsi-chat-msg-label {
    font-size: 0.67rem; font-weight: 600;
    color: var(--tcsi-chat-muted); margin-bottom: 5px;
    display: flex; align-items: center; gap: 6px;
}
.tcsi-chat-ai-pill {
    background: rgba(var(--tcsi-chat-primary-rgb),0.1);
    color: var(--tcsi-chat-primary);
    padding: 1px 7px; border-radius: 4px;
    font-size: 0.6rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.06em;
}
.tcsi-chat-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 0.84rem;
    line-height: 1.65;
}
.tcsi-chat-msg.bot  .tcsi-chat-bubble {
    background: var(--tcsi-chat-white);
    border: 1.5px solid var(--tcsi-chat-border);
    border-bottom-left-radius: 4px;
    color: var(--tcsi-chat-ink);
}
.tcsi-chat-msg.user .tcsi-chat-bubble {
    background: linear-gradient(135deg, var(--tcsi-chat-primary-dk), var(--tcsi-chat-primary));
    color: #fff;
    border-bottom-right-radius: 4px;
    font-weight: 500;
}

/* Quick chips */
.tcsi-chat-chips {
    display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px;
}
.tcsi-chat-chip {
    padding: 5px 13px; border-radius: 100px;
    border: 1.5px solid rgba(var(--tcsi-chat-primary-rgb),0.22);
    font-size: 0.72rem; color: var(--tcsi-chat-primary);
    cursor: pointer; font-weight: 600;
    background: var(--tcsi-chat-white);
    transition: background 0.2s, color 0.2s;
    font-family: system-ui, sans-serif;
}
.tcsi-chat-chip:hover {
    background: var(--tcsi-chat-primary);
    color: #fff;
    border-color: var(--tcsi-chat-primary);
}

/* Typing indicator */
.tcsi-chat-typing {
    background: var(--tcsi-chat-white);
    border: 1.5px solid var(--tcsi-chat-border);
    border-radius: 16px; border-bottom-left-radius: 4px;
    padding: 12px 18px;
    display: flex; align-items: center; gap: 5px;
}
.tcsi-chat-dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--tcsi-chat-primary);
    animation: tcsiBounce 1.3s infinite ease-in-out;
}
.tcsi-chat-dot:nth-child(2) { animation-delay: 0.2s; }
.tcsi-chat-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes tcsiBounce {
    0%,60%,100% { transform: translateY(0); opacity: 0.4; }
    30%          { transform: translateY(-7px); opacity: 1; }
}

/* Input row */
.tcsi-chat-input-row {
    padding: 14px 16px;
    background: var(--tcsi-chat-white);
    border-top: 1.5px solid var(--tcsi-chat-border);
    display: flex; gap: 10px; align-items: center;
    flex-shrink: 0;
}
.tcsi-chat-input {
    flex: 1;
    background: var(--tcsi-chat-bg);
    border: 1.5px solid var(--tcsi-chat-border);
    border-radius: 100px;
    padding: 11px 18px;
    color: var(--tcsi-chat-ink);
    font-family: system-ui, sans-serif;
    font-size: 0.83rem;
    outline: none;
    transition: border-color 0.2s;
}
.tcsi-chat-input::placeholder { color: var(--tcsi-chat-muted); }
.tcsi-chat-input:focus { border-color: var(--tcsi-chat-primary); }
.tcsi-chat-send {
    width: 42px; height: 42px; border-radius: 50%;
    background: linear-gradient(135deg, var(--tcsi-chat-primary-dk), var(--tcsi-chat-primary));
    border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: #fff; flex-shrink: 0; font-size: 1rem;
    box-shadow: 0 4px 14px rgba(var(--tcsi-chat-primary-rgb),0.35);
    transition: transform 0.15s, box-shadow 0.15s;
}
.tcsi-chat-send:hover { transform: scale(1.08); box-shadow: 0 6px 20px rgba(var(--tcsi-chat-primary-rgb),0.45); }
.tcsi-chat-send:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

/* Screen reader only */
.tcsi-chat-fab .sr-only {
    position: absolute; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* Mobile */
@media (max-width: 480px) {
    .tcsi-chat-window {
        width: calc(100vw - 24px);
        height: 70vh;
        right: 12px; bottom: 90px;
    }
}
