/* ============================================================
   Chat Page Styles — extracted from pages/home.py
   Loaded via <link> in home.py to keep CSS out of Python code.
   ============================================================ */

/* Chat bubble avatar should never distort */
.q-message-avatar {
    object-fit: contain !important;
    border-radius: 0 !important;
}

/* Consistent bubble shape & shadow */
.q-message-text {
    position: relative !important;
    overflow: visible !important;
    border-radius: 12px !important;
    padding: 18px 24px !important;
    line-height: 1.6 !important;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.05);
}
.q-message-stamp {
    font-size: 0.75rem !important;
    color: inherit !important;
    opacity: 0.75;
    margin-top: 4px !important;
}

/* Markdown content inside chat bubbles */
.markdown-content h3 {
    font-size: 1.3rem !important;
    font-weight: 800 !important;
    margin-top: 1rem !important;
    margin-bottom: 0.75rem !important;
    color: inherit !important;
    line-height: 1.3 !important;
}
.markdown-content ul {
    padding-left: 1.5rem !important;
    margin-top: 0.5rem !important;
    margin-bottom: 1rem !important;
    list-style-type: disc !important;
}
.markdown-content li  { margin-bottom: 0.5rem !important; }
.markdown-content p   { margin-bottom: 1rem !important; }
.markdown-content p:last-child { margin-bottom: 0 !important; }
.markdown-content strong { font-weight: 700 !important; }

/* Typing indicator dots */
.typing-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 1.5rem;
}
.typing-indicator span {
    display: inline-block;
    width: 8px;
    height: 8px;
    background-color: #80aedb;
    border-radius: 50%;
    margin: 0 2px;
    animation: bounce 1.4s infinite ease-in-out both;
}
.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }
@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40%           { transform: scale(1); }
}

/* Touch-device optimisations */
/* touch-action: manipulation is now set globally in happyly.css */
*    { -webkit-tap-highlight-color: transparent; }
.no-select {
    -webkit-touch-callout: none;
    user-select: none;
}

/* Disable hover effects on touch-only devices to avoid "sticky" pressed states */
@media (hover: none) {
    .hover\:bg-blue-500:hover   { background-color: inherit !important; color: inherit !important; }
    .hover\:text-blue-500:hover { color: inherit !important; }
    .hover\:bg-slate-50:hover   { background-color: inherit !important; }
}

/* Chat container scrollbar hiding */
.hide-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }
.hide-scrollbar::-webkit-scrollbar { display: none; }

/* Smooth entry animation for new chat bubbles */
@keyframes message-pop {
    0%   { opacity: 0; transform: translateY(12px) scale(0.98); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}
.msg-enter-anim {
    animation: message-pop 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* U-17: Subtle press feedback for suggestion buttons on touch devices */
.suggestion-tap {
    transition: transform 0.1s ease-out;
    -webkit-tap-highlight-color: rgba(0,0,0,0.03);
}
.suggestion-tap:active {
    transform: scale(0.97);
}

/* ============================================================
   Conversation Map — mobile bottom sheet for chat navigation
   ============================================================ */

/* Quasar dialog backdrop — subtle dark overlay consistent with the app's soft aesthetic.
   z-index is kept below Quasar's left drawer (~6000) so the sidebar always appears on top. */
.conversation-map-dialog {
    z-index: 5000 !important;
}
.conversation-map-dialog .q-dialog__backdrop {
    background: rgba(15, 23, 42, 0.3) !important;
    backdrop-filter: blur(2px);
}

/* Prevent the page behind the sheet from scrolling when the user swipes
   inside the conversation map on touch devices. overscroll-behavior:contain
   stops scroll-chaining at the sheet boundary. */
.conversation-map-dialog .q-card {
    overscroll-behavior: contain;
    touch-action: pan-y;
}

/* Line-clamp utility: truncate text to 2 lines with ellipsis.
   -webkit-line-clamp is the only reliable cross-browser approach for
   multi-line text truncation as of 2026. */
.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- "You are here" highlight system ---
   iOS Safari defers main-thread paint operations (background-color, border-color)
   during momentum scrolling, which causes the highlight to disappear while
   the user scrolls the chat behind the open Conversation Map.

   The fix: use a ::before pseudo-element whose visibility is controlled via
   `opacity`. opacity is a COMPOSITOR-LEVEL property — iOS renders opacity
   changes immediately even during momentum scroll, unlike background-color
   which requires a main-thread repaint that iOS defers.

   The pseudo-element sits behind the row content (z-index: -1) and provides
   both the blue tint background and the left accent border. */

.conv-map-row {
    position: relative;
    border-left: 3px solid transparent;
    transition: border-left-color 350ms ease-out;
}

/* The highlight layer — always present but invisible (opacity: 0).
   will-change:opacity tells the browser to keep this on its own compositing
   layer so opacity changes render at the compositor level, not paint level. */
.conv-map-row::before {
    content: '';
    position: absolute;
    inset: 0;
    background-color: rgba(219, 234, 254, 0.6);  /* blue-100 at 60% */
    border-left: 3px solid #3b82f6;               /* blue-500 accent */
    border-radius: inherit;
    opacity: 0;
    transition: opacity 350ms ease-out;
    will-change: opacity;
    pointer-events: none;
    z-index: 0;
}

/* When active, the pseudo-element fades in via opacity (compositor-friendly).
   The border-left on the row itself also transitions to blue for consistency. */
.conv-map-row-active::before {
    opacity: 1;
}
.conv-map-row-active {
    border-left-color: transparent;  /* hide row's own border; pseudo has its own */
}
