/* ========== Robot Icon ========== */
#livechat-robot-icon {
    position: fixed;
    bottom: 24px;
    width: 120px;
    height: 75px;
    overflow: hidden;
    cursor: pointer;
    z-index: 999998;
    transition: transform 0.2s, box-shadow 0.2s;
}
#livechat-robot-icon:hover {
    transform: scale(1.08);
}
#livechat-robot-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* ========== Popup ========== */
#livechat-popup {
    position: fixed;
    bottom: 96px;
    width: 310px;
    max-width: calc(100vw - 32px);
    background: #FFFFFF;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
    z-index: 999999;
    display: none;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, sans-serif;
}
#livechat-popup.open {
    display: block;
    animation: livechatFadeIn 0.25s ease;
}
@keyframes livechatFadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ========== Header ========== */
#livechat-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 16px;
    background: linear-gradient(135deg, #14293A, #003662);
    color: #fff;
    border-radius: 12px 12px 0 0;
}
#livechat-avatar {
    width: 36px;
    height: 36px;
    overflow: hidden;
    flex-shrink: 0;
}
#livechat-avatar img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}
#livechat-header-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}
#livechat-title {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
#livechat-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 2px 6px;
    opacity: 0.7;
    transition: opacity 0.2s;
    flex-shrink: 0;
}
#livechat-close:hover {
    opacity: 1;
}

/* ========== Body / Form ========== */
#livechat-body {
    padding: 16px;
}
#livechat-greeting {
    font-size: 12px;
    color: #64748B;
    font-weight: 600;
    font-style: italic;
    line-height: 1.5;
    margin: 0 0 12px 0;
}
#livechat-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.livechat-field input,
.livechat-field textarea {
    width: 100%;
    padding: 0 12px;
    height: 40px;
    border: 1px solid #E2E8F0;
    border-radius: 8px;
    background: #F8FAFC;
    font-size: 13px;
    font-family: inherit;
    color: #0F172A;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.2s;
}
.livechat-field textarea {
    height: auto;
    padding: 10px 12px;
    resize: vertical;
    min-height: 80px;
}
.livechat-field input::placeholder,
.livechat-field textarea::placeholder {
    color: #94A3B8;
}
.livechat-field input:focus,
.livechat-field textarea:focus {
    border-color: #1E3A8A;
}

#livechat-submit {
    width: 100%;
    height: 42px;
    border: none;
    border-radius: 8px;
    background: #009B3A;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.2s;
}
#livechat-submit:hover {
    background: #007A2E;
}
#livechat-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

#livechat-success {
    text-align: center;
    padding: 24px 0;
}
#livechat-success p {
    font-size: 14px;
    color: #0F172A;
    font-weight: 500;
}

/* ========== Footer ========== */
#livechat-footer {
    padding: 8px 16px;
    text-align: right;
    font-size: 11px;
    color: #94A3B8;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
#livechat-footer span:last-child {
    font-size: 9px;
    font-style: italic;
    opacity: 0.7;
}

/* ========== Loading Spinner ========== */
.livechat-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: livechatSpin 0.6s linear infinite;
    vertical-align: middle;
}
@keyframes livechatSpin {
    to { transform: rotate(360deg); }
}

/* ========== Responsive ========== */
@media (max-width: 600px) {
    #livechat-popup {
        bottom: 80px;
        max-width: calc(100vw - 24px);
    }
    #livechat-header {
        padding: 12px;
        gap: 6px;
    }
    #livechat-body {
        padding: 12px;
    }
    #livechat-greeting {
        font-size: 11px;
    }
    .livechat-field input,
    .livechat-field textarea {
        height: 36px;
        font-size: 12px;
        padding: 0 10px;
    }
    .livechat-field textarea {
        height: auto;
        min-height: 64px;
        padding: 8px 10px;
    }
    #livechat-submit {
        height: 38px;
        font-size: 13px;
    }
}
