/* Consolidated chat styling layer.
   Keep chat overrides here to avoid scattered theme.css hotfixes. */

/* Lobby layout: see end of file — #ugfxChatApp wins over class-only rules. */

.ugfx-chat-shell {
  grid-template-columns: 230px minmax(0, 1fr) 240px !important;
  gap: 0.85rem !important;
}

.ugfx-chat-feed,
.ugfx-card.ugfx-chat-feed {
  min-height: 0 !important;
  height: calc(100vh - 95px) !important;
  max-height: calc(100vh - 95px) !important;
}

.ugfx-chat-messages {
  max-height: none !important;
  padding: 0.75rem 0.95rem 1rem 0.95rem !important;
  gap: 0.65rem !important;
}

.ugfx-chat-composer,
#ugfxChatForm {
  padding: 0.85rem 0.95rem 0.95rem 0.95rem !important;
}

#ugfxChatMessage {
  min-height: 72px !important;
  max-height: 140px !important;
}

/* Cap media so chat stays readable */
.ugfx-chat-media img,
.ugfx-chat-rich-media img,
.ugfx-chat-rich-embed iframe,
.ugfx-chat-sticker--image img {
  max-width: min(170px, 100%) !important;
  max-height: 170px !important;
  width: auto !important;
  height: auto !important;
  object-fit: contain !important;
}

.ugfx-chat-voice audio {
  width: min(220px, 100%) !important;
}

.ugfx-chat-users .user-row {
  padding: 0.65rem !important;
  margin-bottom: 0.55rem !important;
}

.ugfx-chat-title {
  font-size: 1.55rem !important;
}

/* Pinned bar and mod log chips */
.ugfx-pinned-bar {
  padding: 0.65rem 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 1rem;
  background: rgba(255, 124, 42, 0.05);
  margin-bottom: 0.8rem;
}

.ugfx-pinned-title {
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #f7b37e;
  margin-bottom: 0.45rem;
}

.ugfx-pinned-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.ugfx-pinned-chip {
  padding: 0.42rem 0.62rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.8rem;
  max-width: 240px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

.ugfx-modlog-item {
  padding: 0.8rem 0.9rem;
  border-radius: 0.95rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.ugfx-modlog-title {
  font-weight: 800;
}

.ugfx-modlog-sub {
  font-size: 0.78rem;
  color: #9fa7b3;
  margin-top: 0.2rem;
}

/* Mod tools readability */
.ugfx-modpanel-modal {
  width: min(1160px, calc(100vw - 1rem)) !important;
  max-height: min(88vh, 920px) !important;
}

.ugfx-modpanel-grid-wrap {
  padding: 0.8rem !important;
}

.ugfx-modpanel-card {
  padding: 0.8rem !important;
}

.ugfx-modpanel-media img {
  max-width: 170px !important;
  max-height: 130px !important;
}

/* Appearance modal quality-of-life */
.ugfx-appearance-modal {
  width: min(840px, 94vw) !important;
  max-height: min(90vh, 860px) !important;
}

.ugfx-appearance-body {
  padding-bottom: 0.4rem;
}

@media (max-width: 1200px) {
  .ugfx-chat-shell {
    grid-template-columns: 1fr !important;
  }

  .ugfx-chat-users {
    display: none !important;
  }
}

/* Migrated legacy layout rebuild rules (kept for parity) */
.ugfx-chat-shell {
  display: grid !important;
  grid-template-columns: 230px minmax(0, 1fr) 240px !important;
  gap: 1rem !important;
  align-items: stretch !important;
}

.ugfx-chat-stage,
.ugfx-chat-feed,
.ugfx-card.ugfx-chat-feed {
  min-height: calc(100vh - 95px) !important;
  height: calc(100vh - 95px) !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
}

.ugfx-chat-topbar {
  flex: 0 0 auto !important;
}

.ugfx-pinned-bar {
  flex: 0 0 auto !important;
  margin: 0 1rem 0.75rem 1rem !important;
}

.ugfx-chat-messages {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  max-height: none !important;
  height: auto !important;
  overflow-y: auto !important;
  padding: 0 1rem 1rem 1rem !important;
  gap: 0.85rem !important;
}

#ugfxChatForm,
.ugfx-chat-composer {
  flex: 0 0 auto !important;
  margin: 0 !important;
  padding: 1rem !important;
  border-top: 1px solid rgba(255, 255, 255, 0.06) !important;
  background: linear-gradient(180deg, rgba(8, 10, 14, 0.55), rgba(8, 10, 14, 0.92)) !important;
}

#ugfxChatMessage {
  min-height: 84px !important;
  max-height: 180px !important;
}

.ugfx-chat-message {
  width: 100% !important;
}

.ugfx-chat-bubble {
  display: grid !important;
  grid-template-columns: 48px minmax(0, 1fr) !important;
  gap: 0.9rem !important;
  align-items: start !important;
}

.ugfx-chat-avatar {
  width: 48px !important;
  height: 48px !important;
  border-radius: 16px !important;
  display: grid !important;
  place-items: center !important;
  flex: 0 0 48px !important;
}

.ugfx-chat-bubble-main {
  min-width: 0 !important;
  padding: 1rem 1.05rem !important;
  border-radius: 22px !important;
  background: rgba(255, 255, 255, 0.035) !important;
  border: 1px solid rgba(255, 154, 31, 0.11) !important;
}

.ugfx-chat-bubble-head {
  display: flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 0.65rem !important;
  margin-bottom: 0.35rem !important;
}

.ugfx-chat-bubble-meta {
  display: flex !important;
  align-items: center !important;
  gap: 0.55rem !important;
  flex-wrap: wrap !important;
  min-width: 0 !important;
}

.ugfx-chat-header,
.ugfx-chat-header-text {
  display: contents !important;
}

.ugfx-chat-name {
  display: inline-block !important;
  margin: 0 !important;
  line-height: 1.1 !important;
  font-weight: 800 !important;
}

.ugfx-chat-sub {
  display: inline-flex !important;
  margin: 0 !important;
  line-height: 1 !important;
}

.ugfx-chat-body {
  display: block !important;
  clear: none !important;
  padding-left: 0 !important;
  margin-top: 0 !important;
}

.ugfx-chat-text {
  line-height: 1.5 !important;
  margin: 0 !important;
}

.ugfx-chat-rich-media img,
.ugfx-chat-rich-embed iframe {
  max-width: min(280px, 100%) !important;
}

@media (max-width: 1100px) {
  .ugfx-chat-shell {
    grid-template-columns: 260px minmax(0, 1fr) !important;
  }

  .ugfx-chat-users,
  .ugfx-chat-right,
  .ugfx-chat-side-right {
    display: none !important;
  }
}

@media (max-width: 780px) {
  .ugfx-chat-shell {
    grid-template-columns: 1fr !important;
  }

  .ugfx-chat-sidebar {
    position: static !important;
    top: auto !important;
  }

  .ugfx-chat-stage,
  .ugfx-chat-feed,
  .ugfx-card.ugfx-chat-feed {
    min-height: calc(100vh - 90px) !important;
    height: calc(100vh - 90px) !important;
  }

  .ugfx-chat-messages {
    padding: 0 0.75rem 0.75rem 0.75rem !important;
  }

  #ugfxChatForm,
  .ugfx-chat-composer {
    padding: 0.75rem !important;
  }

  #ugfxChatMessage {
    min-height: 72px !important;
  }
}

/* Migrated compact message row and inline fixes */
.ugfx-chat-message {
  margin: 0 !important;
}

.ugfx-chat-bubble {
  grid-template-columns: 44px minmax(0, 1fr) !important;
  gap: 0.7rem !important;
}

.ugfx-chat-avatar {
  width: 44px !important;
  height: 44px !important;
  border-radius: 14px !important;
  font-size: 0.95rem !important;
}

.ugfx-chat-bubble-main {
  padding: 0.7rem 0.9rem !important;
  border-radius: 18px !important;
}

.ugfx-chat-bubble-head {
  margin-bottom: 0.18rem !important;
  gap: 0.45rem !important;
}

.ugfx-chat-bubble-meta {
  gap: 0.42rem !important;
  align-items: center !important;
}

.ugfx-chat-name {
  font-size: 1rem !important;
}

.ugfx-chat-sub {
  transform: translateY(-1px) !important;
}

.ugfx-chat-body {
  margin-top: 0 !important;
}

.ugfx-chat-text {
  display: inline !important;
  line-height: 1.35 !important;
  font-size: 0.98rem !important;
}

.ugfx-chat-rich-media,
.ugfx-chat-rich-embed {
  margin-top: 0.4rem !important;
}

.ugfx-chat-inline-text {
  display: inline !important;
  margin-left: 0.4rem !important;
  line-height: 1.35 !important;
  word-break: break-word !important;
}

.ugfx-chat-body {
  display: none !important;
}

/* Migrated chat appearance/font overrides */
.ugfx-chat-avatar {
  overflow: hidden;
}

.ugfx-chat-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.ugfx-chat-bubble-main,
.ugfx-chat-inline-text .ugfx-chat-text,
.ugfx-chat-body,
.ugfx-chat-text {
  color: var(--ugfx-user-color, inherit);
  font-family: var(--ugfx-user-font, inherit);
  font-size: var(--ugfx-user-size, inherit);
}

body.ugfx-appearance-open #ugfxAppearanceOverlay {
  opacity: 1;
  pointer-events: auto;
}

body.ugfx-appearance-open #ugfxAppearanceModal {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%);
}

.ugfx-appearance-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.56);
  opacity: 0;
  pointer-events: none;
  transition: 0.18s;
  z-index: 1150;
}

.ugfx-appearance-modal {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -46%);
  width: min(760px, 92vw);
  height: auto;
  max-height: min(84vh, 820px);
  background: linear-gradient(180deg, rgba(15, 13, 18, 0.98), rgba(10, 11, 15, 0.99));
  border: 1px solid rgba(255, 124, 42, 0.14);
  border-radius: 1.4rem;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: 0.18s;
  z-index: 1151;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ugfx-appearance-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.ugfx-appearance-close {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 1.3rem;
}

body.ugfx-appearance-open .ugfx-appearance-overlay {
  opacity: 1;
  pointer-events: auto;
}

body.ugfx-appearance-open .ugfx-appearance-modal {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%);
}

.ugfx-appearance-form {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: min(84vh, 820px);
}

.ugfx-appearance-body {
  overflow: auto;
  min-height: 0;
}

.ugfx-appearance-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(10, 11, 15, 0.96);
  position: sticky;
  bottom: 0;
  z-index: 2;
}

.ugfx-appearance-color-row {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
}

#ugfxAppearanceColorCustom {
  width: 74px;
  min-width: 74px;
  padding: 0.35rem;
  border-radius: 12px;
  cursor: pointer;
}

#ugfxAppearanceColorCustom:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.ugfx-appearance-preview-wrap {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.02);
}

.ugfx-appearance-preview-card {
  --ugfx-user-color: inherit;
  --ugfx-user-font: inherit;
  --ugfx-user-size: inherit;
  padding: 1rem 1.1rem;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 154, 31, 0.12);
  color: var(--ugfx-user-color, inherit);
  font-family: var(--ugfx-user-font, inherit);
  font-size: var(--ugfx-user-size, inherit);
}

.ugfx-appearance-preview-name {
  font-weight: 800;
  margin-bottom: 0.35rem;
  color: #fff;
  font-family: inherit;
  font-size: 1rem;
}

.ugfx-appearance-preview-text {
  color: var(--ugfx-user-color, inherit);
  font-family: var(--ugfx-user-font, inherit);
  font-size: var(--ugfx-user-size, inherit);
  line-height: 1.5;
}

.ugfx-chat-bubble-main .ugfx-chat-inline-text,
.ugfx-chat-bubble-main .ugfx-chat-inline-text .ugfx-chat-text,
.ugfx-chat-bubble-main .ugfx-chat-text,
.ugfx-chat-bubble-main .ugfx-chat-body {
  color: var(--ugfx-user-color, inherit) !important;
  font-family: var(--ugfx-user-font, inherit) !important;
  font-size: var(--ugfx-user-size, inherit) !important;
}

.ugfx-appearance-preview-name,
.ugfx-appearance-preview-text {
  transition: all 0.15s ease;
}

.ugfx-chat-inline-text,
.ugfx-chat-inline-text .ugfx-chat-text,
.ugfx-chat-body,
.ugfx-chat-body .ugfx-chat-text {
  font: inherit;
  color: inherit;
}

.ugfx-appearance-preview-card,
.ugfx-appearance-preview-card * {
  font-family: var(--ugfx-user-font, inherit) !important;
}

.ugfx-appearance-preview-name {
  font-family: var(--ugfx-user-font, inherit) !important;
}

.ugfx-chat-bubble-main,
.ugfx-chat-bubble-main *,
.ugfx-chat-inline-text,
.ugfx-chat-inline-text *,
.ugfx-chat-text,
.ugfx-chat-text * {
  font-family: var(--ugfx-user-font, inherit) !important;
}

[data-chat-font="system-sans"] { font-family: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, "Noto Sans", Arial, sans-serif !important; }
[data-chat-font="rounded-sans"] { font-family: "Trebuchet MS", "Arial Rounded MT Bold", Verdana, Arial, sans-serif !important; letter-spacing: 0.01em !important; }
[data-chat-font="humanist-sans"] { font-family: Candara, Optima, "Segoe UI", "Noto Sans", Arial, sans-serif !important; }
[data-chat-font="arial"] { font-family: Arial, Helvetica, "Liberation Sans", sans-serif !important; }
[data-chat-font="verdana"] { font-family: Verdana, Geneva, "DejaVu Sans", sans-serif !important; font-size: calc(var(--ugfx-user-size, 1em) * 0.98) !important; }
[data-chat-font="tahoma"] { font-family: Tahoma, Verdana, "DejaVu Sans", sans-serif !important; }
[data-chat-font="trebuchet-ms"] { font-family: "Trebuchet MS", Helvetica, Arial, sans-serif !important; }
[data-chat-font="segoe-ui"] { font-family: "Segoe UI", Tahoma, Arial, sans-serif !important; }
[data-chat-font="serif"] { font-family: Georgia, "Times New Roman", "Liberation Serif", serif !important; }
[data-chat-font="georgia"] { font-family: Georgia, "Liberation Serif", serif !important; }
[data-chat-font="times-new-roman"] { font-family: "Times New Roman", Times, "Liberation Serif", serif !important; }
[data-chat-font="palatino"] { font-family: "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif !important; letter-spacing: 0.01em !important; }
[data-chat-font="garamond"] { font-family: Garamond, "Book Antiqua", Georgia, serif !important; letter-spacing: 0.012em !important; }
[data-chat-font="monospace"] { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "DejaVu Sans Mono", monospace !important; }
[data-chat-font="courier-new"] { font-family: "Courier New", Courier, "Liberation Mono", monospace !important; }
[data-chat-font="lucida-console"] { font-family: "Lucida Console", Monaco, "DejaVu Sans Mono", monospace !important; }
[data-chat-font="comic-sans"] { font-family: "Comic Sans MS", "Comic Sans", "Chalkboard SE", cursive !important; }
[data-chat-font="impact"] { font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif !important; font-weight: 900 !important; letter-spacing: 0.02em !important; }
[data-chat-font="segoe-print"] { font-family: "Segoe Print", "Comic Sans MS", "Chalkboard SE", cursive !important; }
[data-chat-font="brush-script"] { font-family: "Brush Script MT", "Segoe Script", "Lucida Handwriting", cursive !important; font-size: calc(var(--ugfx-user-size, 1em) * 1.04) !important; }
[data-chat-font="copperplate"] { font-family: Copperplate, "Copperplate Gothic Light", fantasy !important; letter-spacing: 0.05em !important; text-transform: none !important; }

@media (max-width: 680px) {
  .ugfx-appearance-modal {
    width: min(96vw, 760px);
    max-height: 92vh;
  }

  .ugfx-appearance-actions {
    padding: 0.85rem;
    flex-wrap: wrap;
  }

  .ugfx-appearance-actions .btn {
    flex: 1 1 180px;
  }
}

/* Desktop height extension for the three chat panels */
@media (min-width: 992px) {
  #ugfxChatApp.ugfx-chat-shell {
    align-items: stretch;
    min-height: calc(100vh - 10px) !important;
  }
  #ugfxChatApp .ugfx-chat-card {
    min-height: calc(100vh - 10px) !important;
    max-height: calc(100vh - 10px) !important;
    overflow: hidden !important;
  }
  #ugfxChatApp .ugfx-chat-feed {
    min-height: calc(100vh - 10px) !important;
    height: calc(100vh - 10px) !important;
    max-height: calc(100vh - 10px) !important;
    overflow: hidden !important;
  }
  #ugfxChatApp .ugfx-chat-messages {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow-y: auto !important;
  }
  #ugfxChatApp .ugfx-chat-side {
    display: flex !important;
    flex-direction: column !important;
    min-height: calc(100vh - 10px) !important;
    max-height: calc(100vh - 10px) !important;
    overflow: hidden !important;
  }
  #ugfxChatUsers {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow-y: auto !important;
  }
}

/* Composer compact pass */
#ugfxChatApp .ugfx-chat-composer {
  padding: 0.7rem 0.85rem 0.8rem !important;
}

#ugfxChatApp #ugfxChatForm .mb-3 {
  margin-bottom: 0.45rem !important;
}

#ugfxChatApp #ugfxChatMessage {
  min-height: 56px !important;
  max-height: 92px !important;
  padding: 0.5rem 0.65rem !important;
}

#ugfxChatApp #ugfxChatForm .text-secondary.small.mt-2 {
  margin-top: 0.3rem !important;
  margin-bottom: 0 !important;
  font-size: 0.8rem !important;
  line-height: 1.25 !important;
}

#ugfxChatApp #ugfxChatForm .btn.btn-sm {
  padding: 0.34rem 0.62rem !important;
  font-size: 0.84rem !important;
}

#ugfxChatApp #ugfxChatReconnectBtn {
  padding: 0.34rem 0.66rem !important;
}

#ugfxChatApp #ugfxChatForm .d-flex.align-items-center.justify-content-between {
  gap: 0.55rem !important;
}

#ugfxChatApp #ugfxChatForm .text-secondary.small.d-flex {
  gap: 0.45rem !important;
  font-size: 0.8rem !important;
}

#ugfxChatApp #ugfxChatForm > .d-flex > .btn.ugfx-btn-primary {
  padding: 0.48rem 0.95rem !important;
  font-size: 0.95rem !important;
}

/*
 * Lobby (file guestbook): the shell is a 2- or 3-column grid for live chat.
 * With only .ugfx-chat-main, that card was auto-placed in the *first* track
 * (~230–360px), leaving the rest of the viewport empty. Drop grid entirely here.
 */
#ugfxChatApp.ugfx-chat-shell.ugfx-lobby-shell {
  display: block !important;
  width: 100% !important;
  max-width: 100%;
}

#ugfxChatApp.ugfx-lobby-shell .ugfx-chat-main {
  width: 100% !important;
  max-width: 100%;
  min-width: 0;
}

#ugfxChatApp.ugfx-lobby-shell .ugfx-chat-text {
  word-break: normal !important;
  overflow-wrap: break-word;
}

