/* chat-list page */
/* Styles for the quest message inbox list */

.chat-inbox {
    max-width: 900px;
    margin: 0 auto;
    padding: 2.5rem 1.5rem;
}

.chat-inbox-header {
    margin-bottom: 2rem;
}

.chat-inbox-header h1 {
    font-size: 1.75rem;
    font-weight: 600;
}

.chat-inbox-header p {
    margin-top: 0.25rem;
    color: var(--muted);
    font-size: 0.95rem;
}

/* Empty state */
.chat-empty {
    text-align: center;
    padding: 5rem 1rem;
    color: var(--muted);
}

.chat-empty-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
}

.chat-empty-title {
    font-weight: 500;
    font-size: 1.1rem;
}

.chat-empty-text {
    margin-top: 0.25rem;
    font-size: 0.9rem;
}

/* Chat list */
.chat-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Chat item */
.chat-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.1rem 1.25rem;
    border-radius: 14px;
    background: var(--surface);
    border: 1px solid rgba(0, 0, 0, 0.06);
    text-decoration: none;
    transition: background 0.15s ease, transform 0.05s ease;
}

html.dark .chat-item {
    border-color: rgba(255, 255, 255, 0.08);
}

.chat-item:hover {
    background: rgba(0, 0, 0, 0.03);
}

html.dark .chat-item:hover {
    background: rgba(255, 255, 255, 0.04);
}

.chat-item.unread {
    box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.35);
}

/* Main content */
.chat-item-main {
    flex: 1;
    min-width: 0;
}

/* Top row */
.chat-item-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
}

.chat-quest-title {
    font-weight: 500;
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-time {
    font-size: 0.75rem;
    color: var(--muted);
    flex-shrink: 0;
}

/* With who */
.chat-with {
    margin-top: 0.15rem;
    font-size: 0.85rem;
    color: var(--muted);
}

.chat-with span {
    color: inherit;
    font-weight: 500;
}

/* Preview */
.chat-preview {
    margin-top: 0.35rem;
    font-size: 0.9rem;
    color: #374151;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

html.dark .chat-preview {
    color: #d1d5db;
}

/* Unread badge */
.chat-unread-badge {
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 999px;
    background: #ef4444;
    color: #fff;
    font-size: 0.75rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
}







/* Chat Page */
/* ===============================
   ROOT
================================ */
.cq-root {
    height: 74vh;
    display: flex;
    flex-direction: column;
    font-family: Inter, system-ui, sans-serif;
    color: #0f172a;
}

/* ===============================
   HEADER
================================ */
.cq-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;

    background: var(--surface, #fff);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.cq-header-inner {
    max-width: 72rem;
    margin: auto;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cq-title {
    font-size: 1.25rem;
    font-weight: 700;
}

.cq-subtitle {
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #64748b;
}

.cq-with {
    font-size: 0.8rem;
    color: #475569;
}

html.dark .cq-header {
    background: rgba(15, 23, 42, 0.85);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

html.dark .cq-header,
html.dark .cq-header * {
    color: #f8fafc;
}

html.dark .cq-subtitle {
    color: #94a3b8;
}

html.dark .cq-with {
    color: #cbd5f5;
}

.cq-header-inline {
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.cq-header-inline .cq-title {
    font-size: 1.05rem;
    font-weight: 700;
}

.cq-header-inline .cq-with {
    font-size: 0.85rem;
}

.cq-sep {
    opacity: 0.5;
}


/* ===============================
   MESSAGES
================================ */
.cq-messages {
    padding-bottom: 10rem;
    flex: 1;
    overflow-y: auto;
    padding: 2rem 1rem;
    padding-top: 4.5rem;
    position: relative;
}


.cq-row {
    display: flex;
    margin-bottom: 1.25rem;
}

.cq-row.mine {
    justify-content: flex-end;
}

.cq-row.theirs {
    justify-content: flex-start;
}

/* ===============================
   SAFE HOVER CONTAINER
   THIS FIXES YOUR PROBLEM
================================ */
.cq-bubble-wrap {
    position: relative;
    max-width: 78%;
    padding: 0.25rem 2.5rem;
    /* space for actions */
}

.cq-bubble-wrap:hover .cq-actions,
.cq-bubble-wrap:focus-within .cq-actions {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* ===============================
   ACTION BAR (STATIONARY)
================================ */
.cq-actions {
    position: absolute;
    top: -1.75rem;
    display: flex;
    gap: 0.35rem;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none;
    z-index: 5;
}

.cq-actions.left {
    left: 0;
}

.cq-actions.right {
    right: 0;
}

.cq-actions button {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 0.6rem;
    padding: 0.3rem 0.45rem;
    font-size: 0.75rem;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.15s ease;
}

.cq-actions button:hover {
    background: #e5e7eb;
    transform: scale(1.05);
}

/* ===============================
   MESSAGE ROW
================================ */
.cq-message-row {
    display: flex;
    gap: 0.6rem;
    align-items: flex-end;
}

.cq-message-row.reverse {
    flex-direction: row-reverse;
}

/* ===============================
   AVATAR
================================ */
.cq-avatar {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.cq-avatar.me {
    background: linear-gradient(135deg, #2563eb, #3b82f6);
    color: white;
}

.cq-avatar.them {
    background: #e5e7eb;
    color: #0f172a;
}

html.dark .cq-avatar.them {
    background: #334155;
    color: #f8fafc;
}


/* ===============================
   BUBBLES
================================ */
.cq-bubble {
    padding: 0.75rem 1rem;
    border-radius: 1.1rem;
    line-height: 1.45;
    font-size: 0.9rem;
    position: relative;
}

.cq-bubble.mine {
    background: linear-gradient(135deg, #2563eb, #3b82f6);
    color: white;
    border-bottom-right-radius: 0.3rem;
}

.cq-bubble.theirs {
    background: white;
    color: #0f172a;
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-bottom-left-radius: 0.3rem;
}

html.dark .cq-bubble.theirs {
    background: #1f2933;
    /* neutral premium gray */
    color: #f8fafc;
    /* clean white text */
    border-color: rgba(255, 255, 255, 0.08);
}


/* ===============================
   META
================================ */
.cq-meta {
    margin-top: 0.25rem;
    display: flex;
    justify-content: flex-end;
    gap: 0.4rem;
    font-size: 0.65rem;
    opacity: 0.65;
}

html.dark .cq-meta {
    opacity: 0.75;
    color: #cbd5e1;
}


.cq-read {
    font-weight: 600;
}

/* ===============================
   INPUT
================================ */
.cq-input {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;

    flex-shrink: 0;
    border-top: 1px solid rgba(0, 0, 0, 0.06);

}

.cq-form {
    max-width: 72rem;
    margin: auto;
    padding: 0.75rem 1rem;
    display: flex;
    gap: 0.75rem;
}

.cq-form textarea {
    flex: 1;
    resize: none;
    border-radius: 1rem;
    border: 1px solid rgba(0, 0, 0, 0.1);
    padding: 0.6rem 0.8rem;
    font-family: inherit;

}

.cq-form button {
    background: linear-gradient(135deg, #2563eb, #3b82f6);
    color: white;
    border: none;
    border-radius: 0.9rem;
    padding: 0.6rem 1.2rem;
    font-weight: 600;
    cursor: pointer;
}

html.dark .cq-actions button {
    background: #0f172a;
    color: #e5e7eb;
    border-color: rgba(255, 255, 255, 0.12);
}

html.dark .cq-actions button:hover {
    background: #1e293b;
}

/* ===============================
   REPLY PREVIEW
================================ */
.cq-reply {
    position: fixed;
    bottom: 4.5rem;
    /* height of input bar */
    left: 50%;
    transform: translateX(-50%);
    z-index: 101;
    padding-bottom: 10rem;
    max-width: 72rem;
    margin: 0.5rem auto 0;
    padding: 0.6rem 0.8rem;
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    background: rgba(37, 99, 235, 0.08);
    border-radius: 0.75rem;
}

.cq-hidden {
    display: none !important;
}

.cq-reply.hidden {
    display: none !important;
}

.cq-reply-bar {
    width: 3px;
    border-radius: 2px;
    background: #2563eb;
    margin-top: 0.15rem;
}

.cq-reply-content {
    flex: 1;
    min-width: 0;
}

.cq-reply-label {
    font-size: 0.65rem;
    font-weight: 600;
    color: #2563eb;
    margin-bottom: 0.15rem;
}

.cq-reply-text {
    font-size: 0.75rem;
    color: #334155;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cq-reply-close {
    background: none;
    border: none;
    font-size: 0.9rem;
    cursor: pointer;
    opacity: 0.6;
}

.cq-reply-close:hover {
    opacity: 1;
}

/* Dark mode */
html.dark .cq-reply {
    background: rgba(59, 130, 246, 0.15);
}

html.dark .cq-reply-text {
    color: #e5e7eb;
}

/*  */
.cq-reply-l-wrapper {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    margin-bottom: 4px;
    position: relative;
    max-width: 80%;
}

.cq-reply-text {
    font-size: 0.85em;
    color: #555;
    margin-bottom: 4px;
    padding-left: 8px;
}

.cq-reply-line {
    position: absolute;
    left: 0;
    top: 0;
    bottom: -4px;
    /* line reaches under bubble */
    width: 2px;
    background-color: #888;
}

.cq-bubble-wrap-inner {
    position: relative;
}

.cq-reply-line::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 10px;
    /* horizontal part of L */
    height: 2px;
    background-color: #888;
}

/*  */


.cq-input-wrap {
    position: sticky;
    bottom: 0;
    z-index: 50;
}