/* ==================== CUSTOMER SUPPORT CHAT SYSTEM ==================== */

/* الزر العائم */
.support-floating-btn {
    position: fixed !important;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--brand-yellow), #FFD700);
    border-radius: 50%;
    display: flex !important;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(255, 196, 0, 0.4);
    transition: all 0.3s ease;
    z-index: 9999 !important;
    border: 3px solid var(--brand-black);
    animation: pulse 2s infinite;
    visibility: visible !important;
    opacity: 1 !important;
}

.support-floating-btn:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 8px 30px rgba(255, 196, 0, 0.6);
}

.support-floating-btn i {
    font-size: 1.75rem;
    color: var(--brand-black);
}

.support-floating-btn .support-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    color: white;
    font-size: 0.7rem;
    font-weight: 800;
    padding: 0.15rem 0.4rem;
    border-radius: 50%;
    min-width: 22px;
    text-align: center;
    border: 2px solid var(--brand-white);
}

/* نافذة الدردشة */
.support-chat-window {
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: 400px;
    max-width: calc(100vw - 60px);
    height: 550px;
    max-height: calc(100vh - 150px);
    background: var(--card-bg);
    border-radius: 20px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.3);
    display: none;
    opacity: 0;
    transform: translateY(20px);
    flex-direction: column;
    overflow: hidden;
    z-index: 998;
    border: 3px solid var(--brand-yellow);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.support-chat-window.active {
    display: flex;
    opacity: 1;
    transform: translateY(0);
}

/* رأس النافذة */
.support-chat-header {
    background: linear-gradient(135deg, var(--brand-black), #2a2a2a);
    color: var(--brand-white);
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 3px solid var(--brand-yellow);
}

.support-chat-header-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.support-chat-avatar {
    width: 45px;
    height: 45px;
    background: var(--brand-yellow);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--brand-black);
    border: 2px solid var(--brand-yellow);
}

.support-chat-title {
    display: flex;
    flex-direction: column;
}

.support-chat-title h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: var(--brand-white);
}

.support-chat-title span {
    font-size: 0.75rem;
    color: #a0a0a0;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.support-status-indicator {
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    display: inline-block;
    animation: blink 1.5s infinite;
}

.support-chat-close {
    background: transparent;
    border: none;
    color: var(--brand-yellow);
    font-size: 1.5rem;
    cursor: pointer;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.support-chat-close:hover {
    background: rgba(255, 196, 0, 0.2);
    transform: rotate(90deg);
}

/* محتوى الرسائل */
.support-chat-body {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    background: var(--bg-secondary);
}

.support-chat-body::-webkit-scrollbar {
    width: 6px;
}

.support-chat-body::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

.support-chat-body::-webkit-scrollbar-thumb {
    background: var(--brand-yellow);
    border-radius: 3px;
}

/* الرسائل */
.support-message {
    margin-bottom: 1rem;
    animation: messageSlideIn 0.3s ease;
}

.support-message-content {
    max-width: 80%;
    padding: 0.875rem 1.125rem;
    border-radius: 12px;
    word-wrap: break-word;
    font-size: 0.9rem;
    line-height: 1.5;
    position: relative;
}

.support-message-time {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 0.35rem;
    display: block;
}

/* رسالة المستخدم - على اليسار */
.support-message.user .support-message-content {
    background: var(--brand-yellow);
    color: var(--brand-black);
    margin-right: auto;
    border-bottom-left-radius: 4px;
}

/* رسالة خدمة العملاء - على اليمين */
.support-message.admin .support-message-content {
    background: var(--card-bg);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    border-bottom-right-radius: 4px;
    margin-left: auto;
}

.support-message.admin .support-admin-label {
    font-size: 0.75rem;
    color: var(--brand-yellow);
    font-weight: 700;
    margin-bottom: 0.25rem;
    margin-left: auto;
    margin-right: 0;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    width: fit-content;
    direction: rtl;
}

.support-message.admin .support-admin-label i {
    font-size: 0.8rem;
}

/* إخفاء admin label من رسائل المستخدم */
.support-message.user .support-admin-label {
    display: none !important;
}

/* رسالة ترحيبية */
.support-message.welcome .support-message-content {
    background: linear-gradient(135deg, rgba(255, 196, 0, 0.15), rgba(255, 196, 0, 0.05));
    color: var(--text-primary);
    border: 2px solid var(--brand-yellow);
    text-align: center;
    max-width: 100%;
    border-radius: 12px;
}

.support-message.welcome .support-message-content strong {
    color: var(--brand-yellow);
    display: block;
    margin-bottom: 0.5rem;
    font-size: 1.05rem;
}

/* نموذج الإرسال */
.support-chat-footer {
    padding: 1rem 1.5rem;
    background: var(--card-bg);
    border-top: 2px solid var(--border-color);
}

.support-chat-form {
    display: flex;
    gap: 0.75rem;
}

.support-chat-input {
    flex: 1;
    padding: 0.875rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-family: var(--font-family);
    font-size: 0.9rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
    transition: all 0.3s ease;
    resize: none;
    max-height: 100px;
}

.support-chat-input:focus {
    outline: none;
    border-color: var(--brand-yellow);
    box-shadow: 0 0 0 3px rgba(255, 196, 0, 0.1);
}

.support-send-btn {
    width: 50px;
    height: 50px;
    background: var(--brand-yellow);
    border: 2px solid var(--brand-black);
    border-radius: 8px;
    color: var(--brand-black);
    font-size: 1.3rem;
    cursor: pointer;
    transition: background 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.support-send-btn:hover {
    background: #e6b000;
}

.support-send-btn:active {
    background: #d9a700;
}

/* حالة التحميل */
.support-loading {
    text-align: center;
    padding: 1rem;
    color: var(--text-secondary);
}

.support-loading i {
    animation: spin 1s linear infinite;
}

/* Animations */
@keyframes pulse {

    0%,
    100% {
        box-shadow: 0 4px 20px rgba(255, 196, 0, 0.4);
    }

    50% {
        box-shadow: 0 4px 30px rgba(255, 196, 0, 0.7);
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.3;
    }
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* Dark Theme Adjustments */
body.theme-dark .support-floating-btn {
    box-shadow: 0 4px 20px rgba(255, 196, 0, 0.5);
}

body.theme-dark .support-chat-window {
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
}

body.theme-dark .support-message.admin .support-message-content {
    background: #2a2a2a;
    border-color: #3a3a3a;
}

/* Responsive Design */
@media (max-width: 768px) {
    .support-floating-btn {
        bottom: 20px;
        right: 20px;
        width: 55px;
        height: 55px;
    }

    .support-floating-btn i {
        font-size: 1.5rem;
    }

    .support-chat-window {
        bottom: 85px;
        right: 20px;
        width: calc(100vw - 40px);
        height: 500px;
    }

    .support-chat-header {
        padding: 1rem 1.25rem;
    }

    .support-chat-avatar {
        width: 40px;
        height: 40px;
        font-size: 1.25rem;
    }

    .support-chat-body {
        padding: 1rem;
    }

    .support-message-content {
        font-size: 0.875rem;
        padding: 0.75rem 1rem;
    }

    .support-chat-footer {
        padding: 0.875rem 1rem;
    }

    .support-chat-input {
        font-size: 0.875rem;
        padding: 0.75rem 0.875rem;
    }

    .support-send-btn {
        width: 45px;
        height: 45px;
        font-size: 1.1rem;
    }
}

/* تحسينات للشاشات المتوسطة والصغيرة */
@media (max-width: 640px) {
    .support-chat-window {
        bottom: 80px;
        right: 15px;
        left: 15px;
        width: auto;
        max-width: none;
        height: 480px;
        max-height: 65vh;
    }

    .support-message-content {
        max-width: 85%;
        font-size: 0.85rem;
    }

    .support-chat-title h3 {
        font-size: 0.95rem;
    }

    .support-chat-title span {
        font-size: 0.7rem;
    }
}

/* تحسينات للشاشات الصغيرة جداً */
@media (max-width: 480px) {
    .support-floating-btn {
        bottom: 15px;
        right: 15px;
        width: 50px;
        height: 50px;
    }

    .support-floating-btn i {
        font-size: 1.4rem;
    }

    .support-chat-window {
        bottom: 70px;
        right: 10px;
        left: 10px;
        width: auto;
        height: 450px;
        max-height: 60vh;
        border-radius: 16px;
    }

    .support-chat-header {
        padding: 0.875rem 1rem;
    }

    .support-chat-avatar {
        width: 36px;
        height: 36px;
        font-size: 1.1rem;
    }

    .support-chat-title h3 {
        font-size: 0.9rem;
    }

    .support-chat-title span {
        font-size: 0.65rem;
    }

    .support-chat-close {
        width: 30px;
        height: 30px;
        font-size: 1.25rem;
    }

    .support-chat-body {
        padding: 0.875rem;
    }

    .support-message-content {
        max-width: 90%;
        font-size: 0.8rem;
        padding: 0.65rem 0.875rem;
    }

    .support-message-time {
        font-size: 0.65rem;
    }

    .support-chat-footer {
        padding: 0.75rem;
    }

    .support-chat-input {
        font-size: 0.8rem;
        padding: 0.65rem 0.75rem;
        border-radius: 10px;
    }

    .support-send-btn {
        width: 42px;
        height: 42px;
        font-size: 1rem;
        border-radius: 10px;
    }

    .support-admin-label {
        font-size: 0.7rem;
    }
}

/* تحسينات للشاشات الصغيرة جداً (أقل من 375px) */
@media (max-width: 375px) {
    .support-chat-window {
        right: 5px;
        left: 5px;
        border-radius: 12px;
    }

    .support-chat-header {
        padding: 0.75rem 0.875rem;
    }

    .support-message-content {
        font-size: 0.775rem;
        padding: 0.6rem 0.8rem;
    }

    .support-chat-footer {
        padding: 0.65rem;
    }

    .support-chat-form {
        gap: 0.5rem;
    }
}

/* إصلاح للأجهزة ذات الطول الطويل (مثل iPhone X وما بعده) */
@media (max-width: 480px) and (min-height: 700px) {
    .support-chat-window {
        max-height: 600px;
    }
}