/* ==================== LIVE CHAT WIDGET ==================== */

/* ---------- Floating Chat Button ---------- */
#livechat-btn {
    position: fixed;
    bottom: 96px;
    left: 28px;
    z-index: 100008;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background:
        radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.34), transparent 26%),
        linear-gradient(135deg, #00d1b2 0%, #0077ff 58%, #10284f 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 12px 30px rgba(0, 119, 255, 0.34), 0 2px 8px rgba(0, 0, 0, 0.24);
    cursor: pointer;
    border: none;
    transition: transform 0.3s cubic-bezier(.34, 1.56, .64, 1), box-shadow 0.3s ease;
    animation: chatBtnEntry 0.6s cubic-bezier(.34, 1.56, .64, 1) both 1.4s;
}

#livechat-btn::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    background: rgba(0, 209, 178, 0.2);
    animation: chatPulse 3s ease-in-out infinite;
    z-index: -1;
}

#livechat-btn:hover {
    transform: scale(1.12);
    box-shadow: 0 16px 36px rgba(0, 119, 255, 0.44), 0 3px 12px rgba(0, 0, 0, 0.25);
}

#livechat-btn svg {
    width: 26px;
    height: 26px;
    fill: #fff;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.15));
}

#livechat-btn .chat-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ff4757;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #0a0f1c;
    display: none;
}

#livechat-btn .chat-badge.visible {
    display: flex;
    animation: badgePop 0.4s cubic-bezier(.34, 1.56, .64, 1);
}

/* ---------- Chat Window ---------- */
#livechat-window {
    position: fixed;
    bottom: 152px;
    left: 28px;
    width: min(440px, calc(100vw - 36px));
    height: min(640px, calc(100vh - 185px));
    min-height: 540px;
    z-index: 100010;
    border-radius: 24px;
    background:
        radial-gradient(circle at 15% 0%, rgba(0, 209, 178, 0.16), transparent 32%),
        radial-gradient(circle at 95% 12%, rgba(0, 119, 255, 0.18), transparent 30%),
        rgba(8, 13, 25, 0.97);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(0, 209, 178, 0.18);
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5), 0 0 34px rgba(0, 119, 255, 0.12);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(.34, 1.56, .64, 1);
}

#livechat-window.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* ---------- Chat Header ---------- */
.livechat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 18px 15px;
    background:
        linear-gradient(135deg, rgba(0, 209, 178, 0.16), rgba(0, 119, 255, 0.12)),
        rgba(255, 255, 255, 0.025);
    border-bottom: 1px solid rgba(0, 209, 178, 0.12);
    flex-shrink: 0;
}

.livechat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.livechat-header-avatar {
    width: 44px;
    height: 44px;
    border-radius: 16px;
    background: linear-gradient(135deg, #00d1b2, #0077ff);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    box-shadow: 0 10px 24px rgba(0, 119, 255, 0.22);
}

.livechat-header-text h4 {
    margin: 0;
    font-size: 1rem;
    color: #fff;
    font-weight: 700;
}

.livechat-header-text span {
    font-size: 0.76rem;
    color: rgba(164, 244, 231, 0.82);
}

.livechat-ai-disclaimer {
    margin: 12px 14px 0;
    padding: 10px 12px;
    border-radius: 18px;
    background: linear-gradient(135deg, rgba(255, 184, 77, 0.14), rgba(0, 209, 178, 0.08));
    border-bottom: 1px solid rgba(255, 184, 77, 0.16);
    color: rgba(255, 255, 255, 0.76);
    font-size: 0.74rem;
    line-height: 1.6;
}

.livechat-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 8px;
    transition: background 0.2s, color 0.2s;
}

.livechat-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

/* ---------- Messages Area ---------- */
.livechat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 18px 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scrollbar-width: none;
}

.livechat-messages::-webkit-scrollbar {
    display: none;
}

/* ---------- Message Bubbles ---------- */
.chat-msg {
    max-width: 86%;
    padding: 12px 15px;
    border-radius: 14px;
    font-size: 0.88rem;
    line-height: 1.65;
    word-wrap: break-word;
    animation: msgSlide 0.3s ease;
}

.chat-msg.user {
    align-self: flex-end;
    background: linear-gradient(135deg, #00c8ff, #0090cc);
    color: #fff;
    border-bottom-left-radius: 18px;
    border-bottom-right-radius: 7px;
}

.chat-msg.admin {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.08);
    color: #e0e0e0;
    border: 1px solid rgba(0, 200, 255, 0.1);
    border-inline-start: 3px solid rgba(0, 209, 178, 0.42);
    border-bottom-right-radius: 18px;
    border-bottom-left-radius: 7px;
}

.chat-msg.bot {
    align-self: flex-start;
    background: linear-gradient(135deg, rgba(255, 184, 77, 0.16), rgba(0, 200, 255, 0.1));
    color: #f5fbff;
    border: 1px solid rgba(255, 184, 77, 0.24);
    border-inline-start: 3px solid rgba(255, 207, 122, 0.5);
    border-bottom-right-radius: 18px;
    border-bottom-left-radius: 7px;
}

.chat-msg .msg-sender-label {
    display: block;
    font-size: 0.66rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    margin-top: 5px;
    color: #ffcf7a;
}

.chat-msg .msg-time {
    display: block;
    font-size: 0.65rem;
    margin-top: 4px;
    opacity: 0.6;
}

.chat-msg-text {
    white-space: pre-wrap;
}

.chat-msg-image-link {
    display: block;
    margin-top: 8px;
}

.chat-msg-image {
    display: block;
    width: 100%;
    max-width: 220px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.04);
}

.livechat-system-note {
    align-self: center;
    max-width: 90%;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(255, 184, 77, 0.12);
    border: 1px solid rgba(255, 184, 77, 0.22);
    color: rgba(255, 255, 255, 0.72);
    font-size: 0.74rem;
    text-align: center;
}

.livechat-typing {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    width: fit-content;
}

.livechat-typing .typing-dot,
.order-chat-typing .typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #ffcf7a;
    animation: chatTypingDot 1s infinite ease-in-out;
}

.livechat-typing .typing-dot:nth-child(2),
.order-chat-typing .typing-dot:nth-child(2) {
    animation-delay: 0.15s;
}

.livechat-typing .typing-dot:nth-child(3),
.order-chat-typing .typing-dot:nth-child(3) {
    animation-delay: 0.3s;
}

.livechat-typing .typing-label,
.order-chat-typing .typing-label {
    margin-inline-start: 4px;
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.64);
}

/* ---------- Welcome Message ---------- */
.livechat-welcome {
    text-align: center;
    padding: 8px 0 18px;
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.8rem;
    line-height: 1.6;
}

.livechat-welcome .welcome-icon {
    font-size: 2.25rem;
    margin-bottom: 8px;
    display: block;
}

.support-desk-welcome {
    display: grid;
    gap: 12px;
}

.support-welcome-card {
    padding: 20px 18px;
    border-radius: 22px;
    background:
        linear-gradient(145deg, rgba(255, 255, 255, 0.075), rgba(255, 255, 255, 0.03)),
        radial-gradient(circle at 50% 0%, rgba(0, 209, 178, 0.18), transparent 48%);
    border: 1px solid rgba(255, 255, 255, 0.09);
}

.support-welcome-card h5 {
    margin: 0 0 0.4rem;
    color: #fff;
    font-size: 1rem;
    font-weight: 800;
}

.support-welcome-card p {
    max-width: 320px;
    margin: 0 auto;
    color: rgba(255, 255, 255, 0.64);
    font-size: 0.82rem;
    line-height: 1.7;
}

.support-quick-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.support-quick-actions button {
    min-height: 40px;
    border-radius: 14px;
    border: 1px solid rgba(0, 209, 178, 0.16);
    background: rgba(255, 255, 255, 0.055);
    color: rgba(255, 255, 255, 0.84);
    cursor: pointer;
    font-family: 'Cairo', sans-serif;
    font-size: 0.78rem;
    font-weight: 800;
    transition: transform 0.18s, border-color 0.18s, background 0.18s;
}

.support-quick-actions button:hover {
    transform: translateY(-1px);
    border-color: rgba(0, 209, 178, 0.34);
    background: rgba(0, 209, 178, 0.09);
}

/* ---------- Input Area ---------- */
.livechat-input {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px;
    border-top: 1px solid rgba(0, 209, 178, 0.1);
    background: rgba(3, 8, 18, 0.72);
    flex-shrink: 0;
}

.livechat-attach {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid rgba(0, 200, 255, 0.18);
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.2s, border-color 0.2s, opacity 0.2s;
}

.livechat-attach svg {
    width: 18px;
    height: 18px;
}

.livechat-attach:hover {
    transform: scale(1.05);
    border-color: rgba(0, 200, 255, 0.45);
}

.livechat-attach:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}

.livechat-input input {
    flex: 1;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(0, 200, 255, 0.15);
    border-radius: 16px;
    padding: 12px 16px;
    color: #fff;
    font-size: 0.85rem;
    font-family: 'Cairo', sans-serif;
    outline: none;
    transition: border-color 0.2s;
}

.livechat-input input::placeholder {
    color: rgba(255, 255, 255, 0.35);
}

.livechat-input input:focus {
    border-color: rgba(0, 200, 255, 0.5);
}

.livechat-send {
    width: 40px;
    height: 40px;
    border-radius: 15px;
    background: linear-gradient(135deg, #00d1b2, #0077ff);
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.2s, opacity 0.2s;
}

.livechat-send:hover {
    transform: scale(1.1);
}

.livechat-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.livechat-send svg {
    width: 18px;
    height: 18px;
    fill: #fff;
    transform: rotate(180deg);
}

/* ---------- Login Prompt ---------- */
.livechat-login-prompt {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 30px;
    text-align: center;
    color: rgba(255, 255, 255, 0.7);
}

.livechat-login-prompt .prompt-icon {
    font-size: 3rem;
}

.livechat-login-prompt p {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.5;
}

.livechat-login-btn {
    padding: 10px 28px;
    border-radius: 10px;
    background: linear-gradient(135deg, #00c8ff, #7b2fff);
    color: #fff;
    border: none;
    cursor: pointer;
    font-family: 'Cairo', sans-serif;
    font-weight: 700;
    font-size: 0.85rem;
    transition: transform 0.2s;
}

.livechat-login-btn:hover {
    transform: translateY(-2px);
}

/* ---------- Closed Banner ---------- */
.livechat-closed {
    padding: 12px 16px;
    background: rgba(255, 71, 87, 0.1);
    border-top: 1px solid rgba(255, 71, 87, 0.2);
    text-align: center;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.78rem;
    flex-shrink: 0;
}

#livechat-window.is-conversation-closed .livechat-input {
    background: rgba(255, 71, 87, 0.08);
}

#livechat-window.is-conversation-closed .livechat-input input {
    color: rgba(255, 255, 255, 0.55);
}

/* ---------- Animations ---------- */
@keyframes chatBtnEntry {
    from {
        opacity: 0;
        transform: scale(0.3) translateY(40px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes chatPulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 0.4;
    }

    50% {
        transform: scale(1.35);
        opacity: 0;
    }
}

@keyframes msgSlide {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes chatTypingDot {
    0%, 80%, 100% {
        transform: translateY(0);
        opacity: 0.35;
    }

    40% {
        transform: translateY(-4px);
        opacity: 1;
    }
}

@keyframes badgePop {
    from {
        transform: scale(0);
    }

    to {
        transform: scale(1);
    }
}

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
    #livechat-btn {
        bottom: 78px;
        left: 18px;
        width: 46px;
        height: 46px;
    }

    #livechat-btn svg {
        width: 22px;
        height: 22px;
    }

    #livechat-window {
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        width: 100%;
        height: min(86dvh, 720px);
        min-height: 0;
        border-radius: 24px 24px 0 0;
    }

    .support-quick-actions {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    #livechat-btn {
        animation: none;
        box-shadow: 0 6px 16px rgba(0, 200, 255, 0.24), 0 2px 8px rgba(0, 0, 0, 0.24);
    }

    #livechat-btn::before {
        display: none;
    }

    #livechat-btn svg {
        filter: none;
    }

    #livechat-window {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        box-shadow: 0 12px 28px rgba(0, 0, 0, 0.36);
        transition: opacity 0.2s ease, transform 0.2s ease;
    }

    .chat-msg,
    #livechat-btn .chat-badge.visible {
        animation: none;
    }

    .livechat-send:hover,
    .livechat-login-btn:hover {
        transform: none;
    }
}

/* ==================== FLOATING ORDER CHAT BADGE ==================== */

#order-chat-float-btn {
    position: fixed;
    bottom: 160px;
    left: 28px;
    z-index: 100007;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ff9f43 0%, #ee5a24 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 18px rgba(255, 159, 67, 0.4), 0 2px 6px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    border: none;
    color: #fff;
    font-size: 1.15rem;
    transition: transform 0.3s cubic-bezier(.34, 1.56, .64, 1), box-shadow 0.3s ease;
    animation: orderChatBadgeEntry 0.5s cubic-bezier(.34, 1.56, .64, 1) both;
}

#order-chat-float-btn::before {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    background: rgba(255, 159, 67, 0.25);
    animation: orderChatPulse 3s ease-in-out infinite;
    z-index: -1;
}

#order-chat-float-btn:hover {
    transform: scale(1.12);
    box-shadow: 0 6px 24px rgba(255, 159, 67, 0.5), 0 3px 10px rgba(0, 0, 0, 0.25);
}

.order-chat-float-count {
    position: absolute;
    top: -3px;
    right: -3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ff4757;
    color: #fff;
    font-size: 0.62rem;
    font-weight: 800;
    display: none;
    align-items: center;
    justify-content: center;
    border: 2px solid #0a0f1c;
}

.order-chat-float-count.visible {
    display: flex;
    animation: badgePop 0.4s cubic-bezier(.34, 1.56, .64, 1);
}

/* ---------- Dropdown ---------- */
.order-chat-float-dropdown {
    position: fixed;
    bottom: 218px;
    left: 28px;
    z-index: 100009;
    width: 280px;
    background: rgba(10, 15, 28, 0.96);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid rgba(255, 159, 67, 0.2);
    border-radius: 14px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45), 0 0 20px rgba(255, 159, 67, 0.08);
    overflow: hidden;
    animation: ocfDropdownSlide 0.25s ease;
}

.ocf-dropdown-title {
    padding: 12px 16px;
    font-size: 0.82rem;
    font-weight: 800;
    color: #ff9f43;
    border-bottom: 1px solid rgba(255, 159, 67, 0.12);
    display: flex;
    align-items: center;
    gap: 8px;
}

.ocf-dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 16px;
    color: #e0e0e0;
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 600;
    transition: background 0.15s;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.ocf-dropdown-item:last-child {
    border-bottom: none;
}

.ocf-dropdown-item:hover {
    background: rgba(255, 159, 67, 0.08);
}

.ocf-item-icon {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: rgba(255, 159, 67, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ff9f43;
    font-size: 0.75rem;
    flex-shrink: 0;
}

.ocf-item-text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ocf-unread {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ff4757;
    color: #fff;
    font-size: 0.62rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

@keyframes orderChatBadgeEntry {
    from {
        opacity: 0;
        transform: scale(0.3) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes orderChatPulse {
    0%, 100% {
        transform: scale(1);
        opacity: 0.35;
    }
    50% {
        transform: scale(1.3);
        opacity: 0;
    }
}

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

@media (max-width: 480px) {
    #order-chat-float-btn {
        bottom: 134px;
        left: 18px;
        width: 42px;
        height: 42px;
        font-size: 1rem;
    }

    .order-chat-float-dropdown {
        bottom: 186px;
        left: 14px;
        right: 14px;
        width: auto;
    }
}

@media (max-width: 768px) {
    #order-chat-float-btn {
        animation: none;
        box-shadow: 0 4px 14px rgba(255, 159, 67, 0.28), 0 2px 6px rgba(0, 0, 0, 0.2);
    }

    #order-chat-float-btn::before {
        display: none;
    }

    .order-chat-float-dropdown {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }

    .order-chat-float-count.visible {
        animation: none;
    }
}
