/* TurboTier Chat frontend widget — brand tokens */
#tc-chat-container {
    --tc-brand: #0e4d36;
    --tc-brand-2: #0a3b29;
    --tc-accent: #ef6330;
    --tc-paper: #f5f2ea;
    --tc-surface: #fffdf8;
    --tc-ink: #15201a;
    --tc-muted: #58635c;
    --tc-line: #e2dccd;
    font-family: "Schibsted Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.4;
    color: var(--tc-ink);
    z-index: 999999;
    -webkit-font-smoothing: antialiased;
}

#tc-chat-container *, #tc-chat-container *::before, #tc-chat-container *::after {
    box-sizing: border-box;
}

/* Chat Bubble */
.tc-bubble {
    position: fixed;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(14, 77, 54, 0.3);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    z-index: 999999;
}
.tc-bubble:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(14, 77, 54, 0.4);
}
.tc-bubble svg {
    width: 28px;
    height: 28px;
    fill: #fff;
}
.tc-bubble .tc-unread-dot {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 20px;
    height: 20px;
    background: #ef4444;
    color: #fff;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
}

/* Chat Window */
.tc-window {
    position: fixed;
    width: 380px;
    height: 520px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(14, 77, 54, 0.18), 0 2px 8px rgba(0, 0, 0, 0.06);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 999998;
    animation: tcSlideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes tcSlideUp {
    from { opacity: 0; transform: translateY(24px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Header */
.tc-header {
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: default;
    flex-shrink: 0;
}
.tc-header-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}
.tc-header-avatar-placeholder {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 600;
    font-size: 16px;
    flex-shrink: 0;
}
.tc-header-info { flex: 1; min-width: 0; }
.tc-header-title { color: #fff; font-weight: 700; font-size: 14px; line-height: 1.2; }
.tc-header-status { color: rgba(255,255,255,0.85); font-size: 11px; }
.tc-header-close {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    line-height: 1;
    transition: background 0.2s;
}
.tc-header-close:hover { background: rgba(255,255,255,0.3); }

/* Greeting Bubble */
.tc-greeting {
    position: fixed;
    background: #fff;
    border-radius: 14px;
    padding: 16px 20px;
    box-shadow: 0 6px 24px rgba(14, 77, 54, 0.15);
    max-width: 280px;
    font-size: 13px;
    line-height: 1.5;
    z-index: 999997;
    animation: tcFadeIn 0.3s ease;
    border: 1px solid #e2dccd;
}
.tc-greeting::after {
    content: '';
    position: absolute;
    bottom: -8px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid #fff;
}
.tc-greeting-close {
    position: absolute;
    top: 6px;
    right: 8px;
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 16px;
    padding: 0;
    transition: color 0.2s;
}
.tc-greeting-close:hover { color: #15201a; }
@keyframes tcFadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Messages Area */
.tc-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #f5f2ea;
}

/* Message Bubbles */
.tc-msg {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 13px;
    line-height: 1.45;
    word-wrap: break-word;
    animation: tcMsgIn 0.2s ease;
}
@keyframes tcMsgIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.tc-msg-visitor {
    background: rgba(14, 77, 54, 0.1);
    color: #15201a;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}
.tc-msg-agent {
    background: #fffdf8;
    color: #15201a;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(14, 77, 54, 0.06);
    border: 1px solid #e2dccd;
}
.tc-msg-system {
    background: transparent;
    color: #94a3b8;
    align-self: center;
    font-size: 11px;
    padding: 4px 8px;
    max-width: 90%;
    text-align: center;
}
.tc-msg-time {
    font-size: 10px;
    color: #94a3b8;
    margin-top: 4px;
    text-align: right;
}
.tc-msg-agent .tc-msg-time { text-align: left; }

/* File Messages */
.tc-msg-file {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
}
.tc-msg-file-icon { font-size: 18px; }
.tc-msg-file a {
    color: inherit;
    text-decoration: underline;
    word-break: break-all;
}
.tc-msg-image img {
    max-width: 100%;
    border-radius: 10px;
    cursor: pointer;
}

/* Typing Indicator */
.tc-typing {
    align-self: flex-start;
    padding: 10px 14px;
    background: #fff;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(14, 77, 54, 0.06);
}
.tc-typing-dots { display: flex; gap: 4px; }
.tc-typing-dots span {
    width: 7px;
    height: 7px;
    background: #0e4d36;
    border-radius: 50%;
    animation: tcTyping 1.4s infinite;
}
.tc-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.tc-typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes tcTyping {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.3; }
    30% { transform: translateY(-5px); opacity: 1; }
}

/* Input Area */
.tc-input-area {
    padding: 12px 14px;
    border-top: 1px solid #e2dccd;
    flex-shrink: 0;
    background: #fff;
}
.tc-input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}
.tc-input-row textarea {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #e2dccd;
    border-radius: 22px;
    resize: none;
    font-size: 13px;
    font-family: inherit;
    line-height: 1.4;
    max-height: 100px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #f5f2ea;
    color: #15201a;
}
.tc-input-row textarea:focus { border-color: #0e4d36; box-shadow: 0 0 0 3px rgba(14, 77, 54, 0.1); background: #fff; }
.tc-send-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}
.tc-send-btn:hover { opacity: 0.9; transform: scale(1.05); }
.tc-send-btn svg { width: 18px; height: 18px; fill: #fff; }
.tc-input-actions {
    display: flex;
    gap: 8px;
    padding-top: 6px;
}
.tc-action-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #94a3b8;
    font-size: 18px;
    padding: 2px;
    transition: color 0.2s;
}
.tc-action-btn:hover { color: #0e4d36; }

/* Pre-Chat Form */
.tc-prechat {
    flex: 1;
    padding: 24px 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.tc-prechat h3 { margin: 0 0 6px; font-size: 16px; text-align: center; color: #15201a; font-weight: 700; }
.tc-prechat p { margin: 0; font-size: 12px; color: #64748b; text-align: center; }
.tc-prechat-field { display: flex; flex-direction: column; gap: 5px; }
.tc-prechat-field label { font-size: 12px; font-weight: 600; color: #15201a; }
.tc-prechat-field input, .tc-prechat-field select, .tc-prechat-field textarea {
    padding: 10px 12px;
    border: 1px solid #e2dccd;
    border-radius: 10px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    color: #15201a;
    background: #f5f2ea;
}
.tc-prechat-field input:focus, .tc-prechat-field select:focus, .tc-prechat-field textarea:focus { border-color: #0e4d36; box-shadow: 0 0 0 3px rgba(14, 77, 54, 0.1); background: #fff; }
.tc-prechat-submit {
    padding: 12px;
    border: none;
    border-radius: 10px;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}
.tc-prechat-submit:hover { opacity: 0.9; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(14, 77, 54, 0.3); }

/* GDPR Checkbox */
.tc-gdpr-check {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    font-size: 11px;
    color: #64748b;
}
.tc-gdpr-check input { margin-top: 2px; accent-color: #0e4d36; }

/* Offline Form */
.tc-offline { text-align: center; padding: 30px 20px; flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.tc-offline h3 { margin: 0; font-size: 16px; color: #15201a; }
.tc-offline p { color: #64748b; font-size: 13px; margin: 0; }

/* Rating */
.tc-rating { text-align: center; padding: 20px; }
.tc-rating h4 { margin: 0 0 10px; color: #15201a; }
.tc-rating-stars { display: flex; justify-content: center; gap: 4px; margin-bottom: 10px; }
.tc-rating-star {
    font-size: 28px;
    background: none;
    border: none;
    cursor: pointer;
    color: #e2dccd;
    transition: color 0.2s, transform 0.2s;
    padding: 0;
}
.tc-rating-star.active, .tc-rating-star:hover { color: #f59e0b; transform: scale(1.15); }
.tc-rating textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e2dccd;
    border-radius: 10px;
    font-size: 13px;
    resize: vertical;
    margin-bottom: 8px;
    font-family: inherit;
    outline: none;
    color: #15201a;
    background: #f5f2ea;
    transition: border-color 0.2s;
}
.tc-rating textarea:focus { border-color: #0e4d36; }
.tc-rating-submit {
    padding: 10px 24px;
    border: none;
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s;
}
.tc-rating-submit:hover { opacity: 0.9; }

/* Emoji Picker (simple) */
.tc-emoji-picker {
    position: absolute;
    bottom: 70px;
    left: 12px;
    background: #fff;
    border: 1px solid #e2dccd;
    border-radius: 12px;
    padding: 10px;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
    box-shadow: 0 6px 24px rgba(14, 77, 54, 0.15);
    max-height: 200px;
    overflow-y: auto;
    z-index: 10;
}
.tc-emoji-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 18px;
    border-radius: 6px;
    transition: background 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.tc-emoji-btn:hover { background: #e2dccd; }

/* File Upload (hidden) */
.tc-file-input { display: none; }

/* Mobile Responsive */
@media ( max-width: 480px ) {
    .tc-window {
        width: 100% !important;
        height: 100% !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        border-radius: 0;
    }
    .tc-bubble {
        width: 52px;
        height: 52px;
    }
    .tc-bubble svg {
        width: 24px;
        height: 24px;
    }
}

/* Scrollbar */
.tc-messages::-webkit-scrollbar { width: 5px; }
.tc-messages::-webkit-scrollbar-track { background: transparent; }
.tc-messages::-webkit-scrollbar-thumb { background: #e2dccd; border-radius: 3px; }
.tc-messages::-webkit-scrollbar-thumb:hover { background: #b8c7e5; }

/* Connection status bar */
.tc-connection-bar {
    padding: 5px 12px;
    text-align: center;
    font-size: 11px;
    color: #64748b;
    background: #f5f2ea;
    flex-shrink: 0;
}

/* Returning visitor welcome */
.tc-returning-welcome {
    padding: 10px 14px;
    background: #ecfdf5;
    border-bottom: 1px solid #a7f3d0;
    font-size: 12px;
    color: #059669;
    text-align: center;
    font-weight: 500;
}
