/* Messagerie LuminaTV — widget client + inbox staff */

.chat-widget {
  position: fixed;
  right: 1.15rem;
  bottom: 1.15rem;
  z-index: 80;
  font-family: var(--font, "Outfit", system-ui, sans-serif);
}

.chat-widget.chat-widget-hidden {
  display: none;
}

.chat-fab {
  width: 52px;
  height: 52px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(160deg, #6b94ff, #4f7cff 55%, #6b3db4);
  box-shadow: 0 14px 32px rgba(79, 124, 255, 0.42);
  position: relative;
}

.chat-fab:hover {
  filter: brightness(1.06);
}

.chat-fab-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 1.2rem;
  height: 1.2rem;
  padding: 0 0.28rem;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  display: grid;
  place-items: center;
  line-height: 1;
}

.chat-panel {
  position: absolute;
  right: 0;
  bottom: calc(52px + 0.75rem);
  width: min(360px, calc(100vw - 1.5rem));
  height: min(480px, calc(100vh - 6.5rem));
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  overflow: hidden;
  background: linear-gradient(165deg, rgba(24, 24, 32, 0.98), rgba(8, 8, 12, 0.98));
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}

.chat-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(79, 124, 255, 0.12);
}

.chat-panel-head strong {
  display: block;
  font-size: 0.98rem;
}

.chat-panel-head p {
  margin: 0.15rem 0 0;
  color: var(--muted, #a1a1aa);
  font-size: 0.82rem;
}

.chat-close {
  border: 0;
  background: transparent;
  color: var(--muted, #a1a1aa);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.15rem;
}

.chat-messages {
  flex: 1;
  overflow: auto;
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.chat-empty {
  margin: auto;
  text-align: center;
  color: var(--muted, #a1a1aa);
  font-size: 0.92rem;
  line-height: 1.45;
  padding: 1rem;
}

.chat-bubble {
  max-width: 88%;
  padding: 0.55rem 0.7rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.chat-bubble.mine {
  align-self: flex-end;
  background: rgba(79, 124, 255, 0.22);
  border-color: rgba(79, 124, 255, 0.28);
}

.chat-bubble.theirs {
  align-self: flex-start;
}

.chat-bubble-meta {
  font-size: 0.7rem;
  color: var(--muted, #a1a1aa);
  margin-bottom: 0.2rem;
}

.chat-bubble-body {
  font-size: 0.9rem;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-compose {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.25);
}

.chat-compose input,
.chat-compose textarea {
  width: 100%;
  box-sizing: border-box;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(12, 12, 16, 0.9);
  color: var(--text, #f5f5f7);
  padding: 0.55rem 0.7rem;
  font: inherit;
  resize: none;
}

.chat-compose input:focus,
.chat-compose textarea:focus {
  outline: none;
  border-color: rgba(79, 124, 255, 0.55);
}

.chat-compose-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.45rem;
  align-items: end;
}

.chat-send {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 11px;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(180deg, #6b94ff, #4f7cff);
}

.chat-compose.is-sending {
  opacity: 0.7;
  pointer-events: none;
}

/* Staff inbox */
.chat-inbox-layout {
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  min-height: calc(100vh - 5.5rem);
}

.chat-inbox-list,
.chat-inbox-view {
  display: flex;
  flex-direction: column;
  min-height: 520px;
  max-height: calc(100vh - 6.5rem);
}

.chat-inbox-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.chat-inbox-toolbar h2 {
  margin: 0;
  font-size: 1.05rem;
}

.chat-inbox-threads {
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex: 1;
}

.chat-thread-item {
  position: relative;
  text-align: left;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  color: inherit;
  border-radius: 12px;
  padding: 0.7rem 0.8rem;
  cursor: pointer;
}

.chat-thread-item:hover,
.chat-thread-item.active {
  border-color: rgba(79, 124, 255, 0.4);
  background: rgba(79, 124, 255, 0.12);
}

.chat-thread-item.unread {
  border-color: rgba(79, 124, 255, 0.35);
}

.chat-thread-item-top {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: var(--muted, #a1a1aa);
  margin-bottom: 0.25rem;
}

.chat-thread-item-top strong {
  color: var(--text, #f5f5f7);
  font-size: 0.9rem;
}

.chat-thread-item-preview {
  font-size: 0.84rem;
  color: var(--muted, #a1a1aa);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-thread-unread {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  min-width: 1.15rem;
  height: 1.15rem;
  padding: 0 0.28rem;
  border-radius: 999px;
  background: #4f7cff;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.chat-inbox-placeholder {
  margin: auto;
  text-align: center;
  padding: 2rem;
}

.chat-inbox-active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.chat-inbox-head {
  padding-bottom: 0.75rem;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.chat-inbox-head p {
  margin: 0.2rem 0 0;
  font-size: 0.82rem;
}

.chat-inbox-messages {
  flex: 1;
  min-height: 0;
}

.chat-inbox-compose {
  margin-top: 0.5rem;
  border-radius: 12px;
}

.admin-tab .chat-tab-badge,
.chat-tab-badge {
  display: inline-grid;
  place-items: center;
  min-width: 1.1rem;
  height: 1.1rem;
  margin-left: 0.35rem;
  padding: 0 0.28rem;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  vertical-align: middle;
}

.chat-tab-badge.hidden {
  display: none;
}

@media (max-width: 900px) {
  .chat-inbox-layout {
    grid-template-columns: 1fr;
  }

  .chat-inbox-list,
  .chat-inbox-view {
    max-height: none;
    min-height: 320px;
  }
}
