/* ============================================================
   CHAT WIDGET — floating AI customer support
   ============================================================ */

.chat-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1050;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Toggle button */
.chat-toggle-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--neon-pink), #ff007a);
    border: none;
    color: #fff;
    font-size: 1.3rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(255, 45, 161, 0.45);
    position: relative;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.chat-toggle-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(255, 45, 161, 0.6);
}

.chat-icon-open,
.chat-icon-close { position: absolute; transition: opacity 0.2s, transform 0.2s; }
.chat-icon-close  { opacity: 0; transform: rotate(-90deg); }
.chat-open .chat-icon-open  { opacity: 0; transform: rotate(90deg); }
.chat-open .chat-icon-close { opacity: 1; transform: rotate(0); }

.chat-unread-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 10px;
    height: 10px;
    background: var(--electric-yellow, #ffe600);
    border-radius: 50%;
    border: 2px solid var(--charcoal, #1a1a1a);
}

/* Panel */
.chat-panel {
    position: absolute;
    bottom: 68px;
    right: 0;
    width: 340px;
    max-height: 520px;
    background: rgba(22, 22, 28, 0.97);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 45, 161, 0.25);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6);
    transform: scale(0.92) translateY(12px);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.22s ease, opacity 0.22s ease;
    transform-origin: bottom right;
}

.chat-open .chat-panel {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: all;
}

/* Header */
.chat-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    background: linear-gradient(135deg, rgba(255, 45, 161, 0.12), rgba(255, 0, 122, 0.06));
    border-radius: 16px 16px 0 0;
}

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

.chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--neon-pink), #ff007a);
    color: #fff;
    font-weight: 800;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-header-name { font-weight: 700; font-size: 0.9rem; color: var(--off-white, #f0f0f0); }
.chat-header-status { font-size: 0.72rem; color: rgba(255,255,255,0.55); display: flex; align-items: center; gap: 5px; margin-top: 1px; }
.chat-online-dot { width: 7px; height: 7px; border-radius: 50%; background: #4caf50; display: inline-block; }

.chat-close-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,0.5);
    font-size: 0.95rem;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    transition: color 0.15s;
}
.chat-close-btn:hover { color: var(--neon-pink); }

/* Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}

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

.chat-message { display: flex; }
.chat-message-user { justify-content: flex-end; }
.chat-message-bot  { justify-content: flex-start; }

.chat-bubble {
    max-width: 82%;
    padding: 10px 13px;
    border-radius: 14px;
    font-size: 0.875rem;
    line-height: 1.5;
    word-wrap: break-word;
}

.chat-message-user .chat-bubble {
    background: linear-gradient(135deg, var(--neon-pink), #ff007a);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chat-message-bot .chat-bubble {
    background: rgba(255, 255, 255, 0.07);
    color: var(--off-white, #f0f0f0);
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(255,255,255,0.06);
}

/* Typing indicator */
.chat-typing {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 12px 16px;
}
.chat-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: rgba(255,255,255,0.4);
    animation: chatTypingBounce 1.2s infinite ease-in-out;
}
.chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes chatTypingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30%            { transform: translateY(-6px); opacity: 1; }
}

/* Order lookup */
.chat-order-lookup {
    padding: 12px 16px;
    border-top: 1px solid rgba(255,255,255,0.06);
    background: rgba(255, 45, 161, 0.04);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-lookup-label { font-size: 0.78rem; color: rgba(255,255,255,0.55); margin: 0; }

.chat-lookup-input {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 8px;
    color: var(--off-white, #f0f0f0);
    padding: 8px 10px;
    font-size: 0.82rem;
    width: 100%;
    outline: none;
    transition: border-color 0.15s;
}
.chat-lookup-input:focus { border-color: var(--neon-pink); }
.chat-lookup-input::placeholder { color: rgba(255,255,255,0.3); }

.chat-lookup-submit {
    background: linear-gradient(135deg, var(--neon-pink), #ff007a);
    border: none;
    border-radius: 8px;
    color: #fff;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 8px;
    cursor: pointer;
    transition: opacity 0.15s;
}
.chat-lookup-submit:hover { opacity: 0.85; }

/* Input area */
.chat-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid rgba(255,255,255,0.07);
}

.chat-input {
    flex: 1;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    color: var(--off-white, #f0f0f0);
    padding: 9px 12px;
    font-size: 0.875rem;
    resize: none;
    outline: none;
    line-height: 1.4;
    max-height: 100px;
    overflow-y: auto;
    transition: border-color 0.15s;
}
.chat-input:focus { border-color: rgba(255, 45, 161, 0.5); }
.chat-input::placeholder { color: rgba(255,255,255,0.3); }

.chat-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--neon-pink), #ff007a);
    border: none;
    color: #fff;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity 0.15s, transform 0.15s;
}
.chat-send-btn:hover:not(:disabled) { opacity: 0.85; transform: scale(1.05); }
.chat-send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Mobile */
@media (max-width: 480px) {
    .chat-widget { bottom: 16px; right: 16px; }
    .chat-panel  { width: calc(100vw - 32px); right: 0; }
}

/* ============================================================
   ADMIN CHAT PAGES
   ============================================================ */

.chat-admin-transcript {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chat-admin-msg { display: flex; flex-direction: column; }
.chat-admin-msg-user { align-items: flex-end; }
.chat-admin-msg-bot  { align-items: flex-start; }

.chat-admin-msg-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: rgba(255,255,255,0.4);
    margin-bottom: 4px;
    font-weight: 600;
}

.chat-admin-msg-bubble {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 0.9rem;
    line-height: 1.55;
    white-space: pre-wrap;
}

.chat-admin-msg-user .chat-admin-msg-bubble {
    background: linear-gradient(135deg, rgba(255, 45, 161, 0.25), rgba(255, 0, 122, 0.15));
    border: 1px solid rgba(255, 45, 161, 0.3);
    color: var(--off-white, #f0f0f0);
}

.chat-admin-msg-bot .chat-admin-msg-bubble {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.08);
    color: var(--off-white, #f0f0f0);
}

.table-row-escalated td { background: rgba(255, 45, 161, 0.04); }

.chat-admin-detail-container { max-width: 820px; }


/* Light mode */
:root.light-mode .chat-panel {
    background: rgba(255, 255, 255, 0.97);
    border-color: rgba(255, 45, 161, 0.2);
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15);
}

:root.light-mode .chat-panel-header {
    background: linear-gradient(135deg, rgba(255, 45, 161, 0.08), rgba(255, 0, 122, 0.04));
}

:root.light-mode .chat-header-name { color: #1a1a1a; }
:root.light-mode .chat-header-status { color: rgba(0,0,0,0.45); }

:root.light-mode .chat-message-bot .chat-bubble {
    background: rgba(0, 0, 0, 0.05);
    color: #1a1a1a;
    border-color: rgba(0,0,0,0.08);
}

:root.light-mode .chat-input {
    background: rgba(0,0,0,0.04);
    border-color: rgba(0,0,0,0.12);
    color: #1a1a1a;
}
:root.light-mode .chat-input::placeholder { color: rgba(0,0,0,0.35); }

:root.light-mode .chat-lookup-input {
    background: rgba(0,0,0,0.04);
    border-color: rgba(0,0,0,0.12);
    color: #1a1a1a;
}
:root.light-mode .chat-lookup-input::placeholder { color: rgba(0,0,0,0.35); }

:root.light-mode .chat-admin-msg-bubble {
    background: rgba(0,0,0,0.04);
    border-color: rgba(0,0,0,0.08);
    color: #1a1a1a;
}
:root.light-mode .chat-admin-msg-user .chat-admin-msg-bubble {
    background: rgba(255, 45, 161, 0.08);
    border-color: rgba(255, 45, 161, 0.2);
    color: #1a1a1a;
}
