.itac-live-chat-tab {
    position: fixed;
    top: var(--itac-tab-top);
    bottom: var(--itac-tab-bottom);
    left: var(--itac-tab-left);
    right: var(--itac-tab-right);
    z-index: 99999;
    background: var(--itac-tab-bg);
    color: var(--itac-tab-text);
    padding: 18px 10px;
    border-radius: 12px 12px 0 0;
    cursor: pointer;
    writing-mode: vertical-rl;
    transform: var(--itac-tab-transform);
    font-weight: 700;
    font-size: 15px;
    letter-spacing: 1px;
    box-shadow: 0 8px 24px var(--itac-shadow);
    transition: all .25s ease;
    font-family: Arial, sans-serif;
}

.itac-live-chat-tab:hover {
    filter: brightness(1.08);
    padding-top: 24px;
    padding-bottom: 24px;
}

.itac-live-chat-tab.has-notification::after {
    content: '';
    position: absolute;
    top: 10px;
    left: 50%;
    width: 10px;
    height: 10px;
    background: #ef4444;
    border-radius: 999px;
    transform: translateX(-50%);
}

.itac-live-chat-box {
    position: fixed;
    top: 50%;
    right: 70px;
    transform: translateY(-50%);
    width: min(380px, calc(100vw - 32px));
    max-width: calc(100vw - 32px);
    background: var(--itac-window-bg);
    border: 1px solid var(--itac-border);
    border-radius: 18px;
    box-shadow: 0 20px 50px var(--itac-shadow);
    overflow: hidden;
    z-index: 100000;
    font-family: Arial, sans-serif;
}

.itac-live-chat-box.itac-left {
    left: 70px;
    right: auto;
}

.itac-live-chat-header {
    background: var(--itac-header-bg);
    color: var(--itac-header-text);
    padding: 16px;
    font-size: 18px;
    font-weight: 700;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.itac-live-chat-close {
    background: transparent;
    color: var(--itac-header-text);
    border: 0;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
}

.itac-live-chat-body {
    padding: 16px;
    color: var(--itac-body-text);
    box-sizing: border-box;
}

.itac-live-chat-body *,
.itac-live-chat-body *::before,
.itac-live-chat-body *::after {
    box-sizing: border-box;
}

.itac-live-chat-status,
.itac-chat-session-info {
    font-size: 12px;
    margin-bottom: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    background: var(--itac-success-bg);
    color: var(--itac-success-text);
}

.itac-chat-hidden {
    display: none !important;
}

.itac-live-chat-history {
    height: 240px;
    overflow-y: auto;
    border: 1px solid var(--itac-border);
    border-radius: 14px;
    padding: 12px;
    margin-bottom: 12px;
    background: rgba(255,255,255,.35);
}

.itac-live-chat-message {
    margin-bottom: 12px;
    display: flex;
}

.itac-live-chat-message.visitor {
    justify-content: flex-end;
}

.itac-live-chat-message.admin {
    justify-content: flex-start;
}

.itac-live-chat-bubble {
    max-width: 82%;
    padding: 10px 12px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.itac-live-chat-message.visitor .itac-live-chat-bubble {
    background: var(--itac-button-bg);
    color: var(--itac-button-text);
    border-bottom-right-radius: 4px;
}

.itac-live-chat-message.admin .itac-live-chat-bubble,
.itac-live-chat-message.admin.is-system .itac-live-chat-bubble {
    background: var(--itac-input-bg);
    color: var(--itac-body-text);
    border: 1px solid var(--itac-border);
    border-bottom-left-radius: 4px;
}

.itac-live-chat-meta {
    font-size: 11px;
    opacity: .7;
    margin-top: 4px;
}

.itac-live-chat-typing {
    min-height: 20px;
    font-size: 12px;
    color: var(--itac-success-text);
    opacity: 0;
    transition: opacity .2s ease;
    margin-bottom: 8px;
}

.itac-live-chat-typing.is-visible {
    opacity: 1;
}

.itac-live-chat-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.itac-quick-reply,
.itac-start-chat,
.itac-download-chatlog,
.itac-attach-button,
.itac-submit {
    border-radius: 10px;
}

.itac-quick-reply,
.itac-download-chatlog,
.itac-attach-button {
    border: 1px solid var(--itac-border);
    background: #fff;
    color: var(--itac-body-text);
    padding: 9px 12px;
    cursor: pointer;
    font-size: 13px;
}

.itac-chat-prechat,
.itac-chat-main {
    width: 100%;
}

.itac-chat-main,
.itac-chat-composer {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.itac-chat-main {
    flex: 1 1 auto;
}

.itac-live-chat-form-fields,
.itac-prechat-fields {
    display: grid;
    gap: 10px;
    width: 100%;
    margin-bottom: 12px;
}

.itac-live-chat-body input,
.itac-live-chat-body textarea,
.itac-start-chat,
.itac-submit {
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.itac-live-chat-body input,
.itac-live-chat-body textarea {
    padding: 10px 12px;
    border: 1px solid var(--itac-border);
    border-radius: 10px;
    background: var(--itac-input-bg);
    color: var(--itac-input-text);
}

.itac-live-chat-body input::placeholder,
.itac-live-chat-body textarea::placeholder {
    color: var(--itac-input-text);
    opacity: .7;
}

.itac-live-chat-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin: 10px 0 12px;
}

.itac-selected-file {
    font-size: 12px;
    color: var(--itac-body-text);
    width: 100%;
    word-break: break-word;
}

.itac-start-chat,
.itac-submit {
    background: var(--itac-button-bg);
    color: var(--itac-button-text);
    border: 0;
    padding: 12px 16px;
    cursor: pointer;
    font-weight: 700;
    transition: background .25s ease;
}

.itac-start-chat:hover,
.itac-submit:hover {
    background: var(--itac-button-hover);
}


.itac-prechat-response {
    min-height: 20px;
    margin: 0 0 10px;
    font-size: 13px;
}
.itac-prechat-response.error {
    color: #b91c1c;
}

.itac-live-chat-response {
    margin-top: 12px;
    font-size: 14px;
}

.itac-live-chat-response.error {
    color: #b91c1c;
}

.itac-live-chat-attachment {
    margin-top: 8px;
    font-size: 13px;
}

.itac-live-chat-attachment a {
    color: inherit;
}

.itac-live-chat-footer-brand {
    margin-top: 14px;
    padding-top: 10px;
    border-top: 1px solid var(--itac-border);
    text-align: center;
    font-size: 11px;
    opacity: .75;
}

@media (max-width: 1024px) {
    .itac-live-chat-box,
    .itac-live-chat-box.itac-left {
        left: 12px;
        right: 12px;
        top: auto;
        bottom: 12px;
        transform: none;
        width: auto;
        max-width: none;
        border-radius: 16px;
        height: min(82vh, 720px);
        max-height: min(82vh, 720px);
        display: flex;
        flex-direction: column;
    }

    .itac-live-chat-header {
        padding: 12px 14px;
        font-size: 17px;
    }

    .itac-live-chat-body {
        padding: 12px;
        display: flex;
        flex-direction: column;
        flex: 1 1 auto;
        min-height: 0;
        overflow: hidden;
        gap: 0;
    }

    .itac-live-chat-status,
    .itac-chat-session-info {
        margin-bottom: 8px;
        padding: 8px 10px;
        font-size: 12px;
    }

    .itac-live-chat-body p {
        margin-top: 0;
        margin-bottom: 8px;
        font-size: 14px;
    }

    .itac-live-chat-history {
        flex: 1 1 auto;
        height: auto;
        min-height: 120px;
        max-height: none;
        padding: 10px;
        margin-bottom: 8px;
    }

    .itac-live-chat-bubble {
        max-width: 90%;
        font-size: 13px;
        padding: 9px 10px;
    }

    .itac-live-chat-form-fields,
    .itac-prechat-fields {
        gap: 8px;
        margin-bottom: 8px;
    }

    .itac-live-chat-body input,
    .itac-live-chat-body textarea {
        padding: 9px 10px;
        font-size: 14px;
    }

    .itac-live-chat-body textarea {
        min-height: 72px;
        max-height: 96px;
    }

    .itac-live-chat-tools {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        gap: 8px;
        align-items: stretch;
        margin: 8px 0 10px;
    }

    .itac-live-chat-tools > .itac-attach-button {
        order: 1;
    }

    .itac-live-chat-tools > .itac-download-chatlog {
        order: 2;
    }

    .itac-live-chat-tools > .itac-attach-button,
    .itac-live-chat-tools > .itac-download-chatlog {
        width: 100%;
        min-width: 0;
        text-align: center;
        padding: 9px 8px;
        font-size: 12px;
    }

    .itac-live-chat-tools > .itac-selected-file {
        order: 3;
        grid-column: 1 / -1;
        font-size: 11px;
    }

    .itac-quick-reply,
    .itac-start-chat,
    .itac-submit {
        width: 100%;
        text-align: center;
    }

    .itac-submit {
        padding: 11px 14px;
        margin-top: 0;
        flex-shrink: 0;
    }

    .itac-live-chat-response,
    .itac-prechat-response,
    .itac-live-chat-footer-brand {
        font-size: 11px;
    }

    .itac-live-chat-footer-brand {
        margin-top: 8px;
        padding-top: 8px;
        flex-shrink: 0;
    }
}

@media (max-width: 767px) {
    .itac-live-chat-tab {
        font-size: 13px;
        padding: 14px 8px;
    }

    .itac-live-chat-box,
    .itac-live-chat-box.itac-left {
        left: 10px;
        right: 10px;
        bottom: 10px;
        height: min(78vh, 620px);
        max-height: min(78vh, 620px);
    }

    .itac-live-chat-header {
        padding: 10px 12px;
        font-size: 16px;
    }

    .itac-live-chat-body {
        padding: 10px;
    }

    .itac-live-chat-history {
        min-height: 110px;
        max-height: none;
        padding: 8px;
    }

    .itac-live-chat-body p {
        font-size: 13px;
    }

    .itac-live-chat-body textarea {
        min-height: 64px;
        max-height: 84px;
    }
}
