/* ═══════════════════════════════════════════════════════
   TNEM™ Smart Chatbot — Frontend Styles
   Version: 1.0.0
═══════════════════════════════════════════════════════ */

:root {
    --tnem-primary:   #1a3a5c;
    --tnem-accent:    #e8a020;
    --tnem-white:     #ffffff;
    --tnem-light:     #f4f7fb;
    --tnem-border:    #dde3ec;
    --tnem-text:      #2c3e50;
    --tnem-subtext:   #6b7c93;
    --tnem-bot-bg:    #f0f4fa;
    --tnem-user-bg:   #1a3a5c;
    --tnem-shadow:    0 8px 40px rgba(26,58,92,.22);
    --tnem-radius:    18px;
    --tnem-radius-sm: 10px;
    --tnem-font:      'Segoe UI', system-ui, -apple-system, sans-serif;
    --tnem-z:         999999;
    --tnem-w:         370px;
    --tnem-h:         580px;
}

/* ── Wrap & Position ───────────────────────────────── */
#tnem-chatbot-wrap {
    position: fixed;
    z-index: var(--tnem-z);
    font-family: var(--tnem-font);
    font-size: 14px;
    line-height: 1.5;
    box-sizing: border-box;
}

#tnem-chatbot-wrap *,
#tnem-chatbot-wrap *::before,
#tnem-chatbot-wrap *::after {
    box-sizing: border-box;
}

.tnem-pos-bottom-right { bottom: 24px; right: 24px; }
.tnem-pos-bottom-left  { bottom: 24px; left: 24px; }

/* ── Launcher Button ───────────────────────────────── */
#tnem-chat-launcher {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--tnem-primary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(26,58,92,.45);
    transition: transform .2s ease, box-shadow .2s ease;
    position: relative;
    outline: none;
}

#tnem-chat-launcher:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(26,58,92,.55);
}

#tnem-chat-launcher:active { transform: scale(.96); }

.tnem-launcher-icon svg {
    width: 26px;
    height: 26px;
    color: var(--tnem-white);
    fill: var(--tnem-white);
    display: block;
}

/* notification dot */
.tnem-notif-dot {
    position: absolute;
    top: 6px; right: 6px;
    width: 12px; height: 12px;
    background: var(--tnem-accent);
    border-radius: 50%;
    border: 2px solid #fff;
    animation: tnem-pulse 2s infinite;
}

@keyframes tnem-pulse {
    0%,100% { transform: scale(1); opacity: 1; }
    50%      { transform: scale(1.3); opacity: .75; }
}

/* ── Chat Window ───────────────────────────────────── */
#tnem-chat-window {
    position: absolute;
    bottom: 72px;
    width: var(--tnem-w);
    max-height: var(--tnem-h);
    background: var(--tnem-white);
    border-radius: var(--tnem-radius);
    box-shadow: var(--tnem-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: tnem-slide-up .25s ease;
}

.tnem-pos-bottom-right #tnem-chat-window { right: 0; }
.tnem-pos-bottom-left  #tnem-chat-window { left: 0; }

@keyframes tnem-slide-up {
    from { opacity: 0; transform: translateY(16px) scale(.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Header ────────────────────────────────────────── */
.tnem-chat-header {
    background: var(--tnem-primary);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.tnem-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tnem-avatar {
    width: 42px; height: 42px;
    border-radius: 50%;
    background: var(--tnem-accent);
    display: flex; align-items: center; justify-content: center;
    color: var(--tnem-white);
    font-weight: 700;
    font-size: 13px;
    position: relative;
    flex-shrink: 0;
}

.tnem-online-dot {
    position: absolute;
    bottom: 1px; right: 1px;
    width: 11px; height: 11px;
    background: #22c55e;
    border-radius: 50%;
    border: 2px solid var(--tnem-primary);
}

.tnem-header-info strong {
    display: block;
    color: var(--tnem-white);
    font-size: 14px;
    font-weight: 600;
}

.tnem-header-info span {
    color: rgba(255,255,255,.65);
    font-size: 11.5px;
}

.tnem-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.tnem-hdr-btn {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: rgba(255,255,255,.12);
    border: none;
    cursor: pointer;
    color: var(--tnem-white);
    display: flex; align-items: center; justify-content: center;
    text-decoration: none;
    transition: background .15s;
}

.tnem-hdr-btn:hover { background: rgba(255,255,255,.22); }
.tnem-hdr-btn svg { width: 16px; height: 16px; fill: currentColor; }

/* ── Chat Body ─────────────────────────────────────── */
.tnem-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px 8px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--tnem-light);
    scroll-behavior: smooth;
}

.tnem-chat-body::-webkit-scrollbar { width: 4px; }
.tnem-chat-body::-webkit-scrollbar-track { background: transparent; }
.tnem-chat-body::-webkit-scrollbar-thumb { background: var(--tnem-border); border-radius: 4px; }

/* ── Message Bubbles ───────────────────────────────── */
.tnem-msg {
    display: flex;
    gap: 8px;
    max-width: 100%;
    animation: tnem-fadein .2s ease;
}

@keyframes tnem-fadein {
    from { opacity:0; transform: translateY(6px); }
    to   { opacity:1; transform: translateY(0); }
}

.tnem-msg.tnem-bot { align-items: flex-start; }
.tnem-msg.tnem-user { justify-content: flex-end; }

.tnem-msg-avatar {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--tnem-primary);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    margin-top: 2px;
}

.tnem-bubble {
    max-width: 84%;
    padding: 10px 13px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.55;
}

.tnem-bot .tnem-bubble {
    background: var(--tnem-white);
    color: var(--tnem-text);
    border: 1px solid var(--tnem-border);
    border-top-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.tnem-user .tnem-bubble {
    background: var(--tnem-primary);
    color: var(--tnem-white);
    border-top-right-radius: 4px;
}

.tnem-bubble strong { font-weight: 600; }
.tnem-bubble em { font-style: italic; color: inherit; opacity: .85; }
.tnem-bubble br { display: block; content: ''; margin-top: 4px; }

/* ── Quick Reply Buttons ───────────────────────────── */
.tnem-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    padding: 4px 0 4px 36px;
}

.tnem-qr-btn {
    background: var(--tnem-white);
    border: 1.5px solid var(--tnem-primary);
    color: var(--tnem-primary);
    border-radius: 20px;
    padding: 6px 13px;
    font-size: 12.5px;
    font-weight: 500;
    cursor: pointer;
    transition: all .15s;
    font-family: var(--tnem-font);
    white-space: nowrap;
}

.tnem-qr-btn:hover {
    background: var(--tnem-primary);
    color: var(--tnem-white);
    border-color: var(--tnem-primary);
    transform: translateY(-1px);
}

/* ── Link Buttons inside bubbles ───────────────────── */
.tnem-link-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.tnem-link-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--tnem-accent);
    color: var(--tnem-white) !important;
    border-radius: var(--tnem-radius-sm);
    padding: 6px 12px;
    font-size: 12.5px;
    font-weight: 600;
    text-decoration: none !important;
    transition: filter .15s, transform .15s;
    border: none;
    cursor: pointer;
    font-family: var(--tnem-font);
}

.tnem-link-btn:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

/* ── Typing indicator ──────────────────────────────── */
.tnem-typing {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
}

.tnem-typing-dots {
    display: flex;
    gap: 4px;
    background: var(--tnem-white);
    padding: 10px 14px;
    border-radius: 14px;
    border: 1px solid var(--tnem-border);
    border-top-left-radius: 4px;
}

.tnem-typing-dots span {
    width: 7px; height: 7px;
    background: var(--tnem-subtext);
    border-radius: 50%;
    animation: tnem-dot 1.2s infinite;
}

.tnem-typing-dots span:nth-child(2) { animation-delay: .2s; }
.tnem-typing-dots span:nth-child(3) { animation-delay: .4s; }

@keyframes tnem-dot {
    0%,60%,100% { transform: translateY(0); opacity: .4; }
    30%          { transform: translateY(-5px); opacity: 1; }
}

/* ── Lead Form ─────────────────────────────────────── */
.tnem-lead-form {
    position: absolute;
    inset: 0;
    background: var(--tnem-white);
    z-index: 10;
    overflow-y: auto;
    animation: tnem-fadein .2s ease;
}

.tnem-lead-form-inner {
    padding: 24px 20px;
}

.tnem-lead-form-inner h4 {
    margin: 0 0 6px;
    font-size: 17px;
    color: var(--tnem-primary);
}

.tnem-lead-form-inner p {
    margin: 0 0 16px;
    color: var(--tnem-subtext);
    font-size: 13px;
}

.tnem-lead-form-inner input,
.tnem-lead-form-inner textarea {
    width: 100%;
    padding: 10px 13px;
    border: 1.5px solid var(--tnem-border);
    border-radius: var(--tnem-radius-sm);
    font-family: var(--tnem-font);
    font-size: 13.5px;
    color: var(--tnem-text);
    background: var(--tnem-light);
    margin-bottom: 10px;
    outline: none;
    transition: border-color .15s;
    display: block;
}

.tnem-lead-form-inner input:focus,
.tnem-lead-form-inner textarea:focus {
    border-color: var(--tnem-primary);
    background: #fff;
}

.tnem-lead-form-inner textarea { min-height: 80px; resize: vertical; }

.tnem-lead-form-inner button#tnem-lead-submit {
    width: 100%;
    padding: 12px;
    background: var(--tnem-primary);
    color: #fff;
    border: none;
    border-radius: var(--tnem-radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--tnem-font);
    transition: filter .15s;
    margin-bottom: 8px;
}

.tnem-lead-form-inner button#tnem-lead-submit:hover { filter: brightness(1.12); }

.tnem-ghost-btn {
    width: 100%;
    padding: 10px;
    background: transparent;
    color: var(--tnem-subtext);
    border: 1.5px solid var(--tnem-border);
    border-radius: var(--tnem-radius-sm);
    font-size: 13px;
    cursor: pointer;
    font-family: var(--tnem-font);
    transition: border-color .15s;
}

.tnem-ghost-btn:hover { border-color: var(--tnem-primary); color: var(--tnem-primary); }

/* ── Footer Input ──────────────────────────────────── */
.tnem-chat-footer {
    padding: 10px 12px;
    background: var(--tnem-white);
    border-top: 1px solid var(--tnem-border);
    flex-shrink: 0;
}

.tnem-input-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

#tnem-chat-input {
    flex: 1;
    padding: 10px 14px;
    border: 1.5px solid var(--tnem-border);
    border-radius: 24px;
    font-size: 13.5px;
    font-family: var(--tnem-font);
    color: var(--tnem-text);
    outline: none;
    background: var(--tnem-light);
    transition: border-color .15s;
}

#tnem-chat-input:focus {
    border-color: var(--tnem-primary);
    background: #fff;
}

#tnem-chat-send {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: var(--tnem-primary);
    border: none;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: filter .15s;
}

#tnem-chat-send:hover { filter: brightness(1.15); }
#tnem-chat-send svg { width: 17px; height: 17px; fill: #fff; }

.tnem-footer-links {
    display: flex;
    gap: 10px;
    margin-top: 8px;
    justify-content: center;
}

.tnem-footer-links a,
.tnem-footer-links button {
    font-size: 11.5px;
    color: var(--tnem-subtext);
    text-decoration: none;
    background: none;
    border: none;
    cursor: pointer;
    font-family: var(--tnem-font);
    padding: 0;
    transition: color .15s;
}

.tnem-footer-links a:hover,
.tnem-footer-links button:hover { color: var(--tnem-primary); }

/* ── Date divider ──────────────────────────────────── */
.tnem-divider {
    text-align: center;
    font-size: 11px;
    color: var(--tnem-subtext);
    margin: 4px 0;
    position: relative;
}

.tnem-divider::before,
.tnem-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 30%;
    height: 1px;
    background: var(--tnem-border);
}

.tnem-divider::before { left: 0; }
.tnem-divider::after  { right: 0; }

/* ── Success message ───────────────────────────────── */
.tnem-success-msg {
    text-align: center;
    padding: 30px 20px;
    color: var(--tnem-primary);
}

.tnem-success-msg .tnem-tick {
    font-size: 42px;
    display: block;
    margin-bottom: 10px;
}

/* ── Mobile responsive ─────────────────────────────── */
@media (max-width: 440px) {
    :root { --tnem-w: calc(100vw - 24px); }
    .tnem-pos-bottom-right #tnem-chat-window { right: 0; }
    .tnem-pos-bottom-left  #tnem-chat-window { left: 0; }
    #tnem-chatbot-wrap { bottom: 16px; right: 12px; }
    .tnem-pos-bottom-left { right: auto; left: 12px; }
}
