/* Chat Container */
.chat-container { display:flex; flex-direction:column; width:auto; min-width:0; margin:20px 20px 20px 0; background:var(--panel-bg); padding:0 10px; border-radius:10px; box-shadow:0 2px 6px rgba(0,0,0,0.06); position:relative; height:calc(100vh - 40px); box-sizing:border-box; }
#chat { overflow-y:auto; flex: 1 1 auto; min-height: 0; padding:10px; overflow-anchor:none; padding-right: 10px; }

.chat-header {
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:12px;
    min-width:0;
    min-height:52px;
    padding:9px 5px;
    position:relative;
    z-index:40;
}
.chat-header h3 {
    flex:1 1 auto;
    min-width:0;
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
}
.chat-header.date-nav-auto:not(:hover) .date-nav-track,
.chat-header.date-nav-collapsed .date-nav-track {
    display:none;
}

/* Loading & Chunks */
#loading { text-align:center; height:100%; justify-content:center; align-items:center; display:flex; color:var(--muted); margin-bottom:20px; }
.message-chunk { min-height:100px; }

/* Messages */
.message-wrapper { display: flex; flex-direction: column; width: 100%; margin-bottom: 2px; }
.from-me-wrapper { align-items: flex-end; }
.from-them-wrapper { align-items: flex-start; }

.message { position:relative; margin:2px 5px; padding:10px 15px; border-radius:18px; max-width:50%; word-break:break-word; overflow-wrap:break-word; }
.message.clump-first { margin-top: 6px; }
.message.clump-last { margin-bottom: 6px; }

.from-me { background:var(--me-bg); color:var(--me-text); text-align:left; }
.from-me:not(.clump-first) { border-top-right-radius: 4px; }
.from-me:not(.clump-last) { border-bottom-right-radius: 4px; }

.from-them { background:var(--them-bg); color:var(--text); text-align:left; }
.from-them:not(.clump-first) { border-top-left-radius: 4px; }
.from-them:not(.clump-last) { border-bottom-left-radius: 4px; }

.sender-name { font-size: 12px; font-weight: normal; color: var(--muted); margin-bottom: 4px; padding: 0 12px; }
.from-me-wrapper .sender-name { display:none; }
.from-them-wrapper .sender-name { margin-left: 2px; }

.message-content { line-height:1.4; }
.from-me .message-content { color:var(--me-text); }
.from-them .message-content { color:var(--text); }
.msg-unsent {
    font-style: italic;
    opacity: 0.55;
    font-size: 0.92em;
}

/* Message Hover Timestamp */
.msg-timestamp {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 11px;
    color: var(--muted);
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
    pointer-events: none;
}
.message:hover .msg-timestamp {
    opacity: 1;
}
.from-me .msg-timestamp {
    right: calc(100% + 10px);
}
.from-them .msg-timestamp {
    left: calc(100% + 10px);
}

/* Time Separator */
.time-separator {
    text-align: center;
    font-size: 12px;
    color: var(--muted);
    margin: 20px 0 10px 0;
    font-weight: 500;
}

.message.has-reactions { margin-bottom: 16px; }
.message.clump-last.has-reactions { margin-bottom: 20px; }

/* Reactions (Floating Bubble) */
.reaction-bubble {
    position: absolute;
    bottom: -14px;
    right: 8px; /* Always on the right edge */
    background: var(--panel-bg);
    border: 1px solid var(--border);
    padding: 2px 6px;
    border-radius: 999px; /* Pill shape */
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 15px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    z-index: 10;
    cursor: default;
    user-select: none;
}
.from-them .reaction-bubble {
    right: 8px; /* Always on the right side as requested */
    left: auto;
}
.reaction-emoji-simple {
    display: inline-block;
    line-height: 1;
}
.reaction-count {
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    margin-left: 2px;
}

/* Reaction Popover */
.reaction-popover {
    display: none;
    position: absolute;
    bottom: calc(100% + 4px);
    right: 0;
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    flex-direction: column;
    gap: 4px;
    min-width: 140px;
    max-height: 160px; /* ~5 items */
    overflow-y: auto;
    z-index: 20;
    cursor: default;
}
.reaction-bubble:hover .reaction-popover {
    display: flex;
}
.reaction-bubble::before {
    content: '';
    position: absolute;
    top: -16px;
    left: 0;
    width: 100%;
    height: 32px;
    background: transparent;
    z-index: 1;
}
.reaction-popover-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    border-radius: 4px;
}
.reaction-popover-item:hover {
    background: var(--hover-overlay);
}
.popover-emoji {
    font-size: 16px;
}
.popover-actor {
    font-size: 13px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.popover-actor.has-time-info {
    text-decoration: underline dotted var(--muted);
    text-underline-offset: 3px;
    cursor: help;
}

/* Media */
.placeholder { width:150px; height:60px; display:flex; align-items:center; justify-content:center; border-radius:10px; background:var(--hover-overlay); color:var(--muted); transition:all .2s ease; font-size: 13px; text-align: center; }
.preview:hover { transform: scale(1.05); }
.preview-video, .preview { max-width:250px; max-height:300px; }
img, video { max-width:100%; border-radius:10px; margin:5px; cursor:pointer; transition:all .3s ease; object-fit:cover; }

.media-file-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--hover-overlay);
    border-radius: 8px;
    text-decoration: none;
    color: inherit;
    font-weight: 500;
    margin: 4px 0;
    font-size: 14px;
    border: 1px solid var(--border);
    word-break: break-all;
    box-sizing: border-box;
}
.media-file-link:hover {
    background: var(--border);
}
.placeholder.media-file-link {
    width: auto;
    height: auto;
    text-align: left;
}

/* Date Navigation */
.date-nav-controls {
    display:none;
    align-items:center;
    justify-content:flex-end;
    gap:8px;
    flex:0 1 540px;
    max-width:62%;
    min-width:0;
    padding:4px;
    box-sizing:border-box;
    overflow:hidden;
}
.date-nav-controls.active { display:flex; }
.date-nav-controls:not(.active) ~ .date-nav-track { display:none; }
.date-nav-scale { display:flex; gap:4px; flex:0 0 auto; }
.date-nav-scale button { border:1px solid var(--border); background:var(--bg); color:var(--text); border-radius:6px; padding:7px 12px; font-size:13px; cursor:pointer; min-height:36px; }
.date-nav-scale button.active { background:var(--accent); border-color:var(--accent); color:#fff; }
.date-nav-steps { display:flex; gap:4px; flex:0 0 auto; }
.date-nav-steps button { width:38px; height:36px; border:1px solid var(--border); border-radius:6px; background:var(--bg); color:var(--text); font-size:18px; line-height:1; cursor:pointer; }
.date-nav-steps button:disabled { opacity:0.4; cursor:default; }
.date-nav-current-box { flex:1 1 auto; min-width:118px; max-width:190px; border:1px solid var(--border); border-radius:6px; background:var(--bg); color:var(--text); padding:7px 10px; box-sizing:border-box; cursor:pointer; font:inherit; min-height:36px; }
.date-nav-current-box:disabled { cursor:default; opacity:0.75; }
.date-nav-current { color:var(--muted); font-size:13px; text-align:left; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }

.date-nav-track { display:flex; align-items:flex-end; gap:6px; overflow-x:auto; overflow-y:hidden; padding:10px; min-height:54px; max-width:100%; min-width:0; box-sizing:border-box; overscroll-behavior-x:contain; position:absolute; top:100%; left:0; right:0; width:auto; border:1px solid var(--border); border-radius:8px; background:var(--panel-bg); box-shadow:0 4px 14px rgba(0,0,0,0.12); }
.date-nav-track.slider-mode { overflow:hidden; display:block; }
.date-nav-item { flex:0 0 auto; min-width:72px; height:52px; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:5px; border:1px solid transparent; border-radius:6px; background:transparent; color:var(--muted); cursor:pointer; padding:5px 7px; }
.date-nav-item:hover { background:var(--hover-overlay); }
.dark .date-nav-item:hover { background:var(--hover-overlay-dark); }
.date-nav-item.active { border-color:var(--accent); color:var(--text); }
.date-nav-density { width:58px; height:7px; border-radius:999px; background:var(--border); overflow:hidden; }
.date-nav-density span { display:block; height:100%; border-radius:inherit; background:var(--accent); opacity:0.85; }
.date-nav-label { font-size:11px; line-height:1; white-space:nowrap; }
.date-nav-count { color:var(--muted); font-size:9px; line-height:1; opacity:0.78; white-space:nowrap; }
.date-nav-slider-wrap { width:100%; min-width:0; box-sizing:border-box; padding:3px 4px; }
.date-nav-slider { display:block; width:100%; height:24px; min-width:0; box-sizing:border-box; accent-color:var(--accent); }
.date-nav-slider-labels { display:flex; justify-content:space-between; gap:12px; color:var(--muted); font-size:11px; margin-top:2px; }
.date-nav-slider-labels span { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.date-nav-slider-meta { color:var(--muted); font-size:11px; margin-top:2px; text-align:center; }

/* Chat Info Panel */
.chat-info-toggle { flex:0 0 auto; width:36px; height:36px; border:1px solid var(--border); border-radius:50%; background:var(--bg); color:var(--text); font-size:17px; font-weight:700; font-family:Georgia, serif; line-height:1; cursor:pointer; }
.chat-info-toggle[aria-expanded="true"] { background:var(--accent); border-color:var(--accent); color:#fff; }
.chat-info-panel { min-width:0; height:calc(100vh - 40px); min-height:0; margin:20px 20px 20px 0; background:var(--panel-bg); border-radius:10px; box-shadow:0 2px 6px rgba(0,0,0,0.06); overflow:hidden; }
.info-panel-header { flex:0 0 auto; min-height:52px; display:flex; align-items:center; justify-content:center; box-sizing:border-box; padding:9px 16px; border-bottom:1px solid var(--border); }
.info-panel-header strong { display:block; max-width:100%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; text-align:center; }
.info-panel-label { color:var(--muted); font-size:13px; margin-bottom:12px; text-align:center; }
.info-panel-content { flex:1 1 auto; min-height:0; overflow:auto; padding:16px; }
.info-section { margin-bottom:22px; }
.info-section strong { display:block; margin-bottom:10px; font-size:16px; }
.info-list, .info-stats { display:flex; flex-direction:column; gap:10px; }
.member-list { display:flex; flex-direction:column; gap:8px; }
.member-chip { width:100%; box-sizing:border-box; padding:7px 10px; border:1px solid var(--border); border-radius:6px; background:var(--bg); color:var(--text); font-size:15px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.info-metric { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:10px 12px; border:1px solid var(--border); border-radius:8px; background:var(--bg); }
.info-metric span { color:var(--muted); font-size:14px; }
.info-metric strong { margin:0; font-size:20px; color:var(--text); }
.attachment-count { color:var(--text); white-space:nowrap; }
.attachment-found { color:var(--muted); opacity:0.68; }
.attachment-separator { color:var(--muted); opacity:0.8; }
.info-row { display:flex; justify-content:space-between; gap:12px; color:var(--muted); font-size:15px; line-height:1.35; }
.info-row span:last-child { color:var(--text); text-align:right; white-space:nowrap; }
.member-stat { display:grid; grid-template-columns:minmax(0, 1fr) auto; gap:7px 12px; font-size:15px; padding:8px 0; }
.member-stat-name { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.member-stat-meta { color:var(--muted); text-align:right; }
.member-stat-bar { grid-column:1 / -1; height:8px; border-radius:999px; background:var(--border); overflow:hidden; }
.member-stat-bar span { display:block; height:100%; border-radius:inherit; background:var(--accent); }
.info-empty { color:var(--muted); font-size:15px; }

/* Search Results Area */
.search-section { margin-top:12px; margin-bottom:16px; }
.search-controls { display:flex; gap:8px; margin:8px 0; }
.search-controls input[type="search"] { flex:1; padding:8px; border-radius:6px; border:1px solid var(--border); margin: 2px;}
.search-controls button { padding:8px 12px; background:var(--accent); color:white; border:none; border-radius:6px; cursor:pointer; }
.search-controls button[type="button"] { background:var(--muted); }
.search-highlight { font:inherit; background-color:var(--highlight); padding:0; border-radius:0; }
.search-progress { display:none; align-items:center; gap:8px; margin:6px 0; }
.search-progress .bar { width:100%; height:8px; background:var(--border); border-radius:6px; overflow:hidden; }
.search-progress .fill { height:100%; background:var(--accent); width:0%; transition:width .2s linear; }
.search-progress .progress-text { min-width:80px; font-size:12px; color:var(--muted); }
.search-results { padding-right: 10px; max-height:200px; overflow:auto; margin-top:8px; border:1px solid var(--border); padding:6px; border-radius:6px; background:var(--panel-bg); }
.search-result-item { padding:6px; border-radius:6px; cursor:pointer; }
.search-result-item:hover { background: rgba(0,0,0,0.03); }
.search-result-item .snippet { color:var(--text); font-size:13px; }
.search-result-item .meta { color:var(--muted); font-size:12px; margin-top:4px; }
.highlight-target { box-shadow:0 0 0 3px rgba(24,119,242,0.15); border-radius:12px; }
.temporary-highlight { animation: highlightFlash 2s ease both; }
@keyframes highlightFlash { from{ box-shadow:0 0 0 6px rgba(24,119,242,0.25);} to{ box-shadow:0 0 0 0 rgba(24,119,242,0);} }
