/* واجهة الدردشة المباشرة - تصميم فخم وعصري (Premium) */
.live-chat-widget {
    position: fixed;
    bottom: 90px;
    inset-inline-end: 20px;
    z-index: 10001;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 120px);
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    background: rgba(15, 15, 15, 0.95);
    backdrop-filter: blur(25px) saturate(200%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    box-shadow:
        0 25px 50px -12px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.05) inset;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.live-chat-widget.active {
    display: flex;
    animation: chatReveal 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes chatReveal {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.9);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* التذييل في الفوتر (الزر العائم) */
.live-chat-btn {
    position: fixed !important;
    bottom: 25px !important;
    inset-inline-end: 20px !important;
    z-index: 10000 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 60px !important;
    height: 60px !important;
    border-radius: 50% !important;
    border: 2px solid #25d366;
    background: #000;
    color: #25d366;
    cursor: pointer !important;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4) !important;
    animation: buttonColorSwap 3s infinite alternate;
}

@keyframes buttonColorSwap {
    0% {
        background: #000;
        color: #25d366;
        border-color: #25d366;
    }

    45% {
        background: #000;
        color: #25d366;
        border-color: #25d366;
    }

    55% {
        background: #25d366;
        color: #000;
        border-color: #000;
    }

    100% {
        background: #25d366;
        color: #000;
        border-color: #000;
    }
}

.live-chat-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff0000;
    color: #fff;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: bold;
    border: 2px solid #fff;
    z-index: 10002;
    animation: badgePop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes badgePop {
    from {
        transform: scale(0);
    }

    to {
        transform: scale(1);
    }
}

.live-chat-btn.chat-open {
    bottom: calc(600px + 20px) !important;
    background: #25d366 !important;
    color: #000 !important;
}

/* الهيدر الاحترافي */
.live-chat-header {
    background: linear-gradient(135deg, #111 0%, #222 100%);
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.live-chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.live-chat-header-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
}

.live-chat-header-title i {
    color: #25d366;
    font-size: 1.2rem;
}

.live-chat-close {
    background: rgba(255, 255, 255, 0.05);
    border: none;
    color: rgba(255, 255, 255, 0.6);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.live-chat-close:hover {
    background: rgba(168, 85, 247, 0.2);
    color: #fff;
    transform: rotate(90deg);
}

/* منطقة الرسائل */
.live-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: radial-gradient(circle at top, rgba(37, 211, 102, 0.05) 0%, transparent 70%);
}

.live-chat-messages::-webkit-scrollbar {
    width: 4px;
}

.live-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

/* فقاعات الرسائل */
.message {
    max-width: 85%;
    position: relative;
    padding: 10px 16px;
    border-radius: 18px;
    font-size: 0.95rem;
    line-height: 1.5;
    animation: msgPop 0.3s ease forwards;
}

@keyframes msgPop {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.message.user {
    align-self: flex-end;
    background: linear-gradient(135deg, #25d366 0%, #128c7e 100%);
    color: #fff;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 15px rgba(37, 211, 102, 0.2);
}

.message.admin {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.08);
    color: #eee;
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.message-time {
    font-size: 0.7rem;
    opacity: 0.6;
    margin-top: 4px;
    text-align: end;
}

.admin-name-tag {
    font-size: 0.75rem;
    font-weight: 700;
    color: #25d366;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* منطقة الإدخال */
.live-chat-input-area {
    padding: 1.25rem;
    background: rgba(0, 0, 0, 0.3);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    gap: 12px;
}

.live-chat-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 10px 18px;
    color: #fff;
    font-family: inherit;
    font-size: 0.95rem;
    resize: none;
    transition: all 0.3s ease;
}

.live-chat-input:focus {
    outline: none;
    border-color: #25d366;
    background: rgba(255, 255, 255, 0.08);
}

.live-chat-send {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #25d366 0%, #00ba7c 100%);
    color: #fff;
    border: none;
    box-shadow: 0 4px 15px rgba(37, 211, 102, 0.4);
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.live-chat-send:hover {
    transform: scale(1.15) rotate(-15deg);
    background: #00ba7c;
    box-shadow: 0 6px 25px rgba(37, 211, 102, 0.6);
}

/* الأزرار السريعة - تصميم راقي */
.chat-options-quick {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 15px;
}

.chat-options-quick button {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    padding: 12px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.chat-options-quick button:hover {
    background: rgba(37, 211, 102, 0.1);
    border-color: #25d366;
    color: #25d366;
    transform: translateY(-2px);
}

/* إخفاء زر التحويل لأنه أصبح تلقائياً */
.live-chat-transfer-area {
    display: none;
}

/* حالة الفريق المتواجد */
.live-chat-status {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #25d366;
    position: relative;
}

.live-chat-status::after {
    content: '';
    position: absolute;
    inset: -2px;
    border: 1px solid #25d366;
    border-radius: 50%;
    animation: statusPulse 2s infinite;
}

@keyframes statusPulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    100% {
        transform: scale(2.5);
        opacity: 0;
    }
}

/* Responsive Fixes */
@media (max-width: 480px) {
    .live-chat-widget {
        inset-inline-end: 10px;
        width: calc(100vw - 20px);
        bottom: 80px;
    }

    .chat-options-quick {
        grid-template-columns: 1fr;
    }
}

/* Reply UI */
.reply-container {
    background: rgba(255, 255, 255, 0.05);
    border-right: 3px solid #25d366;
    padding: 8px 12px;
    border-radius: 8px;
    margin-bottom: 8px;
    font-size: 0.85rem;
    position: relative;
    cursor: pointer;
}

.reply-container .reply-user {
    font-weight: bold;
    color: #25d366;
    display: block;
    margin-bottom: 2px;
}

.reply-container .reply-text {
    color: #aaa;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.message-reply-preview {
    background: rgba(0, 0, 0, 0.5);
    padding: 10px 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: none;
    align-items: center;
    justify-content: space-between;
}

.message-reply-preview.active {
    display: flex;
}

/* Media Messages */
.message-image img {
    max-width: 100%;
    border-radius: 12px;
    margin-top: 5px;
    cursor: pointer;
}

.message-voice {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 0;
}

.voice-player {
    flex: 1;
    height: 30px;
}

/* Mode Toggle */
.chat-mode-toggle {
    display: flex;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 2px;
    font-size: 0.8rem;
}

.mode-btn {
    padding: 4px 12px;
    border-radius: 18px;
    cursor: pointer;
    transition: all 0.3s;
    color: #888;
}

.mode-btn.active {
    background: #25d366;
    color: #000;
    font-weight: bold;
}

/* Recording UI */
.recording-ui {
    display: none;
    align-items: center;
    gap: 15px;
    flex: 1;
    color: #ff4b2b;
    font-weight: bold;
}

.recording-dot {
    width: 10px;
    height: 10px;
    background: #ff4b2b;
    border-radius: 50%;
    animation: blink 1s infinite;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

.input-actions-extra {
    display: flex;
    gap: 10px;
    align-items: center;
}

.action-icon {
    font-size: 1.2rem;
    color: #888;
    cursor: pointer;
    transition: color 0.3s;
}

.action-icon:hover {
    color: #25d366;
}

/* Expiry indicator */
.expiry-tag {
    font-size: 0.65rem;
    color: #ff9800;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Mode standard restriction removed - always show advanced tools */

/* Timer Bar */
.chat-timer-bar {
    background: rgba(255, 152, 0, 0.1);
    color: #ff9800;
    padding: 6px 15px;
    font-size: 0.8rem;
    font-weight: bold;
    display: none;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-bottom: 1px solid rgba(255, 152, 0, 0.2);
    animation: slideDown 0.3s ease;
}

.chat-timer-bar.active {
    display: flex;
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
    }

    to {
        transform: translateY(0);
    }
}

/* Swipe & Highlight */
.message {
    transition: transform 0.2s cubic-bezier(0.18, 0.89, 0.32, 1.28);
    touch-action: pan-y;
    position: relative;
}

.message.highlight {
    animation: messageHighlight 2s ease;
}

@keyframes messageHighlight {

    0%,
    100% {
        background-color: inherit;
    }

    20%,
    80% {
        background-color: rgba(37, 211, 102, 0.3) !important;
    }
}

.swipe-indicator {
    position: absolute;
    right: -40px;
    top: 50%;
    transform: translateY(-50%);
    color: #25d366;
    font-size: 1.2rem;
    opacity: 0;
    transition: opacity 0.2s;
}

.mode-locked .chat-mode-toggle {
    opacity: 0.5;
    pointer-events: none;
    filter: grayscale(1);
}

/* Scroll Snap/Smooth */
.live-chat-messages {
    scroll-behavior: smooth;
}