.livechat-widget {
    position: fixed;
    bottom: 100px;
    right: 20px;
    z-index: 9999;
    font-family: 'Nunito Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Toggle Button */
.livechat-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #076490 0%, #0a7db5 100%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(7, 100, 144, 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    padding: 2px;
}

.livechat-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(7, 100, 144, 0.5);
}

.livechat-toggle i {
    font-size: 24px;
    color: #ffffff;
    transition: transform 0.3s ease;
}

.livechat-toggle.open i {
    transform: rotate(180deg);
}

/* Notification Badge */
.livechat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 20px;
    height: 20px;
    background: #dc2626;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: #ffffff;
    border: 2px solid #ffffff;
    animation: pulse-badge 2s infinite;
}

@keyframes pulse-badge {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Chat Window */
.livechat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 48px);
    height: 520px;
    max-height: calc(100vh - 140px);
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 10px 50px rgba(5, 24, 41, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.livechat-window.closed {
    opacity: 0;
    visibility: hidden;
    transform: scale(0.9) translateY(20px);
    pointer-events: none;
}

.livechat-window.open {
    opacity: 1;
    visibility: visible;
    transform: scale(1) translateY(0);
}

/* Chat Header */
.livechat-header {
    background: linear-gradient(135deg, #000000 0%, #191919 100%);
    padding: 20px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
}

.livechat-header-avatar {
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.livechat-header-avatar i {
    font-size: 22px;
    color: #ffffff;
}

.livechat-header-info {
    flex: 1;
}

.livechat-header-title {
    font-size: 16px;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 2px;
}

.livechat-header-status {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    gap: 6px;
}

.livechat-header-status::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    display: inline-block;
}

.livechat-header-status.notOnline::before {
    background: #cccccc;
}

.livechat-close {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.livechat-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.livechat-close i {
    font-size: 14px;
    color: #ffffff;
}

/* Messages Container */
.livechat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: #0000000a;
}

.livechat-messages::-webkit-scrollbar {
    width: 6px;
}

.livechat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.livechat-messages::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

/* Welcome Message */
.livechat-welcome {
    text-align: center;
    padding: 20px;
    text-wrap: balance;
}

.livechat-welcome-icon {
    width: 64px;
    height: 64px;
    background: var(--mediactive-gradient-fallback) !important;
    background: var(--mediactive-gradient) !important;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}

.livechat-welcome-icon i {
    font-size: 28px;
    color: #ffffff;
}

.livechat-welcome h3 {
    font-size: 18px;
    font-weight: 700;
    color: #051829;
    margin-bottom: 8px;
}

.livechat-welcome p {
    font-size: 14px;
    color: #3a4a5a;
    line-height: 1.5;
}

/* Message Bubbles */
.livechat-message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: messageIn 0.3s ease;
}

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

.livechat-message.visitor {
    align-self: flex-end;
}

.livechat-message.admin {
    align-self: flex-start;
}

.livechat-message-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.livechat-message.visitor .livechat-message-bubble {
    background: linear-gradient(135deg, #000000 0%, #191919 100%);
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.livechat-message.admin .livechat-message-bubble {
    background: #ffffff;
    color: #051829;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(5, 24, 41, 0.06);
}

.livechat-message-time {
    font-size: 11px;
    color: #9ca3af;
    margin-top: 4px;
    padding: 0 4px;
}

.livechat-message.visitor .livechat-message-time {
    text-align: right;
}

/* ========================================================================
   TYPING INDICATOR STYLES (NEW)
   ======================================================================== */

.livechat-typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    align-self: flex-start;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.livechat-typing-indicator-bubble {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: #ffffff;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(5, 24, 41, 0.06);
}

.livechat-typing-indicator-dot {
    width: 8px;
    height: 8px;
    background: #9ca3af;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.livechat-typing-indicator-dot:nth-child(1) { animation-delay: 0s; }
.livechat-typing-indicator-dot:nth-child(2) { animation-delay: 0.2s; }
.livechat-typing-indicator-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 60%, 100% {
        transform: translateY(0);
        background: #9ca3af;
    }
    30% {
        transform: translateY(-8px);
        background: #64bc45;
    }
}

.livechat-typing-indicator-text {
    font-size: 12px;
    color: #9ca3af;
    margin-left: 4px;
}

/* Input Area */
.livechat-input {
    padding: 16px 20px;
    background: #ffffff;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-shrink: 0;
}

.livechat-input-field {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 24px;
    font-family: inherit;
    font-size: 16px !important;
    resize: none;
    outline: none;
    transition: border-color 0.2s;
    max-height: 100px;
    line-height: 1.4;
    -webkit-appearance: none;
    appearance: none;
    touch-action: manipulation;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    overflow: hidden;
    color: #000;
}

.livechat-input-field:focus {
    border-color: #64bc45;
}

.livechat-input-field::placeholder {
    color: #9ca3af;
}

.livechat-send {
    width: 44px;
    height: 44px;
    background: var(--mediactive-gradient) !important;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.livechat-send:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(7, 100, 144, 0.4);
}

.livechat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.livechat-send i {
    font-size: 16px;
    color: #ffffff;
}

/* ========================================================================
       ERROR MESSAGE STYLES
       ======================================================================== */

.livechat-error {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 10px;
    margin: 8px;
    animation: errorSlide 0.3s ease;
}

@keyframes errorSlide {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.livechat-error-icon {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    color: #dc2626;
}

.livechat-error-text {
    font-size: 13px;
    color: #dc2626;
    line-height: 1.4;
}

button.livechat-error-close {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    background: none!important;
    border: none;
    padding: 0;
    cursor: pointer;
    color: #dc2626;
    opacity: 0.6;
    transition: opacity 0.2s;
}

button.livechat-error-close:hover {
    opacity: 1;
    background: none!important;
}
.livechat-char-count {
    font-size: 11px;
    color: #9ca3af;
    text-align: right;
    padding: 4px 20px 0;
}

.livechat-char-count.warning {
    color: #f59e0b;
}

.livechat-char-count.error {
    color: #dc2626;
}

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

    .livechat-window {
        width: calc(100vw - 32px);
        height: calc(100vh - 220px);
        max-height: none;
        bottom: 76px;
        right: -8px;
        border-radius: 16px;
    }

    .livechat-toggle {
        width: 56px;
        height: 56px;
    }

    .livechat-toggle i {
        font-size: 22px;
    }
}