/* ═══════════════════════════════════════════════════════════
   chat-widget.css — iDLock AuthN Chat Widget
   WhatsApp-style, dark mode, premium animations
═══════════════════════════════════════════════════════════ */

/* ── Floating trigger button ── */
#chatTrigger {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 9000;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(37, 99, 235, 0.5);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    outline: none;
}
#chatTrigger:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(37, 99, 235, 0.65);
}
#chatTrigger:active { transform: scale(0.96); }
#chatTrigger svg { width: 28px; height: 28px; fill: #fff; }

/* Pulse ring animation */
#chatTrigger::before {
    content: '';
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 2px solid rgba(37, 99, 235, 0.4);
    animation: chatPulse 2s ease-out infinite;
}
@keyframes chatPulse {
    0%   { transform: scale(1); opacity: 0.8; }
    100% { transform: scale(1.5); opacity: 0; }
}

/* Notification badge */
#chatBadge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--bg-primary, #0f172a);
    animation: badgePop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes badgePop {
    from { transform: scale(0); }
    to   { transform: scale(1); }
}

/* ── Backdrop overlay ── */
#chatOverlay {
    position: fixed;
    inset: 0;
    z-index: 8999;
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
#chatOverlay.chat--open {
    opacity: 1;
    pointer-events: all;
}

/* ── Chat panel ── */
#chatPanel {
    position: fixed;
    bottom: 100px;
    right: 28px;
    z-index: 9001;
    width: 370px;
    max-height: 580px;
    display: flex;
    flex-direction: column;
    background: #1a2332;
    border-radius: 20px;
    box-shadow:
        0 25px 60px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.06);
    overflow: hidden;
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
                opacity 0.25s ease;
}
#chatPanel.chat--open {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: all;
}

/* Mobile */
@media (max-width: 450px) {
    #chatPanel {
        right: 12px;
        left: 12px;
        width: auto;
        bottom: 90px;
        max-height: calc(100dvh - 120px);
    }
    #chatTrigger { right: 16px; bottom: 20px; }
}

/* ── Header ── */
#chatHeader {
    background: linear-gradient(135deg, #1e3a5f, #1a2d4a);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.07);
    flex-shrink: 0;
}
.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(37,99,235,0.4);
}
.chat-avatar img { width: 24px; height: 24px; }
.chat-header-info { flex: 1; }
.chat-header-name {
    font-size: 14px;
    font-weight: 700;
    color: #f1f5f9;
    line-height: 1.2;
}
.chat-header-status {
    font-size: 11px;
    color: #64ffb4;
    display: flex;
    align-items: center;
    gap: 4px;
}
.chat-header-status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #64ffb4;
    animation: onlinePulse 2s ease-in-out infinite;
}
@keyframes onlinePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}
#chatClose {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    display: flex;
    transition: color 0.2s, background 0.2s;
}
#chatClose:hover { color: #f1f5f9; background: rgba(255,255,255,0.08); }
#chatClose svg { width: 18px; height: 18px; }

/* ── Messages area ── */
#chatMessages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    scroll-behavior: smooth;
    background:
        radial-gradient(ellipse at top, rgba(37,99,235,0.06) 0%, transparent 60%),
        #111827;
}
#chatMessages::-webkit-scrollbar { width: 4px; }
#chatMessages::-webkit-scrollbar-track { background: transparent; }
#chatMessages::-webkit-scrollbar-thumb { background: #334155; border-radius: 4px; }

/* ── Message bubbles ── */
.chat-msg {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: 88%;
    animation: msgSlideIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes msgSlideIn {
    from { opacity: 0; transform: translateY(12px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Bot messages — left */
.chat-msg.bot { align-self: flex-start; }
.chat-msg.bot .chat-bubble {
    background: #1e293b;
    color: #e2e8f0;
    border-radius: 18px 18px 18px 4px;
    border: 1px solid rgba(255,255,255,0.06);
}

/* User messages — right */
.chat-msg.user { align-self: flex-end; flex-direction: row-reverse; }
.chat-msg.user .chat-bubble {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #fff;
    border-radius: 18px 18px 4px 18px;
}

.chat-bubble {
    padding: 10px 14px;
    font-size: 13.5px;
    line-height: 1.55;
    word-break: break-word;
    position: relative;
    max-width: 100%;
}
.chat-bubble strong { font-weight: 700; }

/* Timestamp inside bubble */
.chat-time {
    font-size: 10px;
    opacity: 0.55;
    display: block;
    text-align: right;
    margin-top: 4px;
}

/* ── Typing indicator ── */
.chat-msg.typing .chat-bubble {
    padding: 12px 16px;
    background: #1e293b;
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 18px 18px 18px 4px;
}
.chat-typing-dots {
    display: flex;
    gap: 4px;
    align-items: center;
    height: 14px;
}
.chat-typing-dots span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #64748b;
    animation: typingBounce 1.2s ease-in-out infinite;
}
.chat-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30%           { transform: translateY(-6px); opacity: 1; }
}

/* ── Audio player bubble ── */
.chat-audio-player {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 2px 0 4px;
    min-width: 180px;
}
.chat-audio-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(37,99,235,0.25);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s;
}
.chat-audio-btn:hover { background: rgba(37,99,235,0.45); }
.chat-audio-btn svg { width: 16px; height: 16px; fill: #60a5fa; }
.chat-audio-waveform {
    flex: 1;
    height: 28px;
    display: flex;
    align-items: center;
    gap: 2px;
}
.chat-audio-waveform span {
    flex: 1;
    background: rgba(96,165,250,0.35);
    border-radius: 2px;
    transition: height 0.1s;
}
.chat-audio-waveform.playing span {
    animation: waveAnim var(--d, 0.6s) ease-in-out infinite alternate;
}
@keyframes waveAnim {
    from { height: 4px; }
    to   { height: var(--h, 20px); }
}
.chat-audio-duration {
    font-size: 11px;
    color: #64748b;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ── Options / buttons ── */
.chat-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 4px 0 8px;
    align-self: flex-start;
    margin-left: 14px;
    animation: msgSlideIn 0.3s ease;
}
.chat-option-btn {
    background: transparent;
    border: 1.5px solid #2563eb;
    color: #60a5fa;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, transform 0.15s;
    white-space: nowrap;
}
.chat-option-btn:hover {
    background: #2563eb;
    color: #fff;
    transform: translateY(-1px);
}
.chat-option-btn:active { transform: scale(0.96); }
.chat-option-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

/* ── CTA buttons ── */
.chat-cta-area {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-self: flex-start;
    margin-left: 14px;
    width: calc(100% - 28px);
    animation: msgSlideIn 0.4s ease;
}
.chat-cta-btn {
    display: block;
    text-align: center;
    padding: 12px 20px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
    transition: opacity 0.2s, transform 0.15s;
    cursor: pointer;
    border: none;
}
.chat-cta-btn:hover { opacity: 0.88; transform: translateY(-1px); }
.chat-cta-btn.primary {
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff;
}
.chat-cta-btn.secondary {
    background: rgba(37,99,235,0.15);
    border: 1.5px solid #2563eb;
    color: #60a5fa;
}

/* ── Input area ── */
#chatInputArea {
    padding: 10px 12px;
    background: #1a2332;
    border-top: 1px solid rgba(255,255,255,0.07);
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}
#chatInput {
    flex: 1;
    background: #111827;
    border: 1.5px solid #334155;
    border-radius: 22px;
    padding: 10px 16px;
    color: #f1f5f9;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}
#chatInput::placeholder { color: #475569; }
#chatInput:focus { border-color: #2563eb; }
#chatSendBtn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.15s, opacity 0.2s;
}
#chatSendBtn:hover { transform: scale(1.08); }
#chatSendBtn:active { transform: scale(0.94); }
#chatSendBtn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
#chatSendBtn svg { width: 18px; height: 18px; fill: #fff; }

/* ── Date separator ── */
.chat-date-sep {
    text-align: center;
    font-size: 11px;
    color: #475569;
    margin: 8px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}
.chat-date-sep::before,
.chat-date-sep::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(255,255,255,0.06);
}
