/* ============================================================
   TechieNicks — chat widget
   Uses the same CSS variables as style.css (--bg, --surface,
   --text, --border, --gradient, --radius, --shadow, --font-*)
   so it automatically matches light/dark theme. Include this
   file AFTER style.css on any page that has the widget.
   ============================================================ */

.tn-chat-launcher {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 999;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: var(--gradient);
    color: #fff;
    box-shadow: var(--shadow);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .15s ease;
}

.tn-chat-launcher:hover {
    transform: scale(1.06);
}

.tn-chat-launcher img {
    width: 35px;
    height: 35px;
    object-fit: contain;
}

.tn-chat-launcher .tn-chat-close-icon {
    display: none;
}

.tn-chat-launcher[aria-expanded="true"] .tn-chat-open-icon {
    display: none;
}

.tn-chat-launcher[aria-expanded="true"] .tn-chat-close-icon {
    display: block;
}

.tn-chat-panel {
    position: fixed;
    right: 20px;
    bottom: 88px;
    z-index: 999;
    width: min(360px, calc(100vw - 40px));
    height: min(480px, calc(100vh - 140px));
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: var(--font-body);
    opacity: 0;
    transform: translateY(12px);
    pointer-events: none;
    transition: opacity .15s ease, transform .15s ease;
}

.tn-chat-panel[data-open="true"] {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.tn-chat-header {
    padding: 14px 16px;
    background: var(--gradient);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.tn-chat-avatar {
    width: 34px;
    height: 34px;
    margin-right: 10px;
    object-fit: contain;
    flex-shrink: 0;
}

.tn-chat-header h4 {
    margin: 0;
    font-family: var(--font-display);
    font-size: 0.95rem;
}

.tn-chat-header p {
    margin: 2px 0 0;
    font-size: 0.72rem;
    opacity: 0.9;
}

.tn-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tn-chat-msg {
    max-width: 85%;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 0.85rem;
    line-height: 1.45;
    white-space: pre-wrap;
}

.tn-chat-msg.tn-bot {
    align-self: flex-start;
    background: var(--bg-alt);
    color: var(--text);
    border-bottom-left-radius: 4px;
}

.tn-chat-msg.tn-user {
    align-self: flex-end;
    background: var(--gradient);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.tn-chat-msg.tn-error {
    align-self: flex-start;
    background: transparent;
    color: #C0392B;
    font-size: 0.78rem;
}

.tn-chat-typing {
    align-self: flex-start;
    display: flex;
    gap: 4px;
    padding: 8px 12px;
}

.tn-chat-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
    opacity: 0.5;
    animation: tn-chat-bounce 1s infinite ease-in-out;
}

.tn-chat-typing span:nth-child(2) {
    animation-delay: .15s;
}

.tn-chat-typing span:nth-child(3) {
    animation-delay: .3s;
}

@keyframes tn-chat-bounce {

    0%,
    80%,
    100% {
        opacity: 0.3;
        transform: translateY(0);
    }

    40% {
        opacity: 1;
        transform: translateY(-3px);
    }
}

.tn-chat-form {
    display: flex;
    gap: 8px;
    padding: 10px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.tn-chat-input {
    flex: 1;
    resize: none;
    max-height: 80px;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-family: inherit;
    font-size: 0.85rem;
}

.tn-chat-input:focus {
    outline: 2px solid var(--purple);
    outline-offset: 1px;
}

.tn-chat-send {
    border: none;
    background: var(--gradient);
    color: #fff;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    flex-shrink: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tn-chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.tn-chat-send svg {
    width: 16px;
    height: 16px;
}

@media (max-width: 480px) {
    .tn-chat-panel {
        right: 12px;
        left: 12px;
        width: auto;
        bottom: 82px;
    }

    .tn-chat-launcher {
        right: 16px;
        bottom: 16px;
    }
}