/* 
  CHAT WIDGET - DARK THEME REDESIGN
  Matches wapset site (purple/dark)
*/

:root {
    --chat-primary: #7c3aed;
    --chat-primary-dark: #5b21b6;
    --chat-primary-light: #a78bfa;
    --chat-bg-white: #111827; /* Dark surface */
    --chat-bg-gray: #0b0f19; /* Darker background */
    --chat-text-main: #f1f5f9;
    --chat-text-muted: #94a3b8;
    --chat-border: rgba(255,255,255,0.07);
    --chat-shadow-strong: 0 20px 40px -5px rgba(0, 0, 0, 0.5);
    --chat-input-bg: #1a2035;
    --chat-bubble-ai: #1a2035;
}

#chat-widget-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999999;
    font-family: 'Cairo', 'Inter', sans-serif;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

/* ═════════ FLOATING BUTTON ═════════ */
#chat-toggle-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--chat-primary), var(--chat-primary-dark));
    box-shadow: 0 4px 14px 0 rgba(124, 58, 237, 0.39);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    position: relative;
}

#chat-toggle-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(124, 58, 237, 0.45);
}

#chat-toggle-btn svg {
    transition: transform 0.3s ease;
}

#chat-toggle-btn.active svg {
    transform: rotate(90deg);
}

/* ═════════ CHAT WINDOW ═════════ */
#chat-window {
    width: 320px;
    height: 460px;
    background: var(--chat-bg-white);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--chat-shadow-strong);
    margin-bottom: 16px;
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: bottom right;
    border: 1px solid var(--chat-border);
}

#chat-window.active {
    transform: translateY(0) scale(1);
    opacity: 1;
    visibility: visible;
}

/* ═════════ HEADER ═════════ */
.chat-header {
    background: linear-gradient(135deg, var(--chat-primary), var(--chat-primary-dark));
    padding: 16px;
    color: white;
    position: relative;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

#chat-close-btn {
    position: absolute;
    top: 16px;
    left: 16px; /* RTL layout */
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: background 0.2s;
}

#chat-close-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

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

.header-avatar-group {
    position: relative;
    width: 48px;
    height: 48px;
}

.header-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid white;
    background: #111827;
    object-fit: cover;
}

.status-indicator {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: #22c55e;
    border-radius: 50%;
    border: 2px solid var(--chat-primary-dark);
}

.chat-header-info h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.chat-header-info p {
    margin: 2px 0 0;
    font-size: 12px;
    opacity: 0.9;
}

/* ═════════ BODY & MESSAGES ═════════ */
.chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--chat-bg-gray);
    scrollbar-width: none;
}

.chat-body::-webkit-scrollbar {
    display: none;
}

.chat-message {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 13.5px;
    line-height: 1.5;
    position: relative;
    animation: slideUp 0.3s ease-out;
}

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

.chat-message.user {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--chat-primary), var(--chat-primary-dark));
    color: white;
    border-bottom-right-radius: 2px;
    box-shadow: 0 2px 10px rgba(124, 58, 237, 0.2);
}

.chat-message.support, .chat-message.ai, .chat-message.staff {
    align-self: flex-start;
    background: var(--chat-bubble-ai);
    color: var(--chat-text-main);
    border-bottom-left-radius: 2px;
    border: 1px solid var(--chat-border);
}

.sender-name-label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    margin-bottom: 4px;
    opacity: 0.9;
}

.admin-label {
    color: #eab308; /* yellow-500 */
}

.support-label {
    color: var(--chat-primary-light);
}

/* ═════════ QUICK REPLIES ═════════ */
.quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
    background: var(--chat-bg-gray) !important;
}

.quick-reply-btn {
    background: var(--chat-bubble-ai);
    border: 1px solid var(--chat-primary);
    color: var(--chat-primary-light);
    padding: 6px 12px;
    border-radius: 18px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.quick-reply-btn:hover {
    background: var(--chat-primary);
    color: white;
    transform: translateY(-1px);
}

/* ═════════ FOOTER ═════════ */
.chat-footer {
    padding: 12px 16px;
    background: var(--chat-bg-white);
    border-top: 1px solid var(--chat-border);
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-input-wrapper {
    flex: 1;
    position: relative;
}

.chat-footer input {
    width: 100%;
    background: var(--chat-input-bg);
    border: 1px solid var(--chat-border);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 14px;
    outline: none;
    color: var(--chat-text-main);
    transition: border-color 0.2s;
}

.chat-footer input:focus {
    border-color: var(--chat-primary);
}

.chat-footer input::placeholder {
    color: var(--chat-text-muted);
}

#chat-send-btn {
    width: 38px;
    height: 38px;
    background: var(--chat-primary);
    border-radius: 50%;
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, background 0.2s;
}

#chat-send-btn:hover {
    transform: scale(1.05);
    background: var(--chat-primary-dark);
}

#chat-send-btn svg {
    width: 18px;
    height: 18px;
    margin-left: -2px;
}

/* ═════════ NOTIFICATION ═════════ */
.notification-dot {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--chat-bg-white);
    opacity: 0;
    transform: scale(0);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.notification-dot.active {
    opacity: 1;
    transform: scale(1);
}

/* Mobile Responsive */
@media (max-width: 480px) {
    #chat-window {
        width: calc(100vw - 40px);
        height: 60vh;
        right: 20px;
        bottom: 80px;
    }
}