/**
 * EazyGo — ويدجت الدعم الفني (تصميم عصري)
 */

/* ——— زر الإطلاق العائم ——— */
.floating-chat-icon {
    position: fixed;
    bottom: 28px;
    left: 28px;
    z-index: 10100;
    display: none;
}

body.user-logged-in #floatingChatIcon.floating-chat-icon {
    visibility: visible;
    opacity: 1;
    height: auto;
    overflow: visible;
    pointer-events: auto;
}

.floating-chat-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 58px;
    height: 58px;
    padding: 0;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: #fff;
    font-family: inherit;
    background: linear-gradient(135deg, #6366f1 0%, #0ea5e9 50%, #14b8a6 100%);
    box-shadow:
        0 4px 24px rgba(99, 102, 241, 0.45),
        0 8px 32px rgba(14, 165, 233, 0.25);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.floating-chat-btn__pulse {
    position: absolute;
    inset: -4px;
    border-radius: 999px;
    background: linear-gradient(135deg, #6366f1, #14b8a6);
    opacity: 0.35;
    animation: supportLauncherPulse 2.5s ease-out infinite;
    z-index: -1;
}

@keyframes supportLauncherPulse {
    0% { transform: scale(1); opacity: 0.4; }
    70% { transform: scale(1.15); opacity: 0; }
    100% { transform: scale(1.15); opacity: 0; }
}

.floating-chat-btn__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
}

.floating-chat-btn:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow:
        0 8px 32px rgba(99, 102, 241, 0.5),
        0 12px 40px rgba(20, 184, 166, 0.3);
}

.floating-chat-btn:active {
    transform: translateY(0) scale(0.98);
}

.chat-badge {
    position: absolute;
    top: -4px;
    left: -4px;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    background: linear-gradient(135deg, #f43f5e, #e11d48);
    color: #fff;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
    box-shadow: 0 2px 8px rgba(225, 29, 72, 0.5);
}

/* ——— نافذة الشات ——— */
#chatWindow.support-chat-window {
    position: fixed !important;
    bottom: 96px !important;
    left: 28px !important;
    right: auto !important;
    top: auto !important;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 560px;
    max-height: calc(100vh - 110px);
    display: none;
    flex-direction: column;
    z-index: 10101 !important;
    overflow: hidden;
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
    border-radius: 22px;
    background: #f8fafc;
    box-shadow:
        0 0 0 1px rgba(15, 23, 42, 0.06),
        0 24px 64px rgba(15, 23, 42, 0.18),
        0 8px 24px rgba(99, 102, 241, 0.12);
    animation: supportWindowIn 0.35s cubic-bezier(0.34, 1.4, 0.64, 1);
    font-family: inherit;
}

#chatWindow.support-chat-window.is-open {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

@keyframes supportWindowIn {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

body.support-chat-open #floatingChatIcon {
    display: block !important;
}

/* ——— الهيدر ——— */
.support-chat-header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 16px 14px;
    background: linear-gradient(125deg, #1e1b4b 0%, #312e81 35%, #0f766e 100%);
    color: #fff;
    position: relative;
    overflow: hidden;
}

.support-chat-header::before {
    content: '';
    position: absolute;
    top: -40%;
    right: -20%;
    width: 140px;
    height: 140px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.12) 0%, transparent 70%);
    pointer-events: none;
}

.support-chat-header__info {
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    z-index: 1;
    min-width: 0;
}

.support-chat-avatar {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.25), rgba(255, 255, 255, 0.08));
    border: 1px solid rgba(255, 255, 255, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.support-chat-title {
    margin: 0 0 4px;
    font-size: 1rem;
    font-weight: 800;
    line-height: 1.2;
}

.support-chat-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px 3px 8px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.support-chat-pill::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 8px currentColor;
}

.support-chat-pill--online {
    color: #6ee7b7;
    background: rgba(16, 185, 129, 0.2);
    border-color: rgba(110, 231, 183, 0.35);
}

.support-chat-pill--online::before {
    background: #34d399;
    animation: supportDotBlink 2s ease-in-out infinite;
}

.support-chat-pill--offline {
    color: #fde68a;
    background: rgba(251, 191, 36, 0.15);
    border-color: rgba(253, 224, 71, 0.3);
}

.support-chat-pill--offline::before {
    background: #fbbf24;
}

@keyframes supportDotBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.45; }
}

.support-chat-header__actions {
    display: flex;
    gap: 6px;
    position: relative;
    z-index: 1;
}

.support-chat-icon-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.2s;
}

.support-chat-icon-btn:hover {
    background: rgba(255, 255, 255, 0.22);
    transform: scale(1.05);
}

.support-chat-icon-btn--close:hover {
    background: rgba(244, 63, 94, 0.35);
}

/* ——— شرائح نوع البلاغ ——— */
.support-chat-topics {
    flex-shrink: 0;
    padding: 12px 14px 10px;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
}

.support-chat-topics__label {
    display: block;
    font-size: 0.7rem;
    font-weight: 700;
    color: #64748b;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.support-chat-topics__label i {
    margin-left: 4px;
    color: #6366f1;
}

.support-topic-chips {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
}

.support-topic-chips::-webkit-scrollbar {
    display: none;
}

.support-topic-chip {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    border: 1.5px solid #e2e8f0;
    border-radius: 999px;
    background: #f8fafc;
    color: #475569;
    font-size: 0.75rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
}

.support-topic-chip i {
    font-size: 0.8rem;
    opacity: 0.85;
}

.support-topic-chip:hover {
    border-color: #a5b4fc;
    color: #4f46e5;
    background: #eef2ff;
}

.support-topic-chip.is-active {
    border-color: transparent;
    color: #fff;
    background: linear-gradient(135deg, #6366f1, #0ea5e9);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}

.support-topic-chip[data-category="order"].is-active {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.support-topic-chip[data-category="payment"].is-active {
    background: linear-gradient(135deg, #10b981, #059669);
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.35);
}

.support-topic-chip[data-category="account"].is-active {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.35);
}

.support-topic-chip[data-category="technical"].is-active {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    box-shadow: 0 4px 12px rgba(217, 119, 6, 0.35);
}

.support-chat-category-select {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* ——— منطقة الرسائل ——— */
.support-chat-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background:
        radial-gradient(ellipse at 20% 0%, rgba(99, 102, 241, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 100%, rgba(20, 184, 166, 0.06) 0%, transparent 50%),
        #f1f5f9;
    scroll-behavior: smooth;
}

.support-chat-messages::-webkit-scrollbar {
    width: 5px;
}

.support-chat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 999px;
}

.support-chat-empty {
    margin: auto;
    text-align: center;
    padding: 24px 16px;
    color: #94a3b8;
}

.support-chat-empty__icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 12px;
    border-radius: 50%;
    background: linear-gradient(135deg, #e0e7ff, #cffafe);
    color: #6366f1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}

.support-chat-empty p {
    margin: 0;
    font-size: 0.85rem;
    line-height: 1.5;
}

/* ——— فقاعات الرسائل ——— */
.support-msg {
    display: flex;
    max-width: 88%;
    animation: supportMsgIn 0.3s ease;
}

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

.support-msg--user {
    align-self: flex-end;
    justify-content: flex-end;
}

.support-msg--agent {
    align-self: flex-start;
    gap: 8px;
}

.support-msg--system {
    align-self: center;
    max-width: 95%;
}

.support-msg__agent-avatar {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: 10px;
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    margin-top: 2px;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.support-msg__bubble {
    position: relative;
    padding: 10px 14px 6px;
    border-radius: 18px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.support-msg--user .support-msg__bubble {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    color: #fff;
    border-bottom-left-radius: 6px;
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.25);
}

.support-msg--agent .support-msg__bubble {
    background: #fff;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-bottom-right-radius: 6px;
}

.support-msg--system .support-msg__bubble {
    background: rgba(255, 255, 255, 0.85);
    border: 1px dashed #cbd5e1;
    color: #64748b;
    font-size: 0.8rem;
    text-align: center;
    padding: 8px 14px;
    border-radius: 12px;
}

/* بطاقة بيانات المتصل عند الاتصال */
.support-msg--connect {
    align-self: stretch;
    max-width: 100%;
    flex-direction: column;
    align-items: stretch;
}

.support-connect-card {
    background: linear-gradient(135deg, #eef2ff 0%, #f0fdfa 100%);
    border: 1px solid #c7d2fe;
    border-radius: 14px;
    padding: 12px 14px;
    box-shadow: 0 2px 10px rgba(99, 102, 241, 0.1);
}

.support-connect-card__title {
    font-size: 0.78rem;
    font-weight: 800;
    color: #4338ca;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.support-connect-card__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 6px;
}

.support-connect-card__list li {
    font-size: 0.82rem;
    color: #334155;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: baseline;
}

.support-connect-card__label {
    color: #64748b;
    font-weight: 600;
    min-width: 3.2rem;
}

.support-connect-card__list strong {
    color: #0f172a;
    font-weight: 700;
    word-break: break-all;
}

.support-msg__time--connect {
    display: block;
    text-align: center;
    margin-top: 6px;
    font-size: 0.65rem;
    color: #94a3b8;
}

/* بطاقات الطلبات في الشات */
.support-msg__orders {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.support-orders-block__title {
    font-size: 0.75rem;
    font-weight: 800;
    color: #4338ca;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.support-order-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 10px 12px;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
}

.support-msg--user .support-order-card {
    background: rgba(255, 255, 255, 0.95);
}

.support-order-card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid #f1f5f9;
}

.support-order-card__id {
    font-weight: 800;
    font-size: 0.82rem;
    color: #4f46e5;
    display: flex;
    align-items: center;
    gap: 6px;
}

.support-order-card__status {
    font-size: 0.68rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 999px;
    background: #ecfdf5;
    color: #047857;
    white-space: nowrap;
}

.support-order-card__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 4px;
}

.support-order-card__list li {
    font-size: 0.75rem;
    color: #475569;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.support-order-card__list span {
    color: #94a3b8;
    font-weight: 600;
}

.support-order-card__list strong {
    color: #0f172a;
    font-weight: 700;
}

.support-order-card__open {
    margin-top: 8px;
    width: 100%;
    padding: 6px 10px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, #6366f1, #0ea5e9);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.support-order-card__open:hover {
    filter: brightness(1.05);
}

.support-orders-block__cards {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.support-msg__text {
    font-size: 0.88rem;
    line-height: 1.5;
    word-break: break-word;
}

.support-msg--user .support-msg__time {
    color: rgba(255, 255, 255, 0.75);
}

.support-msg__time {
    display: block;
    font-size: 0.65rem;
    color: #94a3b8;
    margin-top: 4px;
    text-align: left;
}

.support-msg--user .support-msg__time {
    text-align: right;
}

.support-msg__attachment {
    margin-top: 8px;
}

.support-msg__img {
    max-width: 100%;
    max-height: 200px;
    border-radius: 12px;
    display: block;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.support-msg--agent .support-msg__img {
    border-color: #e2e8f0;
}

.support-msg__file {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    color: inherit;
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 600;
}

.support-msg--agent .support-msg__file {
    background: #f1f5f9;
    color: #0369a1;
}

.support-msg__file:hover {
    text-decoration: underline;
}

/* ——— منطقة الإرسال ——— */
.support-chat-composer {
    flex-shrink: 0;
    padding: 10px 12px 14px;
    background: #fff;
    border-top: 1px solid #e2e8f0;
    box-shadow: 0 -8px 24px rgba(15, 23, 42, 0.04);
}

.support-chat-pending-attach {
    margin-bottom: 8px;
}

.support-chat-pending-attach[hidden] {
    display: none !important;
}

.support-pending-attach__inner {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: linear-gradient(135deg, #eef2ff, #f0fdfa);
    border: 1px solid #c7d2fe;
    border-radius: 12px;
    font-size: 0.78rem;
    color: #475569;
}

.support-pending-attach__thumb {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 8px;
}

.support-pending-attach__icon {
    font-size: 1.25rem;
    color: #6366f1;
}

.support-pending-attach__name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 600;
}

.support-pending-attach__remove {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 8px;
    background: #fff;
    color: #64748b;
    font-size: 1.1rem;
    cursor: pointer;
    line-height: 1;
    transition: background 0.2s, color 0.2s;
}

.support-pending-attach__remove:hover {
    background: #fee2e2;
    color: #dc2626;
}

.support-chat-composer__box {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 6px 8px 6px 12px;
    background: #f1f5f9;
    border-radius: 16px;
    border: 1.5px solid #e2e8f0;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.support-chat-composer__box:focus-within {
    border-color: #818cf8;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
    background: #fff;
}

.support-chat-attach-btn {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border: none;
    border-radius: 12px;
    background: transparent;
    color: #64748b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    transition: color 0.2s, background 0.2s;
}

.support-chat-attach-btn:hover {
    color: #6366f1;
    background: #e0e7ff;
}

.support-chat-composer__box textarea {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    padding: 8px 0;
    min-height: 24px;
    max-height: 100px;
    font-family: inherit;
    font-size: 0.9rem;
    line-height: 1.45;
    color: #1e293b;
}

.support-chat-composer__box textarea:focus {
    outline: none;
}

.support-chat-composer__box textarea::placeholder {
    color: #94a3b8;
}

.support-chat-send-btn {
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    color: #fff;
    background: linear-gradient(135deg, #6366f1, #0ea5e9);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
}

.support-chat-send-btn:hover {
    transform: scale(1.06);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
}

.support-chat-send-btn:active {
    transform: scale(0.96);
}

/* ——— جوال ——— */
@media (max-width: 768px) {
    .floating-chat-icon {
        bottom: 18px;
        left: 18px;
    }

    .floating-chat-btn {
        width: 52px;
        height: 52px;
    }

    .floating-chat-btn__icon {
        font-size: 1.2rem;
    }

    #chatWindow.support-chat-window,
    #chatWindow.support-chat-window.is-open {
        left: 12px !important;
        bottom: 82px !important;
        width: calc(100vw - 24px);
        max-width: none;
        height: min(72vh, 520px) !important;
        max-height: calc(100vh - 100px) !important;
        border-radius: 18px;
    }

    .support-msg {
        max-width: 92%;
    }
}

