/* =========================================
   Transform AI – Chatbot Widget Styles
   ========================================= */

:root {
    --tai-purple:   #7c3aed;
    --tai-purple-l: #a855f7;
    --tai-dark:     #ffffff;
    --tai-dark2:    #f8fafc;
    --tai-dark3:    #f1f5f9;
    --tai-border:   #e2e8f0;
    --tai-text:     #1e293b;
    --tai-muted:    #64748b;
    --tai-radius:   16px;
    --tai-shadow:   0 16px 48px rgba(15,23,42,0.18), 0 0 0 1px rgba(124,58,237,0.12);
}

/* ── Toggle button ── */
#tai-chat-toggle {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--tai-purple), #4f46e5);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 8px 30px rgba(124,58,237,0.5);
    z-index: 9999;
    transition: transform 0.2s, box-shadow 0.2s;
}
#tai-chat-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 12px 40px rgba(124,58,237,0.65);
}
#tai-chat-toggle::after {
    content: '';
    position: absolute;
    width: 100%; height: 100%;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--tai-purple), #4f46e5);
    animation: tai-pulse 2.5s ease-out infinite;
    z-index: -1;
}
@keyframes tai-pulse {
    0%   { transform: scale(1);   opacity: .7; }
    100% { transform: scale(1.7); opacity: 0; }
}

/* ── Chat window ── */
#tai-chat-window {
    position: fixed;
    bottom: 100px;
    right: 28px;
    width: 370px;
    max-height: 560px;
    background: var(--tai-dark);
    border: 1px solid var(--tai-border);
    border-radius: var(--tai-radius);
    box-shadow: var(--tai-shadow);
    display: flex;
    flex-direction: column;
    z-index: 9998;
    overflow: hidden;
    animation: tai-slide-in 0.25s ease;
}
@keyframes tai-slide-in {
    from { opacity:0; transform: translateY(20px) scale(.97); }
    to   { opacity:1; transform: translateY(0) scale(1); }
}
#tai-chat-window[hidden] { display: none; }

/* ── Header ── */
#tai-chat-header {
    background: linear-gradient(135deg, #f5f3ff, #ede9fe);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--tai-border);
}
.tai-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}
.tai-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--tai-purple), #4f46e5);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 13px; color: #fff;
    flex-shrink: 0;
}
.tai-header-info strong {
    display: block;
    color: var(--tai-text);
    font-size: 14px;
    font-family: 'Segoe UI', system-ui, sans-serif;
}
.tai-header-info span {
    font-size: 11px;
    color: var(--tai-muted);
}
#tai-chat-clear {
    background: none;
    border: none;
    color: var(--tai-muted);
    cursor: pointer;
    font-size: 18px;
    padding: 4px 6px;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
}
#tai-chat-clear:hover { background: rgba(124,58,237,.10); color: var(--tai-purple); }

/* ── Messages ── */
#tai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scrollbar-width: thin;
    scrollbar-color: var(--tai-border) transparent;
}
.tai-msg { display: flex; }
.tai-msg--bot { justify-content: flex-start; }
.tai-msg--user { justify-content: flex-end; }

.tai-bubble {
    max-width: 82%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.55;
    font-family: 'Segoe UI', system-ui, sans-serif;
    word-break: break-word;
    white-space: pre-wrap;
}
.tai-msg--bot .tai-bubble {
    background: var(--tai-dark3);
    color: var(--tai-text);
    border: 1px solid var(--tai-border);
    border-bottom-left-radius: 4px;
}
.tai-msg--user .tai-bubble {
    background: linear-gradient(135deg, var(--tai-purple), #4f46e5);
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* Typing indicator */
.tai-typing .tai-bubble {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 12px 16px;
}
.tai-typing .tai-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--tai-purple-l);
    animation: tai-bounce 1.2s ease-in-out infinite;
}
.tai-typing .tai-dot:nth-child(2) { animation-delay: .2s; }
.tai-typing .tai-dot:nth-child(3) { animation-delay: .4s; }
@keyframes tai-bounce {
    0%,80%,100% { transform: translateY(0); opacity:.5; }
    40%          { transform: translateY(-6px); opacity:1; }
}

/* ── Input area ── */
#tai-chat-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid var(--tai-border);
    background: var(--tai-dark2);
}
#tai-chat-input {
    flex: 1;
    background: var(--tai-dark3);
    border: 1px solid var(--tai-border);
    border-radius: 10px;
    color: var(--tai-text);
    padding: 9px 13px;
    font-size: 14px;
    font-family: 'Segoe UI', system-ui, sans-serif;
    resize: none;
    max-height: 110px;
    outline: none;
    transition: border-color 0.15s;
}
#tai-chat-input:focus { border-color: var(--tai-purple-l); }
#tai-chat-input::placeholder { color: var(--tai-muted); }

#tai-chat-send {
    width: 38px; height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--tai-purple), #4f46e5);
    border: none;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    flex-shrink: 0;
    transition: opacity 0.15s, transform 0.15s;
}
#tai-chat-send:hover { opacity:.85; transform: scale(1.05); }
#tai-chat-send:disabled { opacity:.4; cursor:default; transform:none; }

/* ── Shared form & newsletter styles ── */
.tai-form-wrap,
.tai-nl-wrap {
    font-family: 'Segoe UI', system-ui, sans-serif;
}
.tai-form-msg {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 14px;
    font-size: 14px;
}
.tai-form-msg--ok  { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.tai-form-msg--err { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }

/* Training form */
.tai-form-wrap {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 32px;
    max-width: 620px;
    margin: 0 auto;
    color: #1e293b;
    box-shadow: 0 8px 32px rgba(15,23,42,.08);
}
.tai-form-header h3 { color: #1e293b; font-size: 22px; margin: 0 0 8px; }
.tai-form-header p  { color: #9ca3af; font-size: 14px; margin: 0 0 24px; }
.tai-form-row { margin-bottom: 18px; }
.tai-form-row label { display:block; font-size:13px; color:#475569; margin-bottom:6px; font-weight:600; }
.tai-form-row label span { color:#f87171; }
.tai-form-row input,
.tai-form-row select,
.tai-form-row textarea {
    width: 100%; box-sizing: border-box;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    color: #1e293b;
    padding: 10px 14px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s;
    font-family: inherit;
}
.tai-form-row input:focus,
.tai-form-row select:focus,
.tai-form-row textarea:focus { border-color: #a855f7; }
.tai-form-row select option   { background: #fff; }
.tai-form-row--half { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media(max-width:500px){ .tai-form-row--half { grid-template-columns: 1fr; } }

.tai-btn-submit {
    width: 100%;
    padding: 13px;
    background: linear-gradient(135deg, #7c3aed, #4f46e5);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s, transform 0.15s;
    margin-top: 6px;
}
.tai-btn-submit:hover   { opacity:.88; transform: translateY(-1px); }
.tai-btn-submit:disabled{ opacity:.5; cursor:default; transform:none; }

/* Newsletter */
.tai-nl-wrap {
    background: linear-gradient(135deg, #faf5ff 0%, #f5f3ff 100%);
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 36px;
    max-width: 680px;
    margin: 0 auto;
}
.tai-nl-inner { display: flex; flex-wrap: wrap; gap: 28px; align-items: center; }
.tai-nl-text  { flex: 1 1 260px; }
.tai-nl-text h3 { color:#1e293b; font-size:20px; margin:0 0 8px; }
.tai-nl-text p  { color:#64748b; font-size:14px; margin:0 0 12px; line-height:1.5; }
.tai-nl-gift { background:#ede9fe; border:1px solid #ddd6fe; border-radius:8px; padding:10px 14px; font-size:13px; color:#6d28d9; }
.tai-nl-form-area { flex: 1 1 240px; }
.tai-nl-form-area input {
    display:block; width:100%; box-sizing:border-box;
    background:#ffffff;
    border:1px solid #e2e8f0;
    border-radius:8px;
    color:#1e293b; padding:10px 14px;
    font-size:14px; margin-bottom:10px;
    outline:none; transition:border-color .15s;
    font-family:inherit;
}
.tai-nl-form-area input:focus { border-color:#a855f7; }
.tai-nl-form-area button {
    width:100%; padding:12px;
    background:linear-gradient(135deg,#7c3aed,#4f46e5);
    color:#fff; border:none; border-radius:8px;
    font-size:14px; font-weight:600; cursor:pointer;
    transition:opacity .15s;
}
.tai-nl-form-area button:hover   { opacity:.88; }
.tai-nl-form-area button:disabled{ opacity:.5; cursor:default; }
.tai-nl-privacy { color:#6b7280; font-size:12px; margin:8px 0 0; text-align:center; }

/* Mobile */
@media(max-width:420px){
    #tai-chat-window { width: calc(100vw - 24px); right:12px; bottom:90px; }
}
