#livechat-widget {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: #333;
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
}

#livechat-widget * {
    box-sizing: border-box;
}

/* Floating button */
#livechat-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #045026 0%, #49ac33 100%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(4, 80, 38, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    padding: 0;
    margin: 0;
}

#livechat-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(4, 80, 38, 0.5);
}

#livechat-btn svg {
    fill: white;
    width: 28px;
    height: 28px;
}

#livechat-btn .livechat-unread {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #dc3545;
    color: white;
    font-size: 11px;
    font-weight: 700;
    min-width: 22px;
    height: 22px;
    border-radius: 11px;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    line-height: 22px;
}

/* Chat panel */
#livechat-panel {
    display: none;
    width: 420px;
    height: 600px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0,0,0,0.2);
    overflow: hidden;
    position: absolute;
    bottom: 74px;
    right: 0;
    flex-direction: column;
}

#livechat-panel.open {
    display: flex;
}

/* Header */
#livechat-header {
    background: linear-gradient(135deg, #045026 0%, #49ac33 100%);
    color: white;
    padding: 20px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

#livechat-header h4 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    padding: 0;
    color: white;
}

#livechat-header p {
    font-size: 13px;
    opacity: 0.85;
    margin: 4px 0 0 0;
    padding: 0;
}

#livechat-close {
    background: rgba(255,255,255,0.15);
    border: none;
    color: white;
    cursor: pointer;
    font-size: 22px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    transition: background 0.2s;
}

#livechat-close:hover {
    background: rgba(255,255,255,0.25);
}

/* Pre-chat form */
#livechat-prechat {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

#livechat-prechat .livechat-field {
    margin-bottom: 16px;
}

#livechat-prechat label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #333;
    margin-bottom: 6px;
}

#livechat-prechat input,
#livechat-prechat textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid #ddd;
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    color: #333;
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}

#livechat-prechat input:focus,
#livechat-prechat textarea:focus {
    border-color: #49ac33;
    box-shadow: 0 0 0 3px rgba(73, 172, 51, 0.12);
}

#livechat-prechat input::placeholder,
#livechat-prechat textarea::placeholder {
    color: #aaa;
}

#livechat-prechat textarea {
    resize: none;
    height: 90px;
}

#livechat-start-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #045026 0%, #49ac33 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
    margin-top: 4px;
}

#livechat-start-btn:hover {
    opacity: 0.92;
}

#livechat-start-btn:active {
    transform: scale(0.98);
}

#livechat-start-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Messages area */
#livechat-messages {
    display: none;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

#livechat-messages.active {
    display: flex;
}

#livechat-messages-list {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f5f6f8;
}

.livechat-msg {
    max-width: 80%;
    margin-bottom: 14px;
    padding: 12px 16px;
    border-radius: 16px;
    word-wrap: break-word;
    white-space: pre-wrap;
    animation: livechatFadeIn 0.25s ease;
}

@keyframes livechatFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.livechat-msg.visitor {
    background: #e3f2fd;
    color: #1a1a1a;
    margin-right: auto;
    border-bottom-left-radius: 4px;
}

.livechat-msg.agent {
    background: linear-gradient(135deg, #045026 0%, #49ac33 100%);
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 4px;
}

.livechat-msg-content {
    font-size: 14px;
    line-height: 1.5;
}

.livechat-msg-meta {
    font-size: 11px;
    opacity: 0.55;
    margin-top: 6px;
}

.livechat-msg.agent .livechat-msg-meta {
    text-align: right;
}

/* Resolved banner (hidden, auto-resets to new chat) */
#livechat-resolved {
    display: none;
}

/* Reply box */
#livechat-reply {
    display: flex;
    padding: 14px 16px;
    border-top: 1px solid #eee;
    gap: 10px;
    background: #fff;
    flex-shrink: 0;
    align-items: flex-end;
}

#livechat-reply textarea {
    flex: 1;
    padding: 10px 14px;
    border: 1.5px solid #ddd;
    border-radius: 12px;
    font-size: 14px;
    font-family: inherit;
    color: #333;
    resize: none;
    height: 42px;
    max-height: 100px;
    outline: none;
    transition: border-color 0.2s;
    background: #fff;
}

#livechat-reply textarea:focus {
    border-color: #49ac33;
}

#livechat-reply textarea::placeholder {
    color: #aaa;
}

#livechat-send-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #045026 0%, #49ac33 100%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 0;
    transition: opacity 0.2s;
}

#livechat-send-btn:hover {
    opacity: 0.85;
}

#livechat-send-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

#livechat-send-btn svg {
    fill: white;
    width: 18px;
    height: 18px;
}

/* Powered by */
#livechat-powered {
    text-align: center;
    padding: 8px;
    font-size: 11px;
    color: #bbb;
    background: #fff;
    flex-shrink: 0;
}

/* Mobile responsive */
@media (max-width: 480px) {
    #livechat-widget {
        bottom: 16px;
        right: 16px;
    }

    #livechat-panel {
        width: calc(100vw - 32px);
        height: calc(100vh - 100px);
        right: -8px;
        bottom: 72px;
        border-radius: 14px;
    }
}
