/**
 * Frontend Live Chat - Styles
 * Handles the visual appearance for the end-user chat interface.
 */
.bg-chat { background-color: #f8f9fa; }
.chat-bubble { max-width: 85%; padding: 10px 14px; border-radius: 1rem; position: relative; box-shadow: 0 2px 4px rgba(0,0,0,0.05); word-break: break-word; }
.chat-bubble-customer { background-color: #007bff; color: white; border-bottom-right-radius: 0.2rem; }
.chat-bubble-agent { background-color: white; border: 1px solid #dee2e6; border-bottom-left-radius: 0.2rem; }

/* Sticker, Emoji, Voice */
.sticker-panel, .emoji-panel {
    position: absolute; bottom: 100%; left: 0; right: 0;
    background: #fff; border-top: 1px solid #ddd;
    display: none; grid-template-columns: repeat(8, 1fr);
    padding: 10px; gap: 5px; max-height: 200px; overflow-y: auto;
    z-index: 100; box-shadow: 0 -5px 15px rgba(0,0,0,0.05);
}
.sticker-panel { grid-template-columns: repeat(4, 1fr); gap: 10px; }
.sticker-item, .emoji-item {
    cursor: pointer; font-size: 22px; text-align: center;
    padding: 5px; border-radius: 5px; transition: background 0.2s;
}
.sticker-item:hover, .emoji-item:hover { background: #f0f0f0; }
.sticker-img { width: 60px; height: 60px; object-fit: contain; }
.sticker-img-large { width: 100px; height: 100px; }
.chat-bubble-sticker { background: transparent !important; border: none !important; padding: 0 !important; box-shadow: none !important; }
.voice-record-btn.recording { color: #dc3545 !important; animation: pulse-red 1.5s infinite; }
@keyframes pulse-red { 0% { opacity: 1; } 50% { opacity: 0.5; } 100% { opacity: 1; } }
.audio-player { min-width: 160px; display: flex; align-items: center; }

.history-item { padding: 15px; border-bottom: 1px solid #eee; cursor: pointer; transition: 0.2s; }
.history-item:hover { background: #f0f0f0; }
.history-item.active { border-left: 4px solid #007bff; background: #eef6ff; }
.history-item-title { font-weight: bold; font-size: 0.9rem; }
.history-item-date { font-size: 0.75rem; color: #888; }
.status-dot { width: 12px; height: 12px; border-radius: 50%; position: absolute; bottom: 0; right: 0; border: 2px solid white; }
.status-online { background-color: #28a745; }
.status-offline { background-color: #6c757d; }
.avatar-container { position: relative; }

/* Typing Dots */
.typing-dot { display: inline-block; width: 4px; height: 4px; border-radius: 50%; background: #007bff; margin-right: 2px; animation: typing 1s infinite ease-in-out; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }

/* ============================================================
   MOBILE RESPONSIVE - Visitor Chat
   ============================================================ */

/* Desktop: history panel is a normal flex column */
@media (min-width: 768px) {
    #historyPanel { display: flex; flex-direction: column; }
    #historyOverlay { display: none !important; }
    #btnToggleHistory { display: none !important; }
}

/* Mobile: history panel hidden by default, slides in as overlay */
@media (max-width: 767.98px) {
    /* Override the fixed 700px card height */
    .card[style*="height: 700px"] {
        height: calc(100dvh - 140px) !important;
        border-radius: 0.5rem !important;
    }

    /* History panel: hidden by default */
    #historyPanel {
        display: none;
        position: absolute;
        top: 0;
        left: 0;
        height: 100%;
        width: 85%;
        max-width: 320px;
        z-index: 1050;
        transform: translateX(-110%);
        transition: transform 0.3s ease;
        flex-direction: column;
        box-shadow: 4px 0 16px rgba(0,0,0,0.15);
    }

    /* When open: show and slide in */
    #historyPanel.show {
        display: flex;
        transform: translateX(0);
    }

    /* Overlay behind the history panel */
    #historyOverlay {
        display: none;
        position: absolute;
        inset: 0;
        background: rgba(0,0,0,0.25);
        z-index: 1040;
    }
    #historyOverlay.show { display: block; }

    /* Chat bubbles wider on small screens */
    .chat-bubble { max-width: 90%; }

    /* Shrink sticker/emoji grids */
    .sticker-panel { grid-template-columns: repeat(3, 1fr); }
    .emoji-panel { grid-template-columns: repeat(6, 1fr); }
    .sticker-img { width: 48px; height: 48px; }
    .sticker-img-large { width: 80px; height: 80px; }

    /* Audio player full-width */
    .audio-player audio { width: 100%; }
}

/* Container padding reduction on very small screens */
@media (max-width: 575.98px) {
    .container-xl { padding-left: 8px; padding-right: 8px; }
    .py-5 { padding-top: 1rem !important; padding-bottom: 1rem !important; }
}
