/* Messages page. Uses Bulma 1.0's theme variables, so it follows light/dark mode
   (the site's .theme-dark class) instead of fixed light colours. */

.dm-row {
    display: flex;
    gap: 0.75rem;
    padding: 0.5rem;
    border-radius: 8px;
    color: var(--bulma-text);
}
.dm-row:hover {
    background-color: var(--bulma-background);
    color: var(--bulma-text-strong);
}
.dm-row.is-active {
    background-color: var(--bulma-background);
    box-shadow: inset 3px 0 0 #eb6864;
}

.dm-preview {
    color: var(--bulma-text-weak);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dm-thread {
    height: 55vh;
    overflow-y: auto;
    padding: 4px;
}

.dm-bubble {
    display: inline-block;
    max-width: 80%;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.25rem;
    border-radius: 14px 14px 14px 4px;
    text-align: left;
    word-break: break-word;
    background-color: var(--bulma-background);
    color: var(--bulma-text-strong);
}
.dm-bubble.is-mine {
    border-radius: 14px 14px 4px 14px;
    background-color: #eb6864;
    color: #fff;
}
.dm-bubble.is-mine a {
    color: #fff;
    text-decoration: underline;
}

.dm-meta,
.dm-meta a {
    font-size: 0.75rem;
    color: var(--bulma-text-weak);
}
.dm-meta a:hover {
    color: var(--bulma-text-strong);
}

.dm-deleted {
    font-style: italic;
    opacity: 0.7;
}

/* Call history entries ("Missed call", "Call · 2:05"). */
.dm-call {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-style: italic;
}
.dm-call .material-symbols-outlined {
  font-size: 1.1em;
}

/* The inbox and the conversation are boxes as tall as the screen allows (messenger.fitPanes sets
   the height): the list and the thread scroll inside them, and the message box stays at the
   bottom, so nobody scrolls the page to type. */
.dm-pane {
    display: flex;
    flex-direction: column;
    margin-bottom: 0 !important;
}
.dm-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}
.dm-pane .dm-thread {
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
}
.dm-compose {
    flex: none;
}

/* Conversation header: who, then the call/mute buttons in a row (also on phones). */
.dm-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    flex: none;
    margin-bottom: 0.5rem;
}
.dm-who {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}
.dm-who strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.dm-actions {
    display: flex;
    flex-direction: row;
    flex: none;
    gap: 0.35rem;
}

/* Phones: the conversation tab can't be chosen until someone is picked in Chats. */
.tabs li.is-disabled a {
    opacity: 0.45;
    pointer-events: none;
    cursor: default;
}

/* Support cases */
.support-avatar { flex: none; width: 48px; height: 48px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: #eb6864; color: #fff; }
.support-avatar.is-small { width: 32px; height: 32px; }
.support-avatar.is-small .material-symbols-outlined { font-size: 1.2rem; }
.case-subject { font-weight: 700; text-align: center; margin: 0.25rem 0 0.75rem; }

/* Bulma's .columns pulls itself out by a full column gap on each side, which leaves the page a
   few pixels wider than the screen on phones (a sideways scroll). Pull out a little less. */
.columns.fit-columns {
    margin-inline-end: 0;
}


/* --- who's online (presence.rs): green dots, the friends-online strip, the Appear offline switch --- */
.avatar-presence { position: relative; display: inline-flex; flex: none; }
.online-dot {
    position: absolute; right: -1px; bottom: -1px; width: 12px; height: 12px; border-radius: 50%;
    background: #32de84; box-shadow: 0 0 0 2px var(--presence-ring, var(--bulma-scheme-main));
}
.image.is-32x32 .online-dot, .mb-avatar.is-small + .online-dot { width: 10px; height: 10px; }
.dm-active-now.is-off { visibility: hidden; } /* keeps its line, so the header never shifts */
.dm-active-now { display: block; font-size: 0.75rem; line-height: 1.1; color: #1fa463; }
.theme-dark .dm-active-now { color: #32de84; }
.dm-who > span { min-width: 0; display: flex; flex-direction: column; }

.dm-title-row { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.75rem; }
.dm-online { height: 76px; margin-bottom: 0.5rem; border-bottom: 1px solid var(--bulma-border-weak); flex: none; }
.dm-online-person { position: absolute; top: 2px; display: flex; flex-direction: column; align-items: center; gap: 3px; width: 54px; color: var(--bulma-text); font-size: 0.72rem; }
.dm-online-person img { width: 40px; height: 40px; object-fit: cover; }
.dm-online-person > span:last-child { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-online-person:hover { color: var(--bulma-text-strong); }

/* The online strips are virtual: the track is as wide as everyone, people are placed by index. */
.online-strip { position: relative; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; overscroll-behavior-x: contain; }
.online-strip-track { position: relative; height: 100%; min-width: 100%; }
.online-strip-empty {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 0 0.75rem;
    text-align: center; font-size: 0.75rem; line-height: 1.3; color: var(--bulma-text-weak); pointer-events: none;
}
.mb-online .online-strip-empty { color: var(--mb-weak); font-size: 11.5px; }

/* Bigger photos (profiles, room owner, cards): a bigger dot, tucked onto the photo's edge. */
.online-dot.is-large { width: 18px; height: 18px; right: 4%; bottom: 4%; box-shadow: 0 0 0 3px var(--presence-ring, var(--bulma-scheme-main)); }
.profile-photo-wrap { align-self: flex-end; }
.profile-photo-wrap .online-dot.is-large { width: 22px; height: 22px; right: 8px; bottom: 8px; box-shadow: 0 0 0 4px #fff; }
.theme-dark .profile-photo-wrap .online-dot.is-large { box-shadow: 0 0 0 4px #14161a; }
.room-head-presence { flex: none; }
.user-card-photo + .online-dot { right: 1px; bottom: 1px; }

.presence-switch { position: relative; width: 28px; height: 16px; border-radius: 999px; background: var(--bulma-border); transition: background-color 0.15s; flex: none; }
.presence-switch::after {
    content: ''; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%;
    background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); transition: transform 0.15s;
}
.presence-switch.is-on { background: #eb6864; }
.presence-switch.is-on::after { transform: translateX(12px); }

/* --- message settings (the gear in the message bar and on Messages) --- */
.chat-settings { display: flex; flex-direction: column; gap: 2px; }
.chat-settings-title { margin: 0 0 4px; padding: 4px 8px 6px; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--bulma-text-weak); }
.chat-setting {
    display: flex; align-items: flex-start; gap: 0.65rem; width: 100%; padding: 0.55rem 0.5rem; border: 0; border-radius: 10px;
    background: none; color: var(--bulma-text); font: inherit; text-align: left; cursor: pointer;
}
.chat-setting:hover { background: var(--bulma-background); }
.chat-setting .presence-switch { margin-top: 2px; }
.chat-setting-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.chat-setting-text strong { font-size: 0.85rem; color: var(--bulma-text-strong); }
.chat-setting-text small { font-size: 0.74rem; line-height: 1.35; color: var(--bulma-text-weak); }
.chat-settings.is-in-bar { flex: 1 0 auto; padding: 2px 0; }
.chat-settings.is-in-bar .chat-settings-title { color: var(--mb-weak); }
.chat-settings.is-in-bar .chat-setting { color: var(--mb-text); }
.chat-settings.is-in-bar .chat-setting:hover { background: var(--mb-raise); }
.chat-settings.is-in-bar .chat-setting-text strong { color: var(--mb-text); font-size: 13px; }
.chat-settings.is-in-bar .chat-setting-text small { color: var(--mb-weak); font-size: 11.5px; }
.chat-settings.is-in-bar .presence-switch:not(.is-on) { background: var(--mb-line); box-shadow: inset 0 0 0 1px var(--mb-weak); }
.chat-settings.is-in-bar .mb-all { margin-top: auto; }

/* Messages: the gear's menu floats over the page, so opening it moves nothing. */
.chat-settings-wrap { position: relative; }
.button.chat-gear, .button.chat-gear:focus, .button.chat-gear:active { color: var(--bulma-text-weak); text-decoration: none; box-shadow: none; }
.button.chat-gear:hover, .button.chat-gear.is-on { color: #eb6864; background: var(--bulma-background); }
.chat-settings.is-popover {
    position: absolute; z-index: 30; top: calc(100% + 6px); right: 0; width: min(320px, calc(100vw - 2rem)); padding: 0.4rem;
    border: 1px solid var(--bulma-border-weak); border-radius: 12px; background: var(--bulma-scheme-main);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

/* Under the thread on Messages: the same fixed-height status line. */
.dm-status {
    height: 20px; margin: 0.25rem 0 0; padding: 0 0.25rem; display: flex; align-items: center; justify-content: flex-end; gap: 4px;
    font-size: 0.75rem; color: var(--bulma-text-weak); white-space: nowrap; overflow: hidden; flex: none;
}
.dm-status.is-typing { justify-content: flex-start; color: #eb6864; }

/* "typing" dots */
.typing-dots { display: inline-flex; gap: 2px; margin-left: 1px; }
.typing-dots i { width: 4px; height: 4px; border-radius: 50%; background: currentColor; animation: typing-dot 1.2s infinite ease-in-out; }
.typing-dots i:nth-child(2) { animation-delay: 0.15s; }
.typing-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing-dot { 0%, 60%, 100% { opacity: 0.3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-2px); } }
@media (prefers-reduced-motion: reduce) { .typing-dots i { animation: none; opacity: 0.7; } }

/* "Who can message / call me": three fixed-width segments, so choosing never moves anything. */
.chat-choice { display: flex; flex-direction: column; gap: 5px; padding: 0.55rem 0.5rem; }
.chat-choice > strong { font-size: 0.85rem; color: var(--bulma-text-strong); }
.chat-choice > small { font-size: 0.74rem; line-height: 1.35; color: var(--bulma-text-weak); }
.chat-choice-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; padding: 2px; border-radius: 9px; background: var(--bulma-background); }
.chat-choice-options button {
    padding: 0.3rem 0.25rem; border: 0; border-radius: 7px; background: none; color: var(--bulma-text);
    font: inherit; font-size: 0.75rem; font-weight: 600; line-height: 1.2; cursor: pointer; white-space: nowrap;
}
.chat-choice-options button:hover { color: var(--bulma-text-strong); }
.chat-choice-options button.is-on { background: #eb6864; color: #fff; }
.chat-settings.is-in-bar .chat-choice > strong { color: var(--mb-text); font-size: 13px; }
.chat-settings.is-in-bar .chat-choice > small { color: var(--mb-weak); font-size: 11.5px; }
.chat-settings.is-in-bar .chat-choice-options { background: var(--mb-raise); }
.chat-settings.is-in-bar .chat-choice-options button { color: var(--mb-text); font-size: 11.5px; }
.chat-settings.is-in-bar .chat-choice-options button.is-on { color: #fff; }

/* The inbox is a virtual list (fixedRows, 72px rows): every row is one height. */
.dm-rows > .dm-slot { height: 72px; padding-bottom: 4px; }
.dm-rows .dm-row { height: 100%; align-items: center; overflow: hidden; }
.dm-rows .dm-row p:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Virtual lists with fixed-height rows (fixedRows in auth_handler.js): the list is as tall as all
   its rows; only the ones in view exist, each placed at its own top. */
.fixed-rows { position: relative; flex: none; }
.fixed-rows > * { position: absolute; left: 0; right: 0; }
