/**
 * Hilanaw Community — Messaging UI Styles
 * File: hilanaw-messages.css
 *
 * Covers:
 *   - Two-panel layout (sidebar + thread)
 *   - Tab bar (DM / Groups)
 *   - Conversation list items + unread badges
 *   - Message thread header
 *   - Message bubbles (sent / received)
 *   - Send box
 *   - Empty states
 *   - Mobile slide animation
 *   - Dark mode
 *
 * Class prefix: hcm- (Hilanaw Community Messaging)
 */

/* ================================================================
   LAYOUT — wrap + two-panel grid
   ================================================================ */

/*
 * On the messages page the wrap takes over the full viewport below
 * the sticky Elementor header. --hcm-header-h is set dynamically by
 * JS measuring #hilanaw-global-header on load + resize.
 * Fallback of 60px covers the rare case JS hasn't run yet.
 */
:root {
    --hcm-header-h: 60px;
}

.hcm-wrap {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: var(--hcm-header-h);
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    overflow: hidden;
    background: var(--hc-surface);
    z-index: 100;
}

/* Prevent the page body from scrolling behind the fixed wrap */
body.hcm-page-active {
    overflow: hidden;
}

.hcm-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    height: 100%;
}

/* ================================================================
   TAB BAR
   ================================================================ */

.hcm-tabs {
    display: flex;
    border-bottom: 1px solid var(--hc-border);
    background: var(--hc-surface);
    flex-shrink: 0;
    position: relative;
    z-index: 10;
}

.hcm-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 14px 16px;
    font-size: 14px;
    font-weight: 600;
    color: var(--hc-text-soft);
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    transition: color var(--hc-transition), border-color var(--hc-transition);
    white-space: nowrap;
}

.hcm-tab:hover {
    color: var(--hc-text);
    background: var(--hc-bg);
}

.hcm-tab--active {
    color: var(--hc-blue);
    border-bottom-color: var(--hc-blue);
}

.hcm-tab__badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: var(--hc-blue);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    border-radius: 9px;
    line-height: 1;
    transition: opacity 0.2s;
}

.hcm-tab__badge--hidden {
    opacity: 0;
    pointer-events: none;
}

.hcm-sidebar {
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--hc-border);
    overflow: hidden;
    background: var(--hc-surface);
}

.hcm-sidebar__panel {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.hcm-sidebar__panel[hidden] { display: none; }

.hcm-sidebar__panel--active {
    display: flex;
}

/* ── Search bar ─────────────────────────────────────────────────── */

.hcm-search-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--hc-border);
    flex-shrink: 0;
}

.hcm-search-wrap__icon {
    font-size: 14px;
    flex-shrink: 0;
    opacity: 0.5;
}

.hcm-search {
    flex: 1;
    border: none;
    background: none;
    font-size: 14px;
    color: var(--hc-text);
    outline: none;
    min-width: 0;
}

.hcm-search::placeholder { color: var(--hc-text-faint); }

/* ── Conversation list ──────────────────────────────────────────── */

.hcm-conv-list {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.hcm-conv-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 14px;
    text-align: left;
    background: none;
    border: none;
    border-bottom: 1px solid var(--hc-border);
    cursor: pointer;
    transition: background var(--hc-transition);
    position: relative;
}

.hcm-conv-item:hover {
    background: var(--hc-bg);
}

.hcm-conv-item--active {
    background: var(--hc-blue-light);
    border-left: 3px solid var(--hc-blue);
}

.hcm-conv-item--active:hover {
    background: var(--hc-blue-light);
}

/* ── Conv item — avatar ─────────────────────────────────────────── */

.hcm-conv-item__avatar {
    position: relative;
    flex-shrink: 0;
}

.hcm-conv-item__photo {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    max-width: 44px;
    max-height: 44px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
    overflow: hidden;
}

.hcm-conv-item__photo--placeholder {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    background: var(--hc-blue); /* overridden per-item by nameToColour() JS */
}

.hcm-conv-item__unread-dot {
    position: absolute;
    top: 0;
    right: 0;
    width: 10px;
    height: 10px;
    background: var(--hc-blue);
    border-radius: 50%;
    border: 2px solid var(--hc-surface);
}

/* ── Conv item — info ───────────────────────────────────────────── */

.hcm-conv-item__info {
    flex: 1;
    min-width: 0;
}

.hcm-conv-item__top {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 3px;
}

.hcm-conv-item__name {
    font-size: 14px;
    font-weight: 600;
    color: var(--hc-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hcm-conv-item--unread .hcm-conv-item__name {
    font-weight: 700;
}

.hcm-conv-item__time {
    font-size: 11px;
    color: var(--hc-text-faint);
    white-space: nowrap;
    flex-shrink: 0;
}

.hcm-conv-item__bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.hcm-conv-item__preview {
    font-size: 13px;
    color: var(--hc-text-soft);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.hcm-conv-item--unread .hcm-conv-item__preview {
    color: var(--hc-text);
    font-weight: 500;
}

.hcm-conv-item__you {
    color: var(--hc-text-faint);
    margin-right: 3px;
}

.hcm-unread-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: var(--hc-blue);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    border-radius: 9px;
    flex-shrink: 0;
    line-height: 1;
}

/* ================================================================
   CONV ROW — DM conversation list items (JS-rendered)
   ================================================================ */

.hcm-conv-row {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 14px;
    background: none;
    border: none;
    border-bottom: 1px solid var(--hc-border);
    cursor: pointer;
    transition: background var(--hc-transition);
    position: relative;
    text-align: left;
    box-sizing: border-box;
}

.hcm-conv-row:hover {
    background: var(--hc-bg);
}

.hcm-conv-row--active {
    background: var(--hc-blue-light);
    border-left: 3px solid var(--hc-blue);
}

.hcm-conv-row--active:hover {
    background: var(--hc-blue-light);
}

/* ── Avatar ───────────────────────────────────────────────────── */

.hcm-conv-row__avatar {
    flex-shrink: 0;
    position: relative;
}

.hcm-conv-row__photo {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    max-width: 44px;
    max-height: 44px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
    overflow: hidden;
}

.hcm-conv-row__photo--placeholder {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    background: var(--hc-blue);
}

/* ── Body ─────────────────────────────────────────────────────── */

.hcm-conv-row__body {
    flex: 1;
    min-width: 0;
}

.hcm-conv-row__top {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 3px;
}

.hcm-conv-row__name {
    font-size: 14px;
    font-weight: 600;
    color: var(--hc-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}

.hcm-conv-row__role {
    font-size: 11px;
    color: var(--hc-text-faint);
    white-space: nowrap;
    flex-shrink: 0;
}

.hcm-conv-row__ended {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #92400e;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 4px;
    padding: 1px 6px;
    white-space: nowrap;
    flex-shrink: 0;
}

.hcm-conv-row__time {
    font-size: 11px;
    color: var(--hc-text-faint);
    white-space: nowrap;
    flex-shrink: 0;
}

.hcm-conv-row__bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.hcm-conv-row__preview {
    font-size: 13px;
    color: var(--hc-text-soft);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}

.hcm-conv-row__no-msg {
    color: var(--hc-text-faint);
    font-style: italic;
}

.hcm-conv-row__badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: var(--hc-blue);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    border-radius: 9px;
    flex-shrink: 0;
    line-height: 1;
}

/* Dark mode */
body.hilanaw-dark-mode .hcm-conv-row {
    border-bottom-color: var(--hc-border);
}
body.hilanaw-dark-mode .hcm-conv-row:hover {
    background: rgba(255,255,255,0.04);
}
body.hilanaw-dark-mode .hcm-conv-row--active {
    background: rgba(29, 78, 216, 0.18);
}
body.hilanaw-dark-mode .hcm-conv-row__photo--placeholder {
    background: #1d4ed8;
}

/* ================================================================
   THREAD PANEL — right panel
   ================================================================ */

.hcm-thread-panel {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--hc-bg);
    position: relative;
}

/* ── Thread empty state ─────────────────────────────────────────── */

.hcm-thread-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--hc-text-faint);
    padding: 40px;
}

.hcm-thread-empty__icon { font-size: 48px; }
.hcm-thread-empty p { font-size: 15px; margin: 0; }
.hcm-thread-empty[hidden] { display: none; }

/* ── Thread ─────────────────────────────────────────────────────── */

.hcm-thread {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.hcm-thread[hidden] { display: none; }

/* ── Thread header ──────────────────────────────────────────────── */

.hcm-thread__header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--hc-border);
    background: var(--hc-surface);
    flex-shrink: 0;
    min-height: 56px;
    position: relative;
    z-index: 5;
}

.hcm-thread__back {
    display: flex; /* always visible in an open thread, on every screen size */
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    color: var(--hc-text-soft);
    border-radius: var(--hc-radius);
    transition: background var(--hc-transition);
    flex-shrink: 0;
}

.hcm-thread__back:hover { background: var(--hc-bg); }

.hcm-thread__avatar {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
}

.hcm-thread__avatar-photo {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.hcm-thread__avatar-placeholder {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    color: #fff;
}

.hcm-thread__info { flex: 1; min-width: 0; }

.hcm-thread__name {
    display: block;
    font-size: 15px;
    font-weight: 700;
    color: var(--hc-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hcm-thread__sub {
    display: block;
    font-size: 12px;
    color: var(--hc-text-faint);
}

.hcm-thread__identity {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
    text-decoration: none;
    color: inherit;
    cursor: default;
    border-radius: var(--hc-radius);
    padding: 4px;
    margin: -4px;
    transition: background var(--hc-transition);
}

.hcm-thread__identity.is-clickable { cursor: pointer; }
.hcm-thread__identity.is-clickable:hover { background: var(--hc-bg); }

.hcm-thread__kebab {
    position: relative;
    flex-shrink: 0;
}

.hcm-thread__kebab-trigger {
    width: 32px;
    height: 32px;
    border: 1px solid var(--hc-border);
    border-radius: var(--hc-radius);
    background: var(--hc-surface);
    color: var(--hc-text-soft);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background var(--hc-transition), border-color var(--hc-transition);
}

.hcm-thread__kebab-trigger:hover,
.hcm-thread__kebab-trigger[aria-expanded="true"] {
    background: var(--hc-bg);
    border-color: var(--hc-blue);
}

.hcm-thread__kebab-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 170px;
    background: var(--hc-surface);
    border: 1px solid var(--hc-border);
    border-radius: var(--hc-radius);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
    padding: 4px;
    z-index: 30;
}

.hcm-thread__kebab-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 9px 12px;
    border: none;
    background: none;
    border-radius: 6px;
    font-size: 14px;
    color: var(--hc-text);
    cursor: pointer;
}

/* display:block above always beats the browser's default [hidden]{display:none}
   rule (author styles win over UA styles regardless of specificity), so without
   this, toggling .hidden in JS has no visual effect on these buttons. */
.hcm-thread__kebab-item[hidden] { display: none; }

.hcm-thread__kebab-item:hover { background: var(--hc-bg); }

.hcm-thread__kebab-item--danger { color: #b91c1c; }
.hcm-thread__kebab-item--danger:hover { background: #fef2f2; }

.hcm-readonly-banner {
    flex-shrink: 0;
    padding: 10px 16px;
    background: #fffbeb;
    border-bottom: 1px solid #fde68a;
    color: #92400e;
    font-size: 13px;
    text-align: center;
}

/* ── Message list ───────────────────────────────────────────────── */

.hcm-messages {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    scroll-behavior: smooth;
}

.hcm-messages__loader {
    display: flex;
    justify-content: center;
    padding: 20px;
}

/* ── Date separator ─────────────────────────────────────────────── */

.hcm-date-sep {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 16px 0 8px;
    color: var(--hc-text-faint);
    font-size: 12px;
}

.hcm-date-sep::before,
.hcm-date-sep::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--hc-border);
}

/* ── Message bubble ─────────────────────────────────────────────── */

.hcm-msg {
    display: flex;
    flex-direction: column;
    max-width: 68%;
    margin-bottom: 2px;
}

.hcm-msg--mine {
    align-self: flex-end;
    align-items: flex-end;
}

.hcm-msg--theirs {
    align-self: flex-start;
    align-items: flex-start;
}

.hcm-msg--consecutive {
    margin-bottom: 1px;
}

.hcm-msg__bubble {
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    overflow-wrap: break-word;
    word-break: break-word;
    white-space: pre-wrap;
}

.hcm-msg--mine .hcm-msg__bubble {
    background: var(--hc-blue);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.hcm-msg--theirs .hcm-msg__bubble {
    background: var(--hc-surface);
    color: var(--hc-text);
    border: 1px solid var(--hc-border);
    border-bottom-left-radius: 4px;
}

/* Consecutive messages — tighten border radius */
.hcm-msg--mine.hcm-msg--consecutive .hcm-msg__bubble {
    border-top-right-radius: 4px;
}

.hcm-msg--theirs.hcm-msg--consecutive .hcm-msg__bubble {
    border-top-left-radius: 4px;
}

/* Deleted message */
.hcm-msg--deleted .hcm-msg__bubble {
    background: var(--hc-bg) !important;
    color: var(--hc-text-faint) !important;
    border: 1px dashed var(--hc-border) !important;
    font-style: italic;
}

/* Optimistic (not yet confirmed by server) */
.hcm-msg--optimistic .hcm-msg__bubble {
    opacity: 0.7;
}

.hcm-msg__meta {
    font-size: 11px;
    color: var(--hc-text-faint);
    margin-top: 3px;
    padding: 0 4px;
}

.hcm-msg--mine .hcm-msg__meta {
    text-align: right;
}

/* Timestamp shown below the bubble */
.hcm-msg__time {
    display: block;
    font-size: 10px;
    color: var(--hc-text-faint);
    margin-top: 3px;
    padding: 0 6px;
    line-height: 1;
}

.hcm-msg--mine .hcm-msg__time {
    text-align: right;
}

.hcm-msg--theirs .hcm-msg__time {
    text-align: left;
}

/* ── Spinner ────────────────────────────────────────────────────── */

.hcm-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--hc-border);
    border-top-color: var(--hc-blue);
    border-radius: 50%;
    animation: hcm-spin 0.7s linear infinite;
}

@keyframes hcm-spin { to { transform: rotate(360deg); } }

/* ================================================================
   SEND BOX
   ================================================================ */

.hcm-send-box {
    display: flex;
    flex-direction: column;
    border-top: 1px solid var(--hc-border);
    background: var(--hc-surface);
    flex-shrink: 0;
    padding: 0;
}

.hcm-send-box__row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 14px;
}

.hcm-send-box__input {
    flex: 1;
    border: 1px solid var(--hc-border);
    border-radius: 22px;
    padding: 10px 16px;
    font-size: 14px;
    font-family: inherit;
    color: var(--hc-text);
    background: var(--hc-bg);
    resize: none;
    height: 42px;
    max-height: 120px;
    overflow-y: hidden;
    outline: none;
    transition: border-color var(--hc-transition);
    line-height: 1.5;
    scrollbar-width: thin;
    box-sizing: border-box;
}

.hcm-send-box__input:focus {
    border-color: var(--hc-blue);
}

.hcm-send-box__input::placeholder {
    color: var(--hc-text-faint);
}

/* Attach button */
.hcm-send-box__attach {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: none;
    border: 1.5px solid var(--hc-border);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--hc-text-soft);
    transition: background var(--hc-transition), color var(--hc-transition), border-color var(--hc-transition);
}

.hcm-send-box__attach svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.hcm-send-box__attach:hover {
    background: var(--hc-bg);
    color: var(--hc-blue);
    border-color: var(--hc-blue);
}

/* Send button */
.hcm-send-box__btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--hc-blue);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background var(--hc-transition), opacity var(--hc-transition), transform 0.1s;
}

.hcm-send-box__btn:hover:not(:disabled) {
    background: #1d4ed8;
    transform: scale(1.05);
}

.hcm-send-box__btn:disabled {
    background: var(--hc-border);
    cursor: not-allowed;
    opacity: 0.6;
}

.hcm-send-box__btn:active:not(:disabled) {
    transform: scale(0.95);
}

/* ================================================================
   EMPTY STATES (sidebar)
   ================================================================ */

.hcm-empty-list {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px 24px;
    gap: 10px;
    flex: 1;
}

.hcm-empty-list__icon { font-size: 36px; }

.hcm-empty-list p {
    font-size: 14px;
    color: var(--hc-text-soft);
    margin: 0;
    line-height: 1.5;
}

.hcm-empty-list__hint {
    font-size: 12px !important;
    color: var(--hc-text-faint) !important;
}

/* ================================================================
   GUEST VIEW
   ================================================================ */

/* .hcm-guest styles moved to hilanaw-community.css for global availability */

/* ================================================================
   MOBILE — slide animation (< 680px)
   ================================================================ */

@media (max-width: 680px) {

    .hcm-layout {
        grid-template-columns: 1fr;
        position: relative;
        overflow: hidden;
    }

    /* Sidebar takes full width */
    .hcm-sidebar {
        position: absolute;
        inset: 0;
        width: 100%;
        transition: transform 0.28s ease;
        z-index: 1;
    }

    /* Thread panel overlays the sidebar */
    .hcm-thread-panel {
        position: absolute;
        inset: 0;
        width: 100%;
        transform: translateX(100%);
        transition: transform 0.28s ease;
        z-index: 2;
        background: var(--hc-bg);
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    /* Thread itself must fill available height */
    .hcm-thread {
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    /* Messages area scrolls, send box stays pinned */
    .hcm-messages {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
    }

    /* Send box always at bottom, tighter on mobile */
    .hcm-send-box {
        flex-shrink: 0;
    }

    .hcm-send-box__row {
        padding: 8px 10px;
        gap: 6px;
    }

    .hcm-send-box__attach {
        width: 38px;
        height: 38px;
    }

    .hcm-send-box__attach svg {
        width: 18px;
        height: 18px;
    }

    .hcm-send-box__input {
        font-size: 14px;
        padding: 8px 14px;
    }

    .hcm-send-box__btn {
        width: 40px;
        height: 40px;
    }

    /* When thread is open — slide thread in, sidebar out */
    .hcm-wrap.hcm-thread-open .hcm-sidebar {
        transform: translateX(-100%);
    }

    .hcm-wrap.hcm-thread-open .hcm-thread-panel {
        transform: translateX(0);
    }

    /* Hide view profile link on small screens to save space */

    /* Wider bubbles on mobile */
    .hcm-msg { max-width: 85%; }

    .hcm-tab { font-size: 12px; padding: 12px 8px; }
}

/* ================================================================
   DARK MODE
   ================================================================ */

body.hilanaw-dark-mode .hcm-wrap {
    background: #1f2937;
    border-color: #374151;
}

body.hilanaw-dark-mode .hcm-tabs {
    background: #1f2937;
    border-color: #374151;
}

body.hilanaw-dark-mode .hcm-sidebar {
    background: #1f2937;
    border-color: #374151;
}

body.hilanaw-dark-mode .hcm-search-wrap {
    border-color: #374151;
}

body.hilanaw-dark-mode .hcm-search {
    color: #f9fafb;
}

body.hilanaw-dark-mode .hcm-conv-item {
    border-color: #374151;
}

body.hilanaw-dark-mode .hcm-conv-item:hover {
    background: #111827;
}

body.hilanaw-dark-mode .hcm-conv-item--active {
    background: #1e3a5f;
    border-left-color: #3b82f6;
}

body.hilanaw-dark-mode .hcm-conv-item__name { color: #f9fafb; }
body.hilanaw-dark-mode .hcm-conv-item__photo--placeholder { background: #1d4ed8; }
body.hilanaw-dark-mode .hcm-conv-item__unread-dot { border-color: #1f2937; }

body.hilanaw-dark-mode .hcm-thread-panel { background: #111827; }

body.hilanaw-dark-mode .hcm-thread__header {
    background: #1f2937;
    border-color: #374151;
}

body.hilanaw-dark-mode .hcm-thread__name { color: #f9fafb; }
body.hilanaw-dark-mode .hcm-thread__sub  { color: #9ca3af; }

body.hilanaw-dark-mode .hcm-messages { background: #111827; }

body.hilanaw-dark-mode .hcm-msg--theirs .hcm-msg__bubble {
    background: #1f2937;
    color: #f3f4f6;
    border-color: #374151;
}

body.hilanaw-dark-mode .hcm-send-box {
    background: #1f2937;
    border-color: #374151;
}

body.hilanaw-dark-mode .hcm-send-box__input {
    background: #111827;
    border-color: #374151;
    color: #f9fafb;
}

body.hilanaw-dark-mode .hcm-send-box__input:focus {
    border-color: #3b82f6;
}

body.hilanaw-dark-mode .hcm-send-box__btn:disabled {
    background: #374151;
}

body.hilanaw-dark-mode .hcm-tab { color: #9ca3af; }
body.hilanaw-dark-mode .hcm-tab:hover { background: #111827; color: #f9fafb; }
body.hilanaw-dark-mode .hcm-tab--active { color: #3b82f6; }

body.hilanaw-dark-mode .hcm-spinner {
    border-color: #374151;
    border-top-color: #3b82f6;
}

/* ================================================================
   GROUP CHAT — Phase 2 additions
   ================================================================ */

/* ── Group admin badge in list ──────────────────────────────────── */
.hcm-group-admin-badge {
    display: inline-flex;
    align-items: center;
    font-size: 10px;
    font-weight: 700;
    color: var(--hc-blue);
    background: var(--hc-blue-light);
    padding: 1px 6px;
    border-radius: 100px;
    margin-left: 4px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ── Group placeholder avatar uses nameToColour ─────────────────── */
.hcm-conv-item__photo--group {
    font-size: 20px;
    font-weight: 800;
    color: #fff;
}

/* ── Pinned message banner ──────────────────────────────────────── */
.hcm-pinned-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: #fef3c7;
    border-bottom: 1px solid #f59e0b;
    font-size: 13px;
    color: #92400e;
    flex-shrink: 0;
}

.hcm-pinned-banner__icon { font-size: 14px; flex-shrink: 0; }

.hcm-pinned-banner__text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

/* ── Sender name above received group bubbles ───────────────────── */
.hcm-msg__sender {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: var(--hc-blue);
    margin-bottom: 2px;
    padding-left: 4px;
    text-decoration: none;
}

a.hcm-msg__sender:hover { text-decoration: underline; }

/* ── Group settings modal ───────────────────────────────────────── */
.hc-modal__box--group-settings {
    max-width: 480px;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.hcm-settings-body {
    overflow-y: auto;
    flex: 1;
    padding: 4px 0 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.hcm-settings-danger {
    padding-top: 16px;
    border-top: 1px solid var(--hc-border);
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ── Cohort photo picker (org dashboard modal) ──────────────────── */
.hcd-cohort-photo-group { margin-bottom: 0; }

.hcd-cohort-photo-picker {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px;
    background: var(--hc-bg);
    border: 1px solid var(--hc-border);
    border-radius: var(--hc-radius);
}

.hcd-cohort-photo-preview {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--hc-blue-light);
    border: 2px solid var(--hc-border);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.hcd-cohort-photo-placeholder {
    font-size: 24px;
    line-height: 1;
    color: var(--hc-text-faint);
}

#hcd-cohort-photo-img {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 50%;
}

.hcd-cohort-photo-controls {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.hcd-cohort-photo-label { cursor: pointer; display: inline-flex; }

.hcd-cohort-photo-hint {
    font-size: 12px;
    color: var(--hc-text-faint);
    margin: 0;
    line-height: 1.4;
}

/* ── Archived group indicator ───────────────────────────────────── */
.hcm-thread-archived-notice {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    background: #f3f4f6;
    border-top: 1px solid var(--hc-border);
    font-size: 13px;
    color: var(--hc-text-faint);
    font-style: italic;
}

/* ── Dark mode additions ────────────────────────────────────────── */
body.hilanaw-dark-mode .hcm-pinned-banner {
    background: #1e1a0e;
    border-color: #92400e;
    color: #fde68a;
}

body.hilanaw-dark-mode .hcm-thread-archived-notice {
    background: #111827;
    color: #6b7280;
}

body.hilanaw-dark-mode .hcd-cohort-photo-picker {
    background: #111827;
    border-color: #374151;
}

body.hilanaw-dark-mode .hcm-group-admin-badge {
    background: #1e3a5f;
    color: #93c5fd;
}

/* ================================================================
   PHASE 3 — Attachments, Drag-Drop, Push Prompt, Toast
   ================================================================ */

/* ── Attachment preview strip above the input ───────────────────── */

.hcm-attach-preview {
    padding: 8px 12px 0;
    border-top: 1px solid var(--hc-border);
}

.hcm-attach-preview__inner {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.hcm-attach-preview__item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: var(--hc-bg);
    border: 1px solid var(--hc-border);
    border-radius: var(--hc-radius);
    font-size: 13px;
    color: var(--hc-text-soft);
    max-width: 100%;
}

.hcm-attach-preview__item--image .hcm-attach-preview__img {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 4px;
}

.hcm-attach-preview__icon { font-size: 20px; flex-shrink: 0; }

.hcm-attach-preview__name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 180px;
}

.hcm-attach-preview__size {
    color: var(--hc-text-faint);
    font-size: 11px;
    flex-shrink: 0;
}

.hcm-attach-preview__remove {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--hc-text-faint);
    font-size: 14px;
    padding: 2px 4px;
    border-radius: 50%;
    flex-shrink: 0;
    line-height: 1;
    transition: background var(--hc-transition), color var(--hc-transition);
}

.hcm-attach-preview__remove:hover {
    background: var(--hc-border);
    color: var(--hc-text);
}

/* ── Upload progress bar ────────────────────────────────────────── */

.hcm-upload-progress[hidden] { display: none; }

.hcm-upload-progress {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 14px 8px;
    border-top: 1px solid var(--hc-border);
}

.hcm-upload-progress__bar {
    flex: 1;
    height: 4px;
    background: var(--hc-border);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}

.hcm-upload-progress__bar::after {
    content: '';
    position: absolute;
    inset: 0;
    width: var(--progress, 0%);
    background: var(--hc-blue);
    border-radius: 2px;
    transition: width 0.2s ease;
}

.hcm-upload-progress__label {
    font-size: 12px;
    color: var(--hc-text-faint);
    white-space: nowrap;
}

/* ── Image in message bubble ────────────────────────────────────── */

.hcm-msg-image-link { display: block; }

.hcm-msg-image {
    max-width: 240px;
    max-height: 200px;
    border-radius: 10px;
    object-fit: cover;
    display: block;
    cursor: pointer;
    transition: opacity 0.15s;
}

.hcm-msg-image:hover { opacity: 0.9; }

/* ── File card in message bubble ────────────────────────────────── */

.hcm-msg-file-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: rgba( 255, 255, 255, 0.12 );
    border: 1px solid rgba( 255, 255, 255, 0.2 );
    border-radius: 10px;
    min-width: 200px;
    max-width: 280px;
}

.hcm-msg--theirs .hcm-msg-file-card {
    background: var(--hc-bg);
    border-color: var(--hc-border);
}

.hcm-msg-file-card__icon { font-size: 24px; flex-shrink: 0; }

.hcm-msg-file-card__info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.hcm-msg-file-card__name {
    font-size: 13px;
    font-weight: 600;
    color: inherit;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hcm-msg-file-card__size {
    font-size: 11px;
    opacity: 0.7;
}

.hcm-msg-file-card__download {
    font-size: 16px;
    color: inherit;
    opacity: 0.8;
    flex-shrink: 0;
    text-decoration: none;
    padding: 4px;
    border-radius: 50%;
    transition: opacity var(--hc-transition), background var(--hc-transition);
}

.hcm-msg-file-card__download:hover { opacity: 1; background: rgba(255,255,255,0.15); }

/* ── Drag-and-drop overlay ──────────────────────────────────────── */

.hcm-drop-overlay {
    position: absolute;
    inset: 0;
    background: rgba( 29, 78, 216, 0.88 );
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    pointer-events: none;
}

.hcm-drop-overlay[hidden] { display: none; }

.hcm-drop-overlay__inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: #fff;
}

.hcm-drop-overlay__icon {
    font-size: 48px;
    animation: hcm-bounce 0.6s infinite alternate;
}

@keyframes hcm-bounce {
    from { transform: translateY(0); }
    to   { transform: translateY(-8px); }
}

.hcm-drop-overlay__inner p {
    font-size: 18px;
    font-weight: 700;
    margin: 0;
}

/* ── Toast notification ─────────────────────────────────────────── */

.hcm-toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #1e293b;
    color: #fff;
    font-size: 14px;
    padding: 10px 20px;
    border-radius: 100px;
    z-index: 300;
    opacity: 0;
    transition: opacity 0.25s ease, transform 0.25s ease;
    pointer-events: none;
    white-space: nowrap;
    max-width: 90vw;
    text-align: center;
}

.hcm-toast--visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.hcm-toast--success { background: #065f46; }
.hcm-toast--error   { background: #991b1b; }

/* ── Mobile send box adjustments ────────────────────────────────── */

@media (max-width: 680px) {
    .hcm-msg-image { max-width: 180px; max-height: 160px; }
}

/* ── Dark mode ──────────────────────────────────────────────────── */

body.hilanaw-dark-mode .hcm-send-box__attach {
    border-color: #374151;
    color: #9ca3af;
}

body.hilanaw-dark-mode .hcm-send-box__attach:hover {
    background: #111827;
    color: #3b82f6;
    border-color: #3b82f6;
}

body.hilanaw-dark-mode .hcm-attach-preview {
    border-color: #374151;
}

body.hilanaw-dark-mode .hcm-attach-preview__item {
    background: #111827;
    border-color: #374151;
    color: #d1d5db;
}

body.hilanaw-dark-mode .hcm-upload-progress { border-color: #374151; }
body.hilanaw-dark-mode .hcm-upload-progress__bar { background: #374151; }

body.hilanaw-dark-mode .hcm-msg--theirs .hcm-msg-file-card {
    background: #1f2937;
    border-color: #374151;
}

body.hilanaw-dark-mode .hcm-toast { background: #f9fafb; color: #111827; }
body.hilanaw-dark-mode .hcm-toast--success { background: #065f46; color: #fff; }
body.hilanaw-dark-mode .hcm-toast--error   { background: #991b1b; color: #fff; }

/* ================================================================
   INSTANT PREVIEW + SKELETON LOADER
   ================================================================ */

/* Preview bubble shown instantly from conv list data before real load */
.hcm-msg--preview {
    opacity: 0.55;
    pointer-events: none;
}

/* Loading skeleton for threads with no messages yet */
.hcm-thread-skeleton {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 20px 16px;
}

.hcm-skeleton-bubble {
    height: 36px;
    border-radius: 18px;
    width: 55%;
    background: linear-gradient(
        90deg,
        var(--hc-border) 25%,
        var(--hc-bg) 50%,
        var(--hc-border) 75%
    );
    background-size: 200% 100%;
    animation: hcm-shimmer 1.4s infinite;
}

.hcm-skeleton-bubble--mine {
    align-self: flex-end;
    width: 45%;
}

.hcm-skeleton-bubble--short {
    width: 30%;
}

@keyframes hcm-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

body.hilanaw-dark-mode .hcm-skeleton-bubble {
    background: linear-gradient(
        90deg,
        rgba(255,255,255,0.07) 25%,
        rgba(255,255,255,0.13) 50%,
        rgba(255,255,255,0.07) 75%
    );
    background-size: 200% 100%;
    animation: hcm-shimmer 1.4s infinite;
}

/* ================================================================
   IMAGE LIGHTBOX
   ================================================================ */

.hcm-lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: rgba(0, 0, 0, 0.88);
    align-items: center;
    justify-content: center;
    padding: 16px;
    animation: hcm-lightbox-in 0.18s ease;
}

.hcm-lightbox--visible {
    display: flex;
}

@keyframes hcm-lightbox-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.hcm-lightbox__inner {
    position: relative;
    max-width: 100%;
    max-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hcm-lightbox__img {
    max-width: min(90vw, 960px);
    max-height: 85vh;
    border-radius: 10px;
    object-fit: contain;
    display: block;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
    user-select: none;
}

.hcm-lightbox__close {
    position: fixed;
    top: 16px;
    right: 16px;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    font-size: 20px;
    line-height: 1;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    backdrop-filter: blur(4px);
}

.hcm-lightbox__close:hover {
    background: rgba(255, 255, 255, 0.28);
}

/* ================================================================
   REMOVED GROUP STATE
   ================================================================ */

.hcm-conv-item--removed {
    opacity: 0.65;
    background: var(--hc-surface, #fff);
}

.hcm-conv-item--removed .hcm-conv-item__name {
    color: var(--hc-text-soft, #6b7280);
}

.hcm-group-removed-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    color: #fff;
    background: #ef4444;
    border-radius: 4px;
    padding: 1px 5px;
    margin-left: 6px;
    vertical-align: middle;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.hcm-removed-banner {
    background: #fef2f2;
    border-left: 4px solid #ef4444;
    color: #7f1d1d;
    font-size: 13px;
    line-height: 1.5;
    padding: 12px 16px;
    flex-shrink: 0;
}

.hcm-removed-banner strong {
    font-weight: 600;
}

.hcm-removed-banner__hint {
    display: block;
    margin-top: 4px;
    color: #991b1b;
    font-size: 12px;
    opacity: 0.8;
}

/* ================================================================
   CONTEXT MENU (long-press on removed group row)
   ================================================================ */

.hcm-context-menu {
    position: fixed;
    z-index: 99999;
    background: var(--hc-surface, #fff);
    border: 1px solid var(--hc-border, #e5e7eb);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    overflow: hidden;
    min-width: 180px;
    animation: hcm-menu-in 0.12s ease;
}

@keyframes hcm-menu-in {
    from { opacity: 0; transform: scale(0.95); }
    to   { opacity: 1; transform: scale(1); }
}

.hcm-context-menu__item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 13px 16px;
    font-size: 14px;
    background: none;
    border: none;
    border-bottom: 1px solid var(--hc-border, #e5e7eb);
    cursor: pointer;
    color: var(--hc-text, #111827);
    transition: background 0.1s;
    touch-action: manipulation;
}

.hcm-context-menu__item:last-child {
    border-bottom: none;
}

.hcm-context-menu__item:hover,
.hcm-context-menu__item:active {
    background: var(--hc-surface-2, #f3f4f6);
}

.hcm-context-menu__item--danger {
    color: #ef4444;
}

body.hilanaw-dark-mode .hcm-removed-banner {
    background: #450a0a;
    color: #fca5a5;
    border-left-color: #ef4444;
}

body.hilanaw-dark-mode .hcm-context-menu {
    background: #1f2937;
    border-color: #374151;
}

body.hilanaw-dark-mode .hcm-context-menu__item {
    color: #f9fafb;
    border-color: #374151;
}

body.hilanaw-dark-mode .hcm-context-menu__item:hover {
    background: #374151;
}

/* ================================================================
   PROFILE — EMAIL NOTIFICATION PREFERENCES
   ================================================================ */

.hcp-notif-prefs {
    border: 1px solid var(--hc-border, #e5e7eb);
    border-radius: 12px;
    padding: 20px;
    margin-top: 24px;
}

.hcp-notif-prefs legend {
    font-weight: 600;
    font-size: 14px;
    color: var(--hc-text, #111827);
    padding: 0 8px;
}

.hcp-notif-prefs__hint {
    font-size: 13px;
    color: var(--hc-text-soft, #6b7280);
    margin: 0 0 16px;
    line-height: 1.5;
}

.hcp-notif-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--hc-border, #f3f4f6);
    cursor: pointer;
    user-select: none;
}

.hcp-notif-toggle:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.hcp-notif-toggle input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #0046a0;
    cursor: pointer;
    flex-shrink: 0;
}

.hcp-notif-toggle__label {
    font-size: 14px;
    color: var(--hc-text, #111827);
    line-height: 1.4;
}

body.hilanaw-dark-mode .hcp-notif-prefs {
    border-color: #374151;
}

body.hilanaw-dark-mode .hcp-notif-toggle {
    border-color: #1f2937;
}

body.hilanaw-dark-mode .hcp-notif-toggle__label {
    color: #f9fafb;
}
