/* ==================== 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: linear-gradient(135deg, #00c8ff 0%, #7b2fff 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(0, 200, 255, 0.4), 0 2px 8px rgba(0, 0, 0, 0.2);
    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, 200, 255, 0.2);
    animation: chatPulse 3s ease-in-out infinite;
    z-index: -1;
}

#livechat-btn:hover {
    transform: scale(1.12);
    box-shadow: 0 6px 28px rgba(0, 200, 255, 0.5), 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: 160px;
    left: 28px;
    width: 360px;
    height: 480px;
    z-index: 100010;
    border-radius: 16px;
    background: rgba(10, 15, 28, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(0, 200, 255, 0.2);
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5), 0 0 30px rgba(0, 200, 255, 0.1);
    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: 14px 16px;
    background: linear-gradient(135deg, rgba(0, 200, 255, 0.15), rgba(123, 47, 255, 0.15));
    border-bottom: 1px solid rgba(0, 200, 255, 0.15);
    flex-shrink: 0;
}

.livechat-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.livechat-header-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #00c8ff, #7b2fff);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.livechat-header-text h4 {
    margin: 0;
    font-size: 0.9rem;
    color: #fff;
    font-weight: 700;
}

.livechat-header-text span {
    font-size: 0.72rem;
    color: rgba(0, 200, 255, 0.8);
}

.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;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scrollbar-width: none;
}

.livechat-messages::-webkit-scrollbar {
    display: none;
}

/* ---------- Message Bubbles ---------- */
.chat-msg {
    max-width: 82%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 0.85rem;
    line-height: 1.5;
    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: 14px;
    border-bottom-right-radius: 4px;
}

.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-bottom-right-radius: 14px;
    border-bottom-left-radius: 4px;
}

.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);
}

/* ---------- Welcome Message ---------- */
.livechat-welcome {
    text-align: center;
    padding: 30px 20px;
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.8rem;
    line-height: 1.6;
}

.livechat-welcome .welcome-icon {
    font-size: 2.5rem;
    margin-bottom: 10px;
    display: block;
}

/* ---------- Input Area ---------- */
.livechat-input {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid rgba(0, 200, 255, 0.1);
    background: rgba(0, 0, 0, 0.2);
    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: 20px;
    padding: 10px 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: 50%;
    background: linear-gradient(135deg, #00c8ff, #7b2fff);
    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;
}

/* ---------- 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 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: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
    }
}

@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: 10px;
    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;
    }
}
