/**
 * File: trustchat/assets/css/trustchat-widget.css
 * Frontend widget CSS. Namespaced and resilient against theme/builder CSS.
 */
.tc-root,
.tc-root * {
    box-sizing: border-box;
}

.tc-root {
    --tc-primary: #2563eb;
    --tc-primary-dark: #1d4ed8;
    --tc-text: #111827;
    --tc-muted: #6b7280;
    --tc-border: rgba(17, 24, 39, .1);
    --tc-surface: #ffffff;
    --tc-soft: #f8fafc;
    position: fixed;
    z-index: 999999;
    right: 20px;
    bottom: 20px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    color: var(--tc-text);
    line-height: 1.4;
}

.tc-root.tc-pos-left {
    right: auto;
    left: 20px;
}

.tc-root button,
.tc-root input,
.tc-root textarea,
.tc-root a {
    font-family: inherit;
}

.tc-launcher {
    width: 62px;
    height: 62px;
    border: 0 !important;
    border-radius: 999px;
    background: var(--tc-primary) !important;
    color: #fff !important;
    cursor: pointer;
    box-shadow: 0 18px 44px rgba(37, 99, 235, .35);
    display: grid;
    place-items: center;
    position: relative;
    transition: transform .18s ease, box-shadow .18s ease;
    outline: none;
    padding: 0 !important;
    opacity: 1 !important;
    visibility: visible !important;
}

.tc-launcher:hover {
    transform: translateY(-2px);
    box-shadow: 0 22px 52px rgba(37, 99, 235, .42);
}

.tc-launcher:focus-visible {
    outline: 3px solid rgba(37, 99, 235, .28);
    outline-offset: 3px;
}

.tc-launcher-dot {
    width: 12px;
    height: 12px;
    background: #22c55e;
    border: 2px solid #fff;
    border-radius: 50%;
    position: absolute;
    right: 5px;
    top: 5px;
}

.tc-launcher-icon {
    position: absolute;
    display: grid;
    place-items: center;
    font-size: 26px;
    line-height: 1;
    transition: opacity .18s ease, transform .18s ease;
}

.tc-icon-chat {
    opacity: 1;
    transform: scale(1);
}

.tc-icon-close {
    opacity: 0;
    transform: rotate(-90deg) scale(.75);
    font-size: 36px;
    font-weight: 300;
    margin-top: -10px;
}

.tc-root[data-open="true"] .tc-icon-chat {
    opacity: 0;
    transform: rotate(90deg) scale(.75);
}

.tc-root[data-open="true"] .tc-icon-close {
    opacity: 1;
    transform: rotate(0) scale(1);
}

.tc-panel {
    width: min(380px, calc(100vw - 28px));
    height: min(620px, calc(100vh - 104px));
    position: absolute;
    right: 0;
    bottom: 78px;
    display: flex !important;
    flex-direction: column;
    background: #fff !important;
    color: var(--tc-text) !important;
    border: 1px solid var(--tc-border);
    border-radius: 22px;
    overflow: hidden;
    box-shadow: 0 24px 70px rgba(15, 23, 42, .22);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(16px) scale(.98);
    transform-origin: bottom right;
    transition: opacity .22s ease, transform .22s ease, visibility .22s ease;
}

.tc-pos-left .tc-panel {
    right: auto;
    left: 0;
    transform-origin: bottom left;
}

.tc-root[data-open="true"] .tc-panel {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    transform: translateY(0) scale(1) !important;
}

.tc-offline[hidden],
.tc-compose[hidden] {
    display: none !important;
}

.tc-header {
    background: var(--tc-primary) !important;
    color: #fff !important;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex: 0 0 auto;
}

.tc-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.tc-avatar {
    width: 44px !important;
    height: 44px !important;
    min-width: 44px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, .65);
    object-fit: cover;
    background: rgba(255, 255, 255, .2);
}

.tc-brand strong,
.tc-brand span {
    display: block;
}

.tc-brand strong {
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 230px;
    color: #fff !important;
}

.tc-status {
    margin-top: 2px;
    font-size: 12px;
    opacity: .92;
    color: rgba(255, 255, 255, .92) !important;
}

.tc-status::before {
    content: "";
    display: inline-block;
    width: 7px;
    height: 7px;
    margin-right: 6px;
    border-radius: 50%;
    background: #22c55e;
}

.tc-status-offline::before {
    background: #f59e0b;
}

.tc-close {
    width: 34px;
    height: 34px;
    border: 0 !important;
    border-radius: 50%;
    background: rgba(255, 255, 255, .14) !important;
    color: #fff !important;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    padding: 0 !important;
    display: flex;
    justify-content: center;
}

.tc-body {
    flex: 1 1 auto;
    min-height: 0;
    background: var(--tc-soft);
    display: flex;
    flex-direction: column;
}

.tc-messages {
    flex: 1;
    overflow-y: auto;
    padding: 18px 14px;
    scroll-behavior: smooth;
}

.tc-message {
    display: flex;
    margin: 0 0 10px;
}

.tc-message-admin {
    justify-content: flex-start;
}

.tc-message-visitor {
    justify-content: flex-end;
}

.tc-bubble {
    max-width: 82%;
    padding: 10px 12px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .06);
}

.tc-message-admin .tc-bubble {
    background: #fff;
    color: var(--tc-text);
    border-bottom-left-radius: 6px;
}

.tc-message-visitor .tc-bubble {
    color: #fff;
    background: var(--tc-primary);
    border-bottom-right-radius: 6px;
}

.tc-offline {
    padding: 14px;
    display: grid;
    gap: 9px;
    overflow-y: auto;
    background: #fff;
    border-top: 1px solid var(--tc-border);
}

.tc-offline-title {
    margin: 0 0 2px;
    font-weight: 700;
    font-size: 14px;
}

.tc-offline input,
.tc-offline textarea,
.tc-compose textarea {
    width: 100%;
    border: 1px solid var(--tc-border) !important;
    border-radius: 13px;
    color: var(--tc-text) !important;
    background: #fff !important;
    font: inherit;
    font-size: 14px;
    outline: none;
    box-shadow: none !important;
}

.tc-offline input,
.tc-offline textarea {
    padding: 11px 12px;
}

.tc-offline button,
.tc-compose button {
    border: 0 !important;
    border-radius: 13px;
    background: var(--tc-primary) !important;
    color: #fff !important;
    cursor: pointer;
    font-weight: 700;
    padding: 0;
}

.tc-offline button {
    min-height: 42px;
}

.tc-footer {
    border-top: 1px solid var(--tc-border);
    background: #fff;
    padding: 10px;
    flex: 0 0 auto;
}

.tc-compose {
    display: flex;
    align-items: end;
    gap: 8px;
}

.tc-compose textarea {
    min-height: 42px;
    max-height: 112px;
    resize: none;
    padding: 11px 12px;
}

.tc-compose button {
    width: 42px;
    height: 42px;
    flex: 0 0 auto;
}

.tc-quick-links {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 8px;
}

.tc-quick-links:empty {
    display: none;
}

.tc-quick-links a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 30px;
    padding: 0 10px;
    border-radius: 999px;
    background: #f3f4f6;
    color: #374151 !important;
    text-decoration: none !important;
    font-size: 12px;
    font-weight: 400;
}

@media (max-width: 640px) {
    .tc-root,
    .tc-root.tc-pos-left {
        right: 10px;
        left: 10px;
        bottom: 10px;
    }

    .tc-launcher {
        margin-left: auto;
    }

    .tc-pos-left .tc-launcher {
        margin-left: 0;
        margin-right: auto;
    }

    .tc-panel,
    .tc-pos-left .tc-panel {
        position: fixed;
        left: 10px;
        right: 10px;
        bottom: 82px;
        width: auto;
        height: min(680px, calc(100vh - 96px));
        border-radius: 22px;
        transform-origin: bottom center;
    }
}

/* v1.0.2 — profile capture + unread badge */
.tc-launcher-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 900;
    border: 2px solid #fff;
}
.tc-launcher-badge[hidden] { display: none !important; }
.tc-profile[hidden] { display: none !important; }
.tc-profile {
    margin: 0 12px 10px;
    padding: 12px;
    display: grid;
    gap: 9px;
    background: #fff;
    border: 1px solid var(--tc-border);
    border-radius: 16px;
    box-shadow: 0 10px 28px rgba(15, 23, 42, .06);
}
.tc-profile-title {
    margin: 0;
    font-size: 13px;
    color: var(--tc-muted);
    line-height: 1.35;
}
.tc-profile-grid { display: grid; gap: 8px; }
.tc-profile input {
    width: 100%;
    min-height: 38px;
    border: 1px solid var(--tc-border) !important;
    border-radius: 12px;
    padding: 0 11px;
    font: inherit;
    font-size: 13px;
    color: var(--tc-text) !important;
    background: #fff !important;
    outline: none;
    box-shadow: none !important;
}
.tc-profile-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}
.tc-profile button {
    min-height: 36px;
    border: 0 !important;
    border-radius: 12px;
    padding: 0 12px;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
}
.tc-profile button[type="submit"] {
    background: var(--tc-primary) !important;
    color: #fff !important;
}
.tc-profile-skip {
    background: #f3f4f6 !important;
    color: #374151 !important;
}
.tc-profile small,
.tc-offline small {
    min-height: 16px;
    font-size: 12px;
    color: var(--tc-muted);
}

/* v1.0.3 — mobile app-like polish + optimistic message states */
.tc-message-time {
    display: block;
    margin-top: 4px;
    font-size: 11px;
    color: var(--tc-muted);
}
.tc-message-visitor .tc-message-time {
    text-align: right;
}
.tc-message-pending .tc-bubble {
    opacity: .78;
}
.tc-message-pending .tc-message-time::before {
    content: "";
    display: inline-block;
    width: 6px;
    height: 6px;
    margin-right: 5px;
    border-radius: 50%;
    background: currentColor;
    opacity: .55;
}
.tc-message-error .tc-bubble {
    background: #fee2e2 !important;
    color: #991b1b !important;
    cursor: pointer;
}
.tc-message-error .tc-message-time {
    color: #b91c1c;
    cursor: pointer;
}
.tc-profile input:focus,
.tc-offline input:focus,
.tc-offline textarea:focus,
.tc-compose textarea:focus {
    border-color: color-mix(in srgb, var(--tc-primary) 55%, white) !important;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--tc-primary) 14%, transparent) !important;
}

@media (max-width: 640px) {
    html.tc-chat-open-mobile,
    html.tc-chat-open-mobile body {
        overflow: hidden !important;
        overscroll-behavior: contain;
    }

    .tc-root,
    .tc-root.tc-pos-left {
        right: max(10px, env(safe-area-inset-right));
        left: max(10px, env(safe-area-inset-left));
        bottom: max(10px, env(safe-area-inset-bottom));
        width: auto;
    }

    .tc-launcher {
        width: 60px;
        height: 60px;
        box-shadow: 0 18px 42px rgba(37,99,235,.32);
    }

    .tc-root[data-open="true"] .tc-launcher {
        transform: translateY(-2px);
    }

    .tc-panel,
    .tc-pos-left .tc-panel {
        position: fixed;
        left: max(8px, env(safe-area-inset-left));
        right: max(8px, env(safe-area-inset-right));
        top: max(8px, env(safe-area-inset-top));
        bottom: calc(78px + env(safe-area-inset-bottom));
        width: auto;
        height: auto;
        max-height: none;
        border-radius: 24px;
        transform-origin: bottom center;
    }

    .tc-header {
        padding: 14px 14px;
        min-height: 68px;
    }

    .tc-brand strong {
        max-width: calc(100vw - 150px);
    }

    .tc-body {
        min-height: 0;
    }

    .tc-messages {
        padding: 16px 12px 10px;
    }

    .tc-bubble {
        max-width: 88%;
        font-size: 14px;
    }

    .tc-profile {
        margin: 0 10px 10px;
        padding: 11px;
        border-radius: 18px;
    }

    .tc-profile-grid {
        grid-template-columns: 1fr;
    }

    .tc-profile-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .tc-profile button,
    .tc-offline button,
    .tc-compose button {
        min-height: 44px;
    }

    .tc-footer {
        padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
    }

    .tc-compose textarea {
        min-height: 46px;
        font-size: 16px;
    }

    .tc-compose button {
        width: 46px;
        height: 46px;
    }

    .tc-quick-links {
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 2px;
        scrollbar-width: none;
    }

    .tc-quick-links::-webkit-scrollbar {
        display: none;
    }

    .tc-quick-links a {
        flex: 0 0 auto;
        min-height: 34px;
    }
}

/* v1.0.4 — pre-chat intake step */
.tc-root[data-profile-step="true"] .tc-compose {
    display: none !important;
}
.tc-root[data-profile-step="true"] .tc-messages {
    flex: 0 0 auto;
    max-height: 150px;
}
.tc-profile {
    position: relative;
}
.tc-profile::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 4px;
    border-radius: 16px 16px 0 0;
    background: linear-gradient(90deg, var(--tc-primary), color-mix(in srgb, var(--tc-primary) 38%, #fff));
}
.tc-profile-head {
    display: grid;
    gap: 5px;
    padding-top: 2px;
}
.tc-profile-kicker {
    width: fit-content;
    padding: 4px 8px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--tc-primary) 10%, #fff);
    color: var(--tc-primary);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: .02em;
    text-transform: uppercase;
}
.tc-profile-head strong {
    display: block;
    font-size: 15px;
    line-height: 1.3;
    color: var(--tc-text);
}
.tc-profile-head p {
    margin: 0;
    font-size: 13px;
    line-height: 1.45;
    color: var(--tc-muted);
}
.tc-profile label {
    display: grid;
    gap: 5px;
    margin: 0;
}
.tc-profile label span {
    font-size: 12px;
    font-weight: 800;
    color: #374151;
}
.tc-profile-save {
    box-shadow: 0 10px 20px color-mix(in srgb, var(--tc-primary) 24%, transparent);
}

@media (max-width: 640px) {
    .tc-root[data-profile-step="true"] .tc-messages {
        max-height: 120px;
    }

    .tc-profile-head strong {
        font-size: 15px;
    }

    .tc-profile-head p {
        font-size: 12.5px;
    }
}

/* v1.2.8 — Smart Start Flow rebuilt safely from v1.2.5 */
.tc-smart-teaser[hidden],
.tc-smart-start[hidden],
.tc-smart-chat-now[hidden] {
    display: none !important;
}

.tc-smart-teaser {
    position: absolute;
    right: 0;
    bottom: 76px;
    width: min(320px, calc(100vw - 32px));
    padding: 14px;
    border: 1px solid var(--tc-border);
    border-radius: 20px;
    background: var(--tc-surface);
    box-shadow: 0 22px 60px rgba(15, 23, 42, .18);
    display: grid;
    gap: 10px;
    animation: tcTeaserIn .22s ease both;
}

.tc-pos-left .tc-smart-teaser {
    left: 0;
    right: auto;
}

.tc-root[data-open="true"] .tc-smart-teaser {
    display: none !important;
}

.tc-smart-teaser-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border: 0 !important;
    border-radius: 999px;
    background: rgba(15, 23, 42, .06) !important;
    color: var(--tc-muted) !important;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    display: grid;
    place-items: center;
    padding: 0 !important;
}

.tc-smart-teaser strong {
    display: block;
    padding-right: 30px;
    font-size: 14px;
    line-height: 1.35;
    color: var(--tc-text);
}

.tc-smart-teaser-options,
.tc-smart-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tc-smart-teaser-options button,
.tc-smart-options button {
    min-height: 34px;
    border: 1px solid color-mix(in srgb, var(--tc-primary) 28%, var(--tc-border)) !important;
    border-radius: 999px;
    background: #fff !important;
    color: var(--tc-primary) !important;
    padding: 7px 12px !important;
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
    transition: transform .16s ease, border-color .16s ease, background .16s ease, color .16s ease;
}

.tc-smart-teaser-options button:hover,
.tc-smart-options button:hover,
.tc-smart-teaser-options button.is-suggested,
.tc-smart-options button.is-suggested {
    background: var(--tc-primary) !important;
    border-color: var(--tc-primary) !important;
    color: #fff !important;
    transform: translateY(-1px);
}

.tc-smart-start {
    margin: 0 12px 12px;
    padding: 14px;
    border: 1px solid color-mix(in srgb, var(--tc-primary) 18%, var(--tc-border));
    border-radius: 18px;
    background: linear-gradient(180deg, #fff, color-mix(in srgb, var(--tc-primary) 5%, #fff));
    box-shadow: 0 12px 30px rgba(15, 23, 42, .06);
    display: grid;
    gap: 10px;
}

.tc-smart-start > span {
    width: fit-content;
    padding: 4px 9px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--tc-primary) 10%, #fff);
    color: var(--tc-primary);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: .02em;
    text-transform: uppercase;
}

.tc-smart-start strong {
    display: block;
    font-size: 15px;
    line-height: 1.35;
    color: var(--tc-text);
}

.tc-smart-chat-now {
    width: 100%;
    min-height: 40px;
    border: 1px dashed color-mix(in srgb, var(--tc-primary) 42%, var(--tc-border)) !important;
    border-radius: 14px;
    background: #fff !important;
    color: var(--tc-primary) !important;
    font-weight: 900;
    cursor: pointer;
    padding: 9px 12px !important;
}

.tc-root[data-smart-step="true"] .tc-compose {
    display: none !important;
}

.tc-root[data-smart-step="true"] .tc-messages {
    flex: 0 0 auto;
    max-height: 150px;
}

@keyframes tcTeaserIn {
    from { opacity: 0; transform: translateY(8px) scale(.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 640px) {
    .tc-smart-teaser {
        right: 0;
        bottom: 72px;
        width: min(320px, calc(100vw - 24px));
        padding: 12px;
    }

    .tc-pos-left .tc-smart-teaser {
        left: 0;
    }

    .tc-smart-start {
        margin: 0 10px 10px;
        padding: 12px;
        border-radius: 16px;
    }

    .tc-smart-options button,
    .tc-smart-teaser-options button {
        min-height: 33px;
        font-size: 12.5px;
        padding: 7px 10px !important;
    }

    .tc-root[data-smart-step="true"] .tc-messages {
        max-height: 115px;
    }
}
