/* ============================================================
   chat-widget.css — floating chat popup widget
   Included in: login page (via login.css) + dashboard (home.ejs)
   ============================================================ */

/* ── Float Button ── */
.chat-button {
    position: fixed;
    bottom: 30px;
    right: 24px;
    background: linear-gradient(135deg, #7c3aed, #9d4edd);
    color: white;
    border: none;
    padding: 0;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(124, 58, 237, 0.5);
    z-index: 9050;
    transition: all 0.3s ease;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-button i { font-size: 24px; line-height: 1; }

.chat-button:hover {
    background: linear-gradient(135deg, #6d28d9, #7c3aed);
    transform: scale(1.1);
    box-shadow: 0 8px 28px rgba(124, 58, 237, 0.6);
}
.chat-button:active { transform: scale(0.95); }

/* ── Popup Container: Form Mode (login-style glass card) ── */
#chat-popup {
    position: fixed;
    bottom: 100px;
    right: 24px;
    background: #ffffff;
    border: 1px solid #e4e4ee;
    width: 340px;
    max-height: 560px;
    display: flex;
    flex-direction: column;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(124, 58, 237, 0.18), 0 2px 8px rgba(0,0,0,0.08);
    overflow: hidden;
    z-index: 9051;
    transition: box-shadow 0.3s ease, background 0.3s ease;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* ── Chat Header ── */
#chat-popup .chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 13px 15px;
    background: linear-gradient(135deg, #7c3aed, #9d4edd);
    color: white;
    border-radius: 16px 16px 0 0;
    position: relative;
    flex-shrink: 0;
}

#chat-popup .chat-header h4 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.2px;
}

#chat-popup .right-section {
    display: flex;
    align-items: center;
    gap: 8px;
}

#chat-popup .online-status {
    display: flex;
    align-items: center;
    gap: 5px;
    background: rgba(255,255,255,0.18);
    padding: 3px 9px;
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.25);
}

#chat-popup .online-dot {
    width: 7px;
    height: 7px;
    background: #4ade80;
    border-radius: 50%;
    box-shadow: 0 0 6px rgba(74,222,128,0.9);
    animation: cwPulse 2s infinite;
}

@keyframes cwPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: 0.7; transform: scale(1.25); }
}

#chat-popup .online-text {
    font-size: 0.75rem;
    font-weight: 600;
    color: #d4f7dc;
}

#chat-popup .close-btn1 {
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.35);
    color: white;
    font-size: 18px;
    cursor: pointer;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.22s ease;
    font-weight: bold;
    line-height: 1;
    padding: 0;
}

#chat-popup .close-btn1:hover {
    background: rgba(239,68,68,0.9);
    border-color: transparent;
    transform: rotate(90deg);
}

/* ── Success Toast ── */
#chat-popup .chat-success-popup {
    position: absolute;
    top: 2px;
    left: 50%;
    transform: translateX(-50%);
    background: #16a34a;
    color: white;
    padding: 6px 16px;
    border-radius: 7px;
    font-size: 0.72rem;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(22,163,74,0.35);
    z-index: 1002;
    white-space: nowrap;
    animation: cwSlideDown 0.32s ease;
}

@keyframes cwSlideDown {
    from { opacity: 0; transform: translateX(-50%) translateY(-12px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── User Info wrapper ── */
#user-info { padding: 0; flex-shrink: 0; }

/* ── Guest Form: Login Page Style ── */
#user-form {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 18px 16px 14px;
    background: #ffffff;
}

#user-form label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: #2b2b3a;
    margin-bottom: 8px;
    letter-spacing: 0.1px;
}

#user-form input {
    width: 100%;
    padding: 13px 15px;
    background: #f7f7fb;
    border: 1px solid #e4e4ee;
    border-radius: 10px;
    font-size: 0.92rem;
    outline: none;
    color: #2b2b3a;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    box-sizing: border-box;
    margin-bottom: 6px;
}

#user-form input::placeholder { color: #8a8a9a; }

#user-form input:focus {
    border-color: #7c3aed;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(124,58,237,0.12);
}

/* Primary button — the login page's exact treatment: solid purple, 10px
   radius, weight 700, and a lift + purple shadow on hover. */
#user-form button {
    width: 100%;
    margin-top: 8px;
    padding: 14px 0;
    background: #7c3aed;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
    letter-spacing: 0.2px;
}

#user-form button:hover {
    background: #6d28d9;
    transform: translateY(-1px);
    box-shadow: 0 10px 22px rgba(124,58,237,0.28);
}
#user-form button:active { transform: translateY(0); box-shadow: none; }

/* ── Messages Area ── */
#chat-messages {
    flex: 1;
    max-height: 300px;
    overflow-y: auto;
    padding: 12px 10px;
    background: #f0f2f5;
    border-top: 1px solid #e4e4ee;
    border-bottom: 1px solid #e4e4ee;
    display: flex;
    flex-direction: column;
    gap: 8px;
    scroll-behavior: smooth;
}

/* Logged-in user strip */
#chat-logged-in-strip {
    padding: 10px 13px;
    background: #f8f9ff;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

/* Message Bubbles */
#chat-messages .message-bubble {
    padding: 9px 13px;
    border-radius: 12px;
    align-self: flex-start;
    word-break: break-word;
    max-width: 80%;
    font-size: 0.88rem;
    line-height: 1.45;
    background: #ffffff;
    border: 1px solid #e4e4ee;
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
    position: relative;
    opacity: 0;
    transform: translateY(8px);
    animation: cwFadeIn 0.35s forwards;
}

@keyframes cwFadeIn {
    to { opacity: 1; transform: translateY(0); }
}

#chat-messages .message-time {
    font-size: 0.65rem;
    color: #8a8a9a;
    margin-top: 3px;
    text-align: right;
}

#chat-messages::-webkit-scrollbar { width: 4px; }
#chat-messages::-webkit-scrollbar-track { background: transparent; }
#chat-messages::-webkit-scrollbar-thumb { background: #c4b5fd; border-radius: 10px; }

/* ── Chat Input ── */
#chat-form {
    display: flex !important;
    flex-direction: row !important;
    align-items: center;
    gap: 8px;
    padding: 11px 13px;
    background: #ffffff;
    border-top: 1px solid #e4e4ee;
    flex-wrap: nowrap;
    flex-shrink: 0;
}

#chat-form input[type="text"] {
    flex: 1 1 auto;
    min-width: 0;
    padding: 9px 13px;
    background: #f7f7fb;
    border: 1px solid #e4e4ee;
    border-radius: 20px;
    font-size: 0.88rem;
    outline: none;
    color: #2b2b3a;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-sizing: border-box;
}

#chat-form input[type="text"]::placeholder { color: #8a8a9a; }

#chat-form input[type="text"]:focus {
    border-color: #7c3aed;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(124,58,237,0.1);
}

#chat-form button[type="submit"] {
    flex: 0 0 38px;
    background: #7c3aed;
    border: none;
    color: white;
    padding: 0;
    margin: 0;
    border-radius: 50%;
    cursor: pointer;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, transform 0.15s ease;
    box-sizing: border-box;
}

#chat-form button[type="submit"] i { font-size: 15px; line-height: 1; pointer-events: none; }
#chat-form button[type="submit"]:hover { background: #6d28d9; transform: scale(1.08); }
#chat-form button[type="submit"]:active { transform: scale(0.94); }

/* ════════════════════════════════════════════════════════
   CHAT MODE — dashboard WhatsApp style (JS adds .chat-mode)
   ════════════════════════════════════════════════════════ */

#chat-popup.chat-mode {
    box-shadow: 0 4px 28px rgba(0,0,0,0.24);
    border: none;
}

#chat-popup.chat-mode .chat-header {
    background: #59079A;
    border-radius: 0;
}

#chat-popup.chat-mode #chat-messages {
    background: #E5DDD5;
    border-top: none;
    border-bottom: none;
}

#chat-popup.chat-mode .message-bubble {
    background: #fff;
    border: none;
    border-radius: 8px;
    border-bottom-left-radius: 2px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.12);
    color: #111;
}

#chat-popup.chat-mode .user-message {
    background: #128C7E !important;
    color: #fff !important;
    border: none !important;
    border-radius: 8px !important;
    border-bottom-right-radius: 2px !important;
    align-self: flex-end;
    margin-left: auto;
    box-shadow: 0 1px 2px rgba(0,0,0,0.14) !important;
}

#chat-popup.chat-mode .user-message .message-time { color: rgba(255,255,255,0.7) !important; }

#chat-popup.chat-mode .support-message {
    background: #fff !important;
    color: #111 !important;
    border: none !important;
    border-left: none !important;
    border-radius: 8px !important;
    border-bottom-left-radius: 2px !important;
}

#chat-popup.chat-mode .ai-message {
    background: #e8f5e9 !important;
    color: #1b5e20 !important;
    border: none !important;
    border-radius: 8px !important;
    border-bottom-left-radius: 2px !important;
    font-style: normal;
}

#chat-popup.chat-mode .message-time { color: rgba(0,0,0,0.45); }

#chat-popup.chat-mode #chat-messages::-webkit-scrollbar-thumb { background: #aaa; }

#chat-popup.chat-mode #chat-form {
    background: #f0f0f0;
    border-top: 1px solid #d5d5d5;
}

#chat-popup.chat-mode #chat-form input[type="text"] {
    background: #fff;
    border: none;
    border-radius: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    color: #111;
}

#chat-popup.chat-mode #chat-form input[type="text"]:focus {
    box-shadow: 0 0 0 2px #128C7E;
}

#chat-popup.chat-mode #chat-form button[type="submit"] { background: #128C7E; }
#chat-popup.chat-mode #chat-form button[type="submit"]:hover { background: #0e7368; }
