:root {
  --brand: #6b2d5c;            /* set per-salon by JS */
  --ink: #241f2a;
  --muted: #8a8190;
  --in: #ffffff;               /* incoming bubble */
  --surface: #f4f1f5;          /* chat background */
  --field: #f1eef3;            /* input background */
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--surface);
}

/* ---------- App shell ---------- */
.phone {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100vh;
  height: 100dvh;            /* fits iOS/Android viewport incl. bars */
  background: var(--surface);
  overflow: hidden;
}

/* Desktop: show it as a centered phone-like frame */
@media (min-width: 480px) {
  body {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: #d9d3de;
  }
  .phone {
    width: 420px;
    height: min(780px, 92vh);
    border-radius: 26px;
    box-shadow: 0 18px 55px rgba(0, 0, 0, 0.28);
  }
}

/* ---------- Header ---------- */
.chat-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: var(--brand);
  color: #fff;
}
.avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  font-weight: 600;
  font-size: 15px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.who { flex: 1; min-width: 0; line-height: 1.25; }
.who .name {
  font-weight: 600; font-size: 16px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.who .status {
  font-size: 12px; opacity: 0.82;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.header-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.locale-toggle {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
}
.locale-option {
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: rgba(255, 255, 255, 0.78);
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 5px 8px;
}
.locale-option.active {
  background: #fff;
  color: var(--brand);
}
.icon-btn {
  background: none; border: none; color: #fff;
  font-size: 18px; line-height: 1; cursor: pointer;
  padding: 6px; border-radius: 50%;
}
.icon-btn:active { background: rgba(255, 255, 255, 0.15); }
.icon-btn.round { color: var(--brand); font-size: 20px; }
.mode-badge {
  font-size: 10px; font-weight: 700; letter-spacing: 0.5px;
  background: rgba(255, 255, 255, 0.2); padding: 3px 6px; border-radius: 6px;
}

/* ---------- Chat area ---------- */
.chat {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  /* soft brand-tinted surface so white incoming bubbles stand out */
  background: #ece8ef;
  background: color-mix(in srgb, var(--brand) 10%, #ffffff);
}
.day-divider { text-align: center; margin: 4px 0 8px; }
.day-divider span {
  background: rgba(0, 0, 0, 0.06); color: var(--muted);
  font-size: 11px; font-weight: 600; padding: 4px 12px; border-radius: 20px;
}
.encryption-note {
  align-self: center;
  background: #fff; color: var(--muted);
  font-size: 12.5px; text-align: center;
  padding: 9px 14px; border-radius: 14px;
  max-width: 90%; margin-bottom: 6px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* ---------- Bubbles ---------- */
.bubble {
  max-width: 80%;
  padding: 9px 13px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.42;
  position: relative;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.06);
  animation: pop 0.14s ease-out;
}
@keyframes pop { from { transform: translateY(4px); opacity: 0; } to { transform: none; opacity: 1; } }
.bubble.in {
  align-self: flex-start;
  background: var(--in); color: var(--ink);
  border-bottom-left-radius: 6px;
}
.bubble.out {
  align-self: flex-end;
  background: var(--brand); color: #fff;
  border-bottom-right-radius: 6px;
}
.bubble.reminder { border-left: 3px solid var(--brand); }
.bubble .meta { display: block; text-align: right; font-size: 10.5px; margin-top: 3px; color: var(--muted); }
.bubble.out .meta { color: rgba(255, 255, 255, 0.72); }

/* typing indicator */
.typing {
  align-self: flex-start; background: var(--in);
  padding: 12px 16px; border-radius: 18px; border-bottom-left-radius: 6px;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.06);
}
.typing span {
  display: inline-block; width: 7px; height: 7px; margin: 0 2px;
  background: #b8b0bd; border-radius: 50%; animation: blink 1.2s infinite both;
}
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.3; } 40% { opacity: 1; } }

/* ---------- Suggestions ---------- */
.suggestions {
  display: flex; gap: 8px;
  padding: 8px 12px 4px;
  overflow-x: auto; flex-shrink: 0;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.suggestions::-webkit-scrollbar { display: none; }
.suggestions button {
  white-space: nowrap;
  background: #fff; border: 1px solid rgba(0, 0, 0, 0.12); color: var(--brand);
  font-size: 13.5px; font-weight: 500; padding: 8px 14px; border-radius: 20px;
  cursor: pointer;
}
.suggestions button:active { background: #faf6f9; }

/* ---------- Composer (iOS-style: send button inside the field) ---------- */
.composer {
  flex-shrink: 0;
  display: flex; align-items: flex-end; gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: #fff;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}
.input-wrap { position: relative; flex: 1 1 auto; min-width: 0; display: flex; }
.composer input {
  width: 100%; min-width: 0;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: var(--field);
  border-radius: 22px;
  padding: 11px 46px 11px 16px;  /* right padding leaves room for the send button */
  font-size: 16px;               /* 16px prevents iOS zoom-on-focus */
  outline: none; color: var(--ink);
}
.composer input:focus { border-color: var(--brand); background: #fff; }
.send-btn {
  position: absolute; right: 5px; bottom: 5px;
  width: 34px; height: 34px; border-radius: 50%;
  border: none; background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; padding: 0;
}
.send-btn:active { filter: brightness(0.92); }
.send-btn svg { display: block; }

/* ---------- Below the frame (desktop only) ---------- */
.hint { display: none; }
@media (min-width: 480px) {
  .hint { display: block; color: #6b6470; font-size: 12.5px; text-align: center; max-width: 420px; margin: 12px auto 0; }
}
