.livechat-root {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    z-index: 9999;
    font-family: var(--font-body, 'Plus Jakarta Sans', sans-serif);
}

.livechat-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    border: none;
    border-radius: 999px;
    padding: 0.85rem 1.1rem;
    background: var(--color-magenta, #93165A);
    color: #fff;
    box-shadow: 0 10px 30px rgba(147, 22, 90, 0.35);
    cursor: pointer;
    font-weight: 600;
    position: relative;
}

.livechat-toggle-icon { font-size: 1.15rem; line-height: 1; }

.livechat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 1.25rem;
    height: 1.25rem;
    border-radius: 999px;
    background: #ef4444;
    color: #fff;
    font-size: 0.6875rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.25rem;
}

.livechat-panel {
    position: absolute;
    right: 0;
    bottom: calc(100% + 0.75rem);
    width: min(360px, calc(100vw - 2rem));
    height: 460px;
    background: #fff;
    border: 1px solid var(--color-light-gray, #e5e7eb);
    border-radius: 1rem;
    box-shadow: 0 20px 50px rgba(15, 27, 60, 0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.livechat-panel[hidden] { display: none !important; }

.livechat-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.9rem 1rem;
    background: var(--color-navy, #0f1b3c);
    color: #fff;
}

.livechat-header small { display: block; opacity: 0.8; font-size: 0.75rem; margin-top: 0.15rem; }

.livechat-close {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
}

.livechat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    background: #f8fafc;
}

.livechat-welcome { color: #4b5563; font-size: 0.875rem; }

.livechat-msg {
    margin-bottom: 0.75rem;
    max-width: 88%;
    padding: 0.65rem 0.8rem;
    border-radius: 0.75rem;
    font-size: 0.875rem;
    line-height: 1.45;
    white-space: pre-wrap;
}

.livechat-msg time {
    display: block;
    font-size: 0.6875rem;
    opacity: 0.65;
    margin-top: 0.25rem;
}

.livechat-msg-visitor {
    margin-left: auto;
    background: var(--color-magenta, #93165A);
    color: #fff;
    border-bottom-right-radius: 0.2rem;
}

.livechat-msg-admin,
.livechat-msg-system {
    margin-right: auto;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 0.2rem;
}

.livechat-msg-system { font-style: italic; color: #4b5563; }

.livechat-form {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.5rem;
    padding: 0.75rem;
    border-top: 1px solid #e5e7eb;
    background: #fff;
}

.livechat-form textarea {
    resize: none;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    padding: 0.55rem 0.65rem;
    font-family: inherit;
    font-size: 0.875rem;
}

.livechat-form textarea:focus {
    outline: none;
    border-color: var(--color-magenta, #93165A);
}

.livechat-end-btn {
    background: rgba(255,255,255,.15);
    border: 1px solid rgba(255,255,255,.35);
    color: #fff;
    border-radius: .375rem;
    padding: .2rem .55rem;
    font-size: .75rem;
    cursor: pointer;
}

.livechat-end-btn:hover { background: rgba(255,255,255,.25); }

.livechat-transcript-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(0,0,0,.45);
}

.livechat-transcript-overlay[hidden] { display: none !important; }

.livechat-transcript-modal {
    width: min(24rem, 100%);
    background: #fff;
    border-radius: .75rem;
    padding: 1.25rem;
    box-shadow: 0 20px 50px rgba(0,0,0,.2);
}

.livechat-transcript-modal h3 { margin: 0 0 .35rem; font-size: 1.05rem; color: #111827; }
.livechat-transcript-modal p { margin: 0 0 1rem; font-size: .875rem; color: #6b7280; }
.livechat-transcript-error { color: #b91c1c !important; font-weight: 600; }
.livechat-transcript-modal .form-group { margin-bottom: .75rem; }
.livechat-transcript-modal label { display: block; font-size: .8125rem; font-weight: 600; margin-bottom: .25rem; color: #374151; }
.livechat-transcript-modal .form-control {
    width: 100%; box-sizing: border-box; padding: .55rem .65rem;
    border: 1px solid #d1d5db; border-radius: .375rem; font-size: .875rem;
}
.livechat-transcript-actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1rem; }

@media (max-width: 480px) {
    .livechat-root { right: 0.75rem; bottom: 0.75rem; }
    .livechat-toggle-label { display: none; }
    .livechat-panel {
        width: calc(100vw - 1.5rem);
        height: min(70vh, 480px);
    }
}
