/* Live Chat Widget - self-hosted, site-wide floating chat bubble + window */

.livechat-widget {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 99990;
    font-family: inherit;
}

.livechat-bubble {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: var(--brand-primary, #e6483e);
    border: none;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    transition: transform 0.15s ease;
}

.livechat-bubble:hover {
    transform: scale(1.06);
}

.livechat-bubble-icon {
    width: 34px;
    height: 30px;
}

.livechat-unread-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ffb400;
    color: #222;
    font-size: 11px;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
}

/* same equal-specificity vs .hidden issue as #livechat-window above */
#livechat-unread-badge.hidden {
    display: none;
}

.livechat-window {
    position: absolute;
    right: 0;
    bottom: 72px;
    width: 340px;
    max-width: calc(100vw - 40px);
    height: 480px;
    max-height: calc(100vh - 120px);
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* .hidden (global utility, plain .display:none with no !important) and
   .livechat-window (.display:flex) have equal specificity, so whichever
   stylesheet loads later would otherwise win regardless of which class was
   added last - this compound selector outranks both so the widget actually
   hides when .hidden is toggled back on */
#livechat-window.hidden {
    display: none;
}

.livechat-header {
    background: var(--brand-dark, #1c1c1c);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.livechat-status {
    font-size: 12px;
    opacity: 0.85;
    margin-top: 4px;
}

.livechat-status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 5px;
}

.livechat-status-dot.online {
    background: #2ecc71;
}

.livechat-status-dot.offline {
    background: #95a5a6;
}

.livechat-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    opacity: 0.8;
}

.livechat-close:hover {
    opacity: 1;
}

.livechat-body {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
}

.livechat-body .form-group {
    margin-bottom: 12px;
}

.livechat-body label {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 4px;
    display: block;
}

.livechat-error {
    color: #e6483e;
    font-size: 12px;
    margin-bottom: 10px;
}

.livechat-messages {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.livechat-msg {
    max-width: 80%;
    padding: 8px 12px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.4;
    word-wrap: break-word;
}

.livechat-msg-visitor {
    align-self: flex-end;
    background: var(--brand-primary, #e6483e);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.livechat-msg-agent {
    align-self: flex-start;
    background: #f1f1f3;
    color: #222;
    border-bottom-left-radius: 4px;
}

.livechat-typing {
    font-size: 12px;
    color: #999;
    font-style: italic;
    padding: 4px 0;
}

.livechat-composer {
    display: flex;
    gap: 8px;
    padding: 10px;
    border-top: 1px solid #eee;
}

/* same equal-specificity vs .hidden issue as #livechat-window above */
#livechat-composer.hidden {
    display: none;
}

.livechat-composer input {
    flex: 1;
}

@media (max-width: 480px) {
    .livechat-window {
        right: -10px;
        width: calc(100vw - 20px);
    }

    .livechat-widget {
        right: 12px;
        bottom: 12px;
    }
}
