/* ===== LegacyCapitalTrades Live Chat System ===== */

/* === Chat Widget (Floating Button on Public Pages & Dashboard) === */
.chat-widget-btn {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #00C896, #00a87d);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 6px 24px rgba(0, 200, 150, 0.4);
    z-index: 9999;
    transition: all 0.3s ease;
    border: none;
    color: #fff;
    font-size: 24px;
}
.chat-widget-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 8px 32px rgba(0, 200, 150, 0.5);
}
.chat-widget-btn .badge-dot {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 14px;
    height: 14px;
    background: #FF4D4F;
    border-radius: 50%;
    border: 2px solid #0F172A;
    font-size: 0;
}
.chat-widget-btn .online-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    background: #00C896;
    border-radius: 50%;
    border: 2px solid #0F172A;
}

/* === Chat Widget Window === */
.chat-widget-window {
    position: fixed;
    bottom: 100px;
    right: 28px;
    width: 380px;
    height: 520px;
    background: #1a2540;
    border: 1px solid #2a3a5c;
    border-radius: 16px;
    display: none;
    flex-direction: column;
    z-index: 9998;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    animation: chatSlideUp 0.3s ease;
}
.chat-widget-window.open {
    display: flex;
}
@keyframes chatSlideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-widget-header {
    background: linear-gradient(135deg, #0B1F3B, #1E4D8C);
    padding: 18px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #2a3a5c;
}
.chat-widget-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}
.chat-widget-avatar {
    width: 40px;
    height: 40px;
    background: rgba(0, 200, 150, 0.15);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}
.chat-widget-name {
    font-weight: 600;
    font-size: 15px;
    color: #fff;
}
.chat-widget-status {
    font-size: 12px;
    color: #00C896;
    display: flex;
    align-items: center;
    gap: 4px;
}
.chat-widget-status .dot {
    width: 6px;
    height: 6px;
    background: #00C896;
    border-radius: 50%;
    display: inline-block;
}
.chat-widget-status.offline .dot { background: #64748b; }
.chat-widget-status.offline { color: #64748b; }
.chat-widget-close {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: 0.2s;
}
.chat-widget-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

/* Chat Messages Area */
.chat-widget-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.chat-widget-messages::-webkit-scrollbar { width: 4px; }
.chat-widget-messages::-webkit-scrollbar-thumb { background: #2a3a5c; border-radius: 2px; }

.chat-msg {
    max-width: 85%;
    display: flex;
    flex-direction: column;
    animation: msgFade 0.3s ease;
}
@keyframes msgFade {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.chat-msg.user { align-self: flex-end; }
.chat-msg.admin, .chat-msg.system { align-self: flex-start; }
.chat-msg-bubble {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.6;
    word-wrap: break-word;
}
.chat-msg.user .chat-msg-bubble {
    background: #00C896;
    color: #0B1F3B;
    border-bottom-right-radius: 4px;
}
.chat-msg.admin .chat-msg-bubble {
    background: #1E4D8C;
    color: #fff;
    border-bottom-left-radius: 4px;
}
.chat-msg.system .chat-msg-bubble {
    background: rgba(255, 255, 255, 0.05);
    color: #64748b;
    font-size: 12px;
    text-align: center;
    font-style: italic;
}
.chat-msg-time {
    font-size: 10px;
    color: #64748b;
    margin-top: 4px;
    padding: 0 4px;
}
.chat-msg.user .chat-msg-time { text-align: right; }

/* Chat Input */
.chat-widget-input {
    padding: 12px 16px;
    border-top: 1px solid #2a3a5c;
    display: flex;
    gap: 10px;
    align-items: center;
    background: #0F172A;
}
.chat-widget-input input {
    flex: 1;
    background: #1a2540;
    border: 1px solid #2a3a5c;
    border-radius: 8px;
    padding: 10px 14px;
    color: #fff;
    font-size: 13px;
    font-family: 'Inter', sans-serif;
    outline: none;
    transition: 0.2s;
}
.chat-widget-input input:focus { border-color: #00C896; }
.chat-widget-input input::placeholder { color: #64748b; }
.chat-widget-send {
    width: 40px;
    height: 40px;
    background: #00C896;
    border: none;
    border-radius: 8px;
    color: #0B1F3B;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
    flex-shrink: 0;
}
.chat-widget-send:hover { background: #00e6ad; }
.chat-widget-send:disabled {
    background: #2a3a5c;
    color: #64748b;
    cursor: not-allowed;
}

/* Pre-chat form */
.chat-prechat {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 28px 24px;
}
.chat-prechat h3 {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 6px;
    color: #fff;
}
.chat-prechat p {
    font-size: 13px;
    color: #94a3b8;
    margin-bottom: 20px;
    line-height: 1.6;
}
.chat-prechat .form-group { margin-bottom: 14px; }
.chat-prechat label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: #94a3b8;
    margin-bottom: 5px;
}
.chat-prechat input, .chat-prechat textarea {
    width: 100%;
    padding: 10px 12px;
    background: #0F172A;
    border: 1px solid #2a3a5c;
    border-radius: 8px;
    color: #fff;
    font-size: 13px;
    font-family: 'Inter', sans-serif;
    outline: none;
}
.chat-prechat input:focus, .chat-prechat textarea:focus { border-color: #00C896; }
.chat-prechat textarea { min-height: 60px; resize: none; }

/* Typing indicator */
.typing-indicator {
    display: none;
    align-self: flex-start;
    padding: 8px 14px;
    background: #1E4D8C;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
}
.typing-indicator.show { display: block; }
.typing-dots {
    display: flex;
    gap: 4px;
    align-items: center;
}
.typing-dots span {
    width: 6px;
    height: 6px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-4px); }
}

/* =====================================================
   === ADMIN CHAT PAGE LAYOUT (admin/chat.php only) ===
   ===================================================== */

/*
 * .dash-layout  = flex row  (sidebar 260px | .dash-main fills rest)
 * .dash-main    = flex col  (dash-header | admin-chat-layout fills rest)
 * .admin-chat-layout = flex row (conv-list 300px | messages | user-panel)
 */

.admin-chat-layout {
    display: flex;           /* ← was grid, now flex */
    flex: 1 1 0;
    min-height: 0;           /* lets it shrink inside flex parent */
    overflow: hidden;
    /* no fixed height — inherits from .dash-main flex column */
}

/* ── Left: conversation list ── */
.chat-sidebar {
    width: 300px;
    min-width: 260px;
    flex-shrink: 0;
    background: #0B1F3B;
    border-right: 1px solid #2a3a5c;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.chat-sidebar-header {
    padding: 18px 20px;
    border-bottom: 1px solid #2a3a5c;
    flex-shrink: 0;
}
.chat-sidebar-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    margin-bottom: 12px;
}
.chat-search {
    width: 100%;
    padding: 9px 12px;
    background: #1a2540;
    border: 1px solid #2a3a5c;
    border-radius: 8px;
    color: #fff;
    font-size: 13px;
    outline: none;
    font-family: 'Inter', sans-serif;
    box-sizing: border-box;
}
.chat-search:focus { border-color: #00C896; }
.chat-search::placeholder { color: #64748b; }

.chat-list {
    flex: 1 1 0;
    overflow-y: auto;
    list-style: none;
    margin: 0;
    padding: 0;
}
.chat-list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    cursor: pointer;
    transition: 0.15s;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    position: relative;
}
.chat-list-item:hover { background: rgba(255, 255, 255, 0.03); }
.chat-list-item.active {
    background: rgba(0, 200, 150, 0.08);
    border-left: 3px solid #00C896;
}
.chat-list-item.unread::after {
    content: '';
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 8px;
    height: 8px;
    background: #00C896;
    border-radius: 50%;
}
.chat-list-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #1E4D8C;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 15px;
    color: #fff;
    flex-shrink: 0;
}
.chat-list-info { flex: 1; min-width: 0; }
.chat-list-name {
    font-weight: 600;
    font-size: 14px;
    color: #fff;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-list-preview {
    font-size: 12px;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-list-time {
    font-size: 11px;
    color: #64748b;
    flex-shrink: 0;
}
.chat-list-status {
    display: flex;
    align-items: center;
    gap: 4px;
}
.chat-list-status .status-badge {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}
.status-badge.waiting { background: rgba(251,191,36,.15); color: #fbbf24; }
.status-badge.active  { background: rgba(0,200,150,.15);  color: #00C896; }
.status-badge.closed  { background: rgba(148,163,184,.15); color: #94a3b8; }

/* ── Centre: message area ── */
.chat-main {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: #0F172A;
    overflow: hidden;
}
.chat-main-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #64748b;
}
.chat-main-empty .icon { font-size: 64px; margin-bottom: 16px; opacity: 0.3; }
.chat-main-empty h3 { font-size: 18px; font-weight: 600; color: #94a3b8; margin-bottom: 6px; }
.chat-main-empty p { font-size: 13px; }

.chat-main-header {
    padding: 16px 24px;
    border-bottom: 1px solid #2a3a5c;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(11, 31, 59, 0.8);
    flex-shrink: 0;
}
.chat-main-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}
.chat-main-header-name { font-weight: 600; font-size: 15px; color: #fff; }
.chat-main-header-email { font-size: 12px; color: #64748b; }
.chat-main-header-actions { display: flex; gap: 8px; }

.chat-main-messages {
    flex: 1 1 0;
    overflow-y: auto;
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
}

/* Quick Replies */
.quick-replies {
    padding: 8px 24px;
    border-top: 1px solid #2a3a5c;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    background: rgba(11, 31, 59, 0.5);
    flex-shrink: 0;
}
.quick-reply-btn {
    padding: 6px 14px;
    background: rgba(30, 77, 140, 0.4);
    border: 1px solid #2a3a5c;
    border-radius: 20px;
    color: #94a3b8;
    font-size: 12px;
    cursor: pointer;
    transition: 0.2s;
    font-family: 'Inter', sans-serif;
}
.quick-reply-btn:hover {
    background: rgba(0, 200, 150, 0.15);
    border-color: #00C896;
    color: #00C896;
}

/* Chat Input */
.chat-main-input {
    padding: 16px 24px;
    border-top: 1px solid #2a3a5c;
    display: flex;
    gap: 12px;
    align-items: flex-end;
    background: #0B1F3B;
    flex-shrink: 0;
}
.chat-main-input textarea {
    flex: 1;
    background: #1a2540;
    border: 1px solid #2a3a5c;
    border-radius: 10px;
    padding: 12px 16px;
    color: #fff;
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    outline: none;
    resize: none;
    min-height: 44px;
    max-height: 120px;
    transition: 0.2s;
}
.chat-main-input textarea:focus { border-color: #00C896; }
.chat-main-input textarea::placeholder { color: #64748b; }
.chat-main-send {
    width: 44px;
    height: 44px;
    background: #00C896;
    border: none;
    border-radius: 10px;
    color: #0B1F3B;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
    flex-shrink: 0;
}
.chat-main-send:hover { background: #00e6ad; }

/* ── Right: user info panel ── */
.chat-user-panel {
    width: 260px;
    min-width: 220px;
    flex-shrink: 0;
    background: #0B1F3B;
    border-left: 1px solid #2a3a5c;
    padding: 24px;
    overflow-y: auto;
    box-sizing: border-box;
}
.chat-user-panel h4 {
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    margin-bottom: 16px;
}
.chat-user-detail { margin-bottom: 12px; }
.chat-user-detail label {
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: block;
    margin-bottom: 3px;
}
.chat-user-detail span { font-size: 14px; color: #94a3b8; }

/* ── Responsive ── */
@media (max-width: 768px) {
    .chat-widget-window {
        width: calc(100% - 24px);
        right: 12px;
        bottom: 80px;
        height: 70vh;
    }
    .admin-chat-layout {
        flex-direction: column;
    }
    .chat-sidebar {
        width: 100%;
        min-width: 0;
        height: 200px;
        flex-shrink: 0;
    }
    .chat-user-panel { display: none; }
}