/* ═══════════════════════════════════════
   24 Total Service AI Chat Widget
   ═══════════════════════════════════════ */

:root {
    --ts-primary: #468dab;
    --ts-primary-dark: #3a7892;
    --ts-primary-light: #e6f1f5;
    --ts-text: #1f2937;
    --ts-text-light: #6b7280;
    --ts-bg: #ffffff;
    --ts-bg-gray: #f3f4f6;
    --ts-border: #e5e7eb;
    --ts-shadow: 0 10px 40px rgba(0,0,0,0.15);
    --ts-radius: 16px;
}

/* ── Toggle Button ── */

#ts-chat-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999999;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: transparent;
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    box-shadow: none;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

#ts-chat-toggle:hover {
    transform: scale(1.08);
}

#ts-chat-toggle.ts-chat-open {
    background: var(--ts-primary);
    border-radius: 50%;
    box-shadow: 0 4px 20px rgba(70, 141, 171, 0.4);
}

#ts-chat-toggle.ts-chat-open:hover {
    box-shadow: 0 6px 28px rgba(70, 141, 171, 0.5);
}

#ts-chat-icon-open {
    width: 60px;
    height: 60px;
    object-fit: contain;
    filter: drop-shadow(0 4px 12px rgba(70, 141, 171, 0.4));
}

#ts-chat-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: #ef4444;
    color: #fff;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
    animation: ts-pulse 2s infinite;
}

@keyframes ts-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* ── Chat Window ── */

#ts-chat-window {
    position: fixed;
    bottom: 90px;
    right: 20px;
    z-index: 999998;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 520px;
    max-height: calc(100vh - 120px);
    background: var(--ts-bg);
    border-radius: var(--ts-radius);
    box-shadow: var(--ts-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: ts-slide-up 0.3s ease;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

@keyframes ts-slide-up {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── Header ── */

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

#ts-chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

#ts-chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,0.9);
    object-fit: cover;
    flex-shrink: 0;
}

#ts-chat-title {
    font-weight: 700;
    font-size: 15px;
    line-height: 1.2;
}

#ts-chat-subtitle {
    font-size: 12px;
    opacity: 0.85;
    line-height: 1.3;
}

#ts-chat-header-actions {
    display: flex;
    gap: 8px;
}

#ts-chat-header-actions a {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    text-decoration: none;
    transition: background 0.2s;
}

#ts-chat-header-actions a:hover {
    background: rgba(255,255,255,0.3);
}

/* ── Messages Area ── */

#ts-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--ts-bg-gray);
}

#ts-chat-messages::-webkit-scrollbar {
    width: 4px;
}

#ts-chat-messages::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 4px;
}

.ts-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    animation: ts-msg-in 0.2s ease;
}

@keyframes ts-msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.ts-msg-bot {
    background: var(--ts-bg);
    color: var(--ts-text);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

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

.ts-msg-typing {
    background: var(--ts-bg);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    padding: 14px 18px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.ts-typing-dots {
    display: flex;
    gap: 4px;
}

.ts-typing-dots span {
    width: 8px;
    height: 8px;
    background: #9ca3af;
    border-radius: 50%;
    animation: ts-bounce 1.4s infinite;
}

.ts-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.ts-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes ts-bounce {
    0%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-6px); }
}

/* ── CTA inside messages ── */

.ts-msg-cta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    padding: 8px 14px;
    background: var(--ts-primary);
    color: #fff;
    border-radius: 8px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    transition: background 0.2s;
}

.ts-msg-cta:hover {
    background: var(--ts-primary-dark);
    color: #fff;
}

/* ── Input Area ── */

#ts-chat-input-area {
    border-top: 1px solid var(--ts-border);
    background: var(--ts-bg);
    flex-shrink: 0;
}

#ts-chat-quick-btns {
    display: flex;
    gap: 6px;
    padding: 10px 12px 0;
    flex-wrap: wrap;
}

.ts-quick-btn {
    padding: 6px 12px;
    border: 1px solid var(--ts-border);
    border-radius: 20px;
    background: var(--ts-bg);
    color: var(--ts-primary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.ts-quick-btn:hover {
    background: var(--ts-primary-light);
    border-color: var(--ts-primary);
}

#ts-chat-input-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
}

#ts-chat-input {
    flex: 1;
    border: 1px solid var(--ts-border);
    border-radius: 24px;
    padding: 10px 16px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    color: var(--ts-text);
    background: var(--ts-bg);
    font-family: inherit;
}

#ts-chat-input:focus {
    border-color: var(--ts-primary);
}

#ts-chat-input::placeholder {
    color: #9ca3af;
}

#ts-chat-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 2px;
    transition: transform 0.15s;
}

#ts-chat-send img {
    width: 36px;
    height: 36px;
    object-fit: contain;
}

#ts-chat-send:hover {
    transform: scale(1.1);
}

#ts-chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ── Responsive ── */

@media (max-width: 480px) {
    #ts-chat-window {
        width: calc(100vw - 16px);
        right: 8px;
        bottom: 80px;
        height: calc(100vh - 100px);
        border-radius: 12px;
    }

    #ts-chat-toggle {
        right: 12px;
        bottom: 12px;
        width: 56px;
        height: 56px;
    }
}

/* ── Powered by ── */

.ts-powered-by {
    text-align: center;
    font-size: 11px;
    color: #9ca3af;
    padding: 4px 0 8px;
    background: var(--ts-bg);
}

.ts-powered-by a {
    color: #9ca3af;
    text-decoration: none;
}
