:root {
  --text: #ffffff;
  --flora-bubble: #ff4fa3;
  --julien-bubble: #6f3ccf;
  --topbar-bg: rgba(35, 24, 52, 0.82);
  --overlay: rgba(16, 10, 26, 0.52);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--text);
  background:
    linear-gradient(var(--overlay), var(--overlay)),
    url('/conversation/assets/fond_d_ecran.jpg') center center / cover no-repeat fixed;
}

.conversation-app {
  width: min(920px, 100%);
  margin: 0 auto;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--topbar-bg);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.18);
}

.back-btn {
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 8px;
}

.title {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
}

.filter-btn {
  margin-left: auto;
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 4px 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.filter-icon {
  width: 21px;
  height: 21px;
  display: block;
  filter: brightness(0) invert(1);
}

.filter-modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
}

.filter-modal.show {
  display: block;
}
.fullscreen-btn {
  background: transparent;
  border: 0;
  padding: 6px 8px;
  color: rgba(255,255,255,0.9);
  font-size: 18px;
  line-height: 1;
}
.fullscreen-btn[aria-pressed="true"] {
  opacity: 0.9;
}

.filter-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 6, 18, 0.55);
}

.filter-panel {
  position: absolute;
  right: 12px;
  top: 62px;
  width: min(380px, calc(100vw - 24px));
  background: rgba(38, 26, 58, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.35);
}

.filter-panel h2 {
  margin: 0 0 12px;
  font-size: 16px;
}

.filter-label {
  display: block;
  font-size: 13px;
  margin: 10px 0 6px;
  opacity: 0.94;
}

.calendar-box {
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  padding: 8px;
}

.calendar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 8px;
}

.calendar-month {
  font-size: 13px;
  font-weight: 700;
}

.calendar-nav {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  cursor: pointer;
}

.calendar-weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}

.calendar-weekdays span {
  text-align: center;
  font-size: 11px;
  opacity: 0.8;
}

.calendar-day,
.calendar-empty {
  height: 30px;
}

.calendar-empty {
  pointer-events: none;
}

.calendar-day {
  border-radius: 8px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  cursor: pointer;
  font-size: 12px;
}

.calendar-day.available {
  border-color: rgba(255, 255, 255, 0.3);
}

.calendar-day:not(.available) {
  opacity: 0.35;
  cursor: not-allowed;
}

.calendar-day.selected {
  background: rgba(255, 255, 255, 0.32);
  border-color: rgba(255, 255, 255, 0.9);
}

.filter-row {
  display: flex;
  gap: 8px;
}

.filter-input {
  flex: 1;
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border-radius: 10px;
  padding: 8px 10px;
}

.filter-input:focus {
  outline: 2px solid rgba(255, 255, 255, 0.35);
  outline-offset: 0;
}

.filter-action,
.filter-close {
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  border-radius: 10px;
  padding: 8px 10px;
  cursor: pointer;
}

.filter-close {
  margin-top: 12px;
  width: 100%;
}

.filter-status {
  min-height: 18px;
  margin-top: 8px;
  font-size: 12px;
  opacity: 0.92;
}

.messages-wrap {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 10px 14px;
}

/* Loader overlay while rendering: keep loader visible, hide other children */
.messages-wrap {
  position: relative;
}
.messages-wrap .loading {
  display: none;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 20;
  width: min(80%, 420px);
}
.messages-wrap .loading .spinner {
  width: 36px;
  height: 36px;
  margin: 0 auto 8px;
  border-radius: 50%;
  border: 4px solid rgba(255,255,255,0.16);
  border-top-color: rgba(255,255,255,0.92);
  box-sizing: border-box;
  animation: spin 1s linear infinite;
}
.messages-wrap .loading .loading-text {
  font-size: 14px;
  opacity: 0.95;
}

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

/* Global full-screen loader (fallback) */
.global-loader {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 60;
  align-items: center;
  justify-content: center;
}
.global-loader .global-loader-inner {
  background: rgba(0,0,0,0.6);
  padding: 18px 20px;
  border-radius: 12px;
  text-align: center;
  color: #fff;
  width: min(90%, 420px);
}
.global-loader.show {
  display: flex;
}
.messages-wrap.loading-overlay .loading {
  display: block;
}
.messages-wrap.loading-overlay > *:not(.loading) {
  visibility: hidden;
}

.loading,
.error {
  text-align: center;
  background: rgba(0, 0, 0, 0.36);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 14px;
  padding: 10px 12px;
}

.message-row {
  display: flex;
}

.day-separator {
  align-self: center;
  margin: 8px 0 4px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(120, 120, 130, 0.38);
  color: rgba(235, 235, 240, 0.92);
  font-size: 12px;
  line-height: 1.2;
  text-align: center;
}

.message-row.match .bubble {
  outline: 2px solid rgba(255, 255, 255, 0.85);
  outline-offset: 1px;
}

.message-row.right {
  justify-content: flex-end;
}

.message-row.left {
  justify-content: flex-start;
}

.bubble {
  max-width: min(82vw, 640px);
  padding: 10px 12px;
  border-radius: 16px;
  color: #fff;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
  position: relative;
}

.bubble.has-reaction {
  margin-bottom: 14px;
}

.bubble.right {
  background: var(--flora-bubble);
  border-bottom-right-radius: 6px;
}

.bubble.left {
  background: var(--julien-bubble);
  border-bottom-left-radius: 6px;
}

.text {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.38;
  font-size: 15px;
}

.text.with-call {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inline-call-icon {
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(130, 130, 140, 0.9);
}

.inline-call-icon.ended {
  background: rgba(220, 54, 54, 0.95);
}

.inline-call-icon-img {
  width: 13px;
  height: 13px;
  display: block;
  filter: brightness(0) invert(1);
}

.meta {
  margin-top: 6px;
  text-align: right;
  font-size: 11px;
  opacity: 0.86;
}

.bubble-reaction {
  position: absolute;
  bottom: -12px;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
  border: 1.5px solid #000;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.bubble-reaction-left {
  left: 8px;
  background: var(--julien-bubble);
}

.bubble-reaction-right {
  right: 8px;
  background: var(--flora-bubble);
}

.media {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.media img,
.media video,
.media audio {
  max-width: 100%;
  border-radius: 10px;
  display: block;
}

.media img,
.media video {
  width: min(260px, 100%);
}

.media audio {
  width: min(280px, 100%);
}

.bottom-bar {
  width: min(900px, calc(100vw - 20px));
  margin: 0 auto;
  padding: 8px 0 calc(10px + env(safe-area-inset-bottom));
}

.composer {
  min-height: 46px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 7px 6px 14px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  backdrop-filter: blur(5px);
}

.composer-disabled {
  background: rgba(98, 98, 110, 0.45);
}

.composer-placeholder {
  color: rgba(255, 255, 255, 0.72);
  font-size: 13px;
  user-select: none;
}

.send-btn {
  margin-left: auto;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 0;
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.send-btn:disabled {
  background: rgba(170, 170, 178, 0.7);
  color: rgba(238, 238, 242, 0.8);
  cursor: not-allowed;
}

@media (max-width: 560px) {
  .messages-wrap {
    padding: 12px 8px 18px;
  }

  .bubble {
    max-width: 88vw;
  }
}
