/* SaveBite – Chat Drawer UI */

/* Chat List Wrapper */
#chat-list-wrapper { display: flex; flex-direction: column; height: 100%; gap: 0.75rem; }
.chat-list-view { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 1rem; }

/* Chat Search Bar */
.chat-search-bar { display: flex; align-items: center; gap: 0.6rem; background: rgba(14,14,16,.04); border: 1px solid rgba(14,14,16,.1); border-radius: 50px; padding: 0.5rem 1rem; flex-shrink: 0; transition: var(--transition); }
.chat-search-bar:focus-within { border-color: var(--primary); }
.chat-search-icon { width: 15px; height: 15px; color: var(--text-muted); flex-shrink: 0; }
#chat-search-input { background: transparent; border: none; outline: none; color: var(--text-main); font-size: 0.85rem; width: 100%; }
#chat-search-input::placeholder { color: var(--text-muted); }

.chat-item { background: #FFFFFF; border: 1px solid rgba(14,14,16,.09); border-radius: var(--radius-md); padding: 1rem; display: flex; align-items: center; gap: 0.75rem; cursor: pointer; transition: var(--transition); }
.chat-item:hover { background: rgba(14,14,16,.04); border-color: var(--primary); }
.chat-item.unread { border-left: 3px solid var(--primary); background: rgba(16,185,129,0.03); }

.chat-item-avatar  { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; }
.chat-item-content { flex-grow: 1; }
.chat-item-header  { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.25rem; }
.chat-item-name    { font-weight: 700; font-size: 0.95rem; }
.chat-item-time    { font-size: 0.75rem; color: var(--text-muted); }
.chat-item-msg     { font-size: 0.82rem; color: var(--text-muted); display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; text-overflow: ellipsis; }
.chat-item.unread .chat-item-msg { color: var(--text-main); font-weight: 500; }
.chat-item-unread-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 2px rgba(16,185,129,0.25); flex-shrink: 0; }

.chat-item-delete-btn { background: transparent; border: none; color: var(--text-muted); padding: 0.4rem; border-radius: 50%; cursor: pointer; flex-shrink: 0; display: flex; align-items: center; justify-content: center; transition: var(--transition); }
.chat-item-delete-btn:hover { background: rgba(239,68,68,0.12); color: #ef4444; }
.chat-item-delete-btn i { width: 16px; height: 16px; }

/* Chat search – user suggestion results */
.chat-search-section-label { font-size: 0.72rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; padding: 0.5rem 0.25rem 0.4rem; }
.chat-search-users-loading { display: flex; align-items: center; gap: 0.5rem; font-size: 0.83rem; color: var(--text-muted); padding: 0.5rem 0.25rem; }
@keyframes spin { to { transform: rotate(360deg); } }

.chat-user-suggestion { display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem; border-radius: var(--radius-md); cursor: pointer; transition: var(--transition); background: #FFFFFF; border: 1px solid rgba(14,14,16,.08); margin-bottom: 0.5rem; }
.chat-user-suggestion:hover { background: rgba(16,185,129,0.04); border-color: var(--primary); }
.chat-user-suggestion-avatar { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.chat-user-suggestion-info { flex: 1; min-width: 0; }
.chat-user-suggestion-name { font-weight: 600; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-user-suggestion-rating { display: flex; align-items: center; gap: 0.25rem; font-size: 0.78rem; color: var(--text-muted); margin-top: 0.15rem; }

[data-theme="dark"] .chat-user-suggestion { background: rgba(30,41,59,0.6); border-color: rgba(255,255,255,0.07); }
[data-theme="dark"] .chat-user-suggestion:hover { background: rgba(30,41,59,0.85); }

/* Empty state for the embedded two-pane (dashboard) layout */
.chat-empty-state { display: none; flex-direction: column; align-items: center; justify-content: center; height: 100%; color: var(--text-muted); text-align: center; gap: 0.75rem; }
.chat-empty-state i { width: 48px; height: 48px; opacity: 0.4; }

/* Active Chat Screen */
.active-chat-view { display: flex; flex-direction: column; height: 100%; }
.chat-back-btn { align-self: flex-start; background: transparent; border: none; color: var(--primary); font-weight: 600; font-size: 0.85rem; cursor: pointer; display: flex; align-items: center; gap: 0.25rem; margin-bottom: 1rem; }

.chat-active-partner { display: flex; align-items: center; gap: 0.75rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border-color); margin-bottom: 1rem; }
.chat-partner-avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.chat-partner-name   { font-weight: 700; font-size: 1rem; }
.chat-partner-item   { font-size: 0.78rem; color: var(--text-muted); }
.chat-partner-item span { color: var(--primary); font-weight: 600; }
.chat-food-link { cursor: pointer; display: inline-flex; align-items: center; gap: 0.3rem; user-select: none; }
.chat-food-link:hover span { text-decoration: underline; }
#food-preview-chevron { width: 12px; height: 12px; color: var(--primary); transition: transform 0.2s ease; flex-shrink: 0; }

/* Food Post Preview Card */
.chat-food-preview-card { background: #FFFFFF; border: 1px solid rgba(14,14,16,.09); border-radius: var(--radius-md); margin-bottom: 0.75rem; overflow: hidden; animation: chatPreviewSlideDown 0.18s ease; }
@keyframes chatPreviewSlideDown { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
.chat-food-preview-inner { display: flex; gap: 0.75rem; padding: 0.75rem; }
.chat-food-preview-img { width: 72px; height: 72px; object-fit: cover; border-radius: var(--radius-sm); flex-shrink: 0; }
.chat-food-preview-body { flex: 1; min-width: 0; }
.chat-food-preview-title { font-weight: 700; font-size: 0.88rem; color: var(--text-main); margin-bottom: 0.3rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-food-preview-tags { display: flex; gap: 0.3rem; flex-wrap: wrap; margin-bottom: 0.3rem; }
.chat-food-tag { font-size: 0.68rem; padding: 0.12rem 0.45rem; border-radius: 50px; font-weight: 600; background: rgba(14,14,16,.06); color: var(--text-muted); }
.chat-food-tag.free  { background: rgba(16,185,129,0.15); color: var(--primary); }
.chat-food-tag.price { background: rgba(245,158,11,0.15); color: #f59e0b; }
.chat-food-preview-addr { font-size: 0.73rem; color: var(--text-muted); margin-bottom: 0.2rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-food-preview-exp  { font-size: 0.7rem; color: var(--text-muted); margin-bottom: 0.45rem; }
.chat-food-preview-btn  { background: var(--primary); color: white; border: none; border-radius: var(--radius-sm); padding: 0.28rem 0.7rem; font-size: 0.73rem; font-weight: 600; cursor: pointer; transition: var(--transition); }
.chat-food-preview-btn:hover { background: var(--primary-hover); }
.chat-food-preview-minimal { padding: 0.75rem; }
.chat-food-preview-minimal .chat-food-preview-title { margin-bottom: 0.25rem; }
.chat-food-preview-note { font-size: 0.76rem; color: var(--text-muted); font-style: italic; }

/* Messages */
.chat-messages-container { flex-grow: 1; overflow-y: auto; padding: 0.5rem; display: flex; flex-direction: column; gap: 1rem; margin-bottom: 1rem; }
.chat-msg-bubble { max-width: 75%; padding: 0.75rem 1rem; border-radius: var(--radius-md); font-size: 0.88rem; line-height: 1.4; word-break: break-word; }
.chat-msg-bubble.received { align-self: flex-start; background: rgba(14,14,16,.07); border: 1px solid rgba(14,14,16,.09); border-bottom-left-radius: 4px; color: #0E0E10; }
.chat-msg-bubble.sent     { align-self: flex-end; background: var(--primary); color: white; border-bottom-right-radius: 4px; box-shadow: 0 2px 8px rgba(16,185,129,0.2); }
.chat-msg-time { font-size: 0.7rem; color: var(--text-muted); margin-top: 0.25rem; text-align: right; }
.chat-msg-bubble.received .chat-msg-time { text-align: left; }

/* Suggested Chips */
.suggested-chips { display: flex; gap: 0.5rem; overflow-x: auto; padding-bottom: 0.5rem; margin-bottom: 0.75rem; }
.suggest-chip { flex-shrink: 0; background: rgba(14,14,16,.04); border: 1px solid rgba(14,14,16,.1); padding: 0.4rem 0.8rem; border-radius: 50px; font-size: 0.78rem; color: #6B6B72; cursor: pointer; transition: var(--transition); }
.suggest-chip:hover { background: var(--primary-glow); border-color: var(--primary); color: var(--primary); }

/* Input Area */
.chat-input-area { display: flex; gap: 0.75rem; align-items: center; border-top: 1px solid var(--border-color); padding-top: 1rem; }
.chat-input-wrapper { flex-grow: 1; background: rgba(14,14,16,.04); border: 1px solid rgba(14,14,16,.1); border-radius: 50px; padding: 0.5rem 1rem; display: flex; align-items: center; }
.chat-input-wrapper input { background: transparent; border: none; outline: none; color: var(--text-main); width: 100%; font-size: 0.88rem; }
.chat-send-btn { width: 38px; height: 38px; background: var(--primary); border: none; border-radius: 50%; color: white; display: flex; align-items: center; justify-content: center; cursor: pointer; box-shadow: 0 2px 6px rgba(16,185,129,0.3); transition: var(--transition); }
.chat-send-btn:hover { transform: scale(1.05); background: var(--primary-hover); }

/* Typing Indicator */
.typing-indicator { align-self: flex-start; background: rgba(14,14,16,.06); padding: 0.6rem 1rem; border-radius: 20px; display: flex; align-items: center; gap: 0.25rem; animation: fadeIn 0.3s ease; }
.typing-dot { width: 6px; height: 6px; background: var(--text-muted); border-radius: 50%; animation: pulse 1.2s infinite ease-in-out; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

/* ── Dark Mode Chat Overrides ── */
[data-theme="dark"] .chat-item {
    background: rgba(30,41,59,0.6);
    border-color: rgba(255,255,255,0.08);
}
[data-theme="dark"] .chat-item:hover { background: rgba(30,41,59,0.85); }
[data-theme="dark"] .chat-item.unread { background: rgba(16,185,129,0.06); }
[data-theme="dark"] .chat-food-preview-card {
    background: rgba(30,41,59,0.7);
    border-color: rgba(255,255,255,0.08);
}
[data-theme="dark"] .chat-msg-bubble.received {
    background: rgba(255,255,255,0.08);
    border-color: rgba(255,255,255,0.08);
    color: #f8fafc;
}
[data-theme="dark"] .chat-input-wrapper {
    background: rgba(255,255,255,0.06);
    border-color: rgba(255,255,255,0.1);
}
[data-theme="dark"] .suggest-chip {
    background: rgba(255,255,255,0.06);
    border-color: rgba(255,255,255,0.1);
    color: #94a3b8;
}
[data-theme="dark"] .typing-indicator { background: rgba(255,255,255,0.08); }
