/* common.css — ইউজার ও এডমিন দুই পেজের সাধারণ স্টাইল (মোবাইল-ফার্স্ট) */

:root {
  --bg: #f3efe8;
  --surface: #ffffff;
  --surface-2: #f8f5f0;
  --surface-3: #ece7df;
  --text: #1d2320;
  --muted: #68706b;
  --border: #e0dad0;
  --accent: #0f766e;
  --accent-strong: #0b5f58;
  --accent-soft: #d5efe9;
  --on-accent: #ffffff;
  --bubble-in: #ffffff;
  --bubble-out: #d5efe9;
  --bubble-out-text: #12302c;
  --danger: #b42318;
  --online: #22c55e;
  --shadow: 0 1px 2px rgba(20, 30, 25, .06), 0 2px 8px rgba(20, 30, 25, .05);
  --radius: 18px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121715;
    --surface: #1a201e;
    --surface-2: #1f2624;
    --surface-3: #28302d;
    --text: #e6ebe8;
    --muted: #97a19c;
    --border: #2c3532;
    --accent: #2bb3a3;
    --accent-strong: #5fd0c2;
    --accent-soft: #16332f;
    --on-accent: #06201d;
    --bubble-in: #1f2624;
    --bubble-out: #174a43;
    --bubble-out-text: #e2f5f1;
    --danger: #f97066;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #121715;
  --surface: #1a201e;
  --surface-2: #1f2624;
  --surface-3: #28302d;
  --text: #e6ebe8;
  --muted: #97a19c;
  --border: #2c3532;
  --accent: #2bb3a3;
  --accent-strong: #5fd0c2;
  --accent-soft: #16332f;
  --on-accent: #06201d;
  --bubble-in: #1f2624;
  --bubble-out: #174a43;
  --bubble-out-text: #e2f5f1;
  --danger: #f97066;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; margin: 0; }
body {
  font-family: "Hind Siliguri", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.muted { color: var(--muted); }

/* ---------- লগইন / নাম স্ক্রিন ---------- */
.screen {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}
.card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 32px 24px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: center;
}
.card h1 { margin: 4px 0 0; font-size: 1.5rem; font-weight: 600; }
.card p { margin: 0; }
.card input {
  width: 100%;
  padding: 13px 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-2);
  font-size: 1rem;
  outline: none;
}
.card input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
.brand-mark {
  width: 64px;
  height: 64px;
  margin: 0 auto 4px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  font-size: 30px;
  background: var(--accent-soft);
}
.form-error { color: var(--danger); font-size: .9rem; }

/* ---------- বাটন ---------- */
.btn {
  border: 0;
  border-radius: 14px;
  padding: 12px 16px;
  font-weight: 600;
  font-size: .95rem;
  transition: background .15s, transform .05s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-strong); }
.btn.ghost { background: var(--surface-2); border: 1px solid var(--border); }
.btn.ghost:hover { background: var(--surface-3); }

.icon-btn {
  width: 40px;
  height: 40px;
  flex: none;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
}
.icon-btn:hover, .icon-btn.active { background: var(--surface-3); color: var(--text); }
.icon-btn svg { width: 22px; height: 22px; }

/* ---------- চ্যাট লেআউট ---------- */
.app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  position: relative;
}
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex: none;
}
.avatar {
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 600;
  position: relative;
}
.avatar.online::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--online);
  border: 2px solid var(--surface);
}
.title { flex: 1; min-width: 0; }
.title .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.title .sub { font-size: .8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overscroll-behavior: contain;
}
.empty { margin: auto; text-align: center; color: var(--muted); padding: 24px; max-width: 280px; }

.day-sep { display: flex; justify-content: center; margin: 12px 0 8px; }
.day-sep span {
  font-size: .75rem;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 2px 12px;
  border-radius: 999px;
}

.row { display: flex; align-items: center; gap: 6px; margin: 2px 0; }
.row.out { flex-direction: row-reverse; }
.bubble {
  max-width: min(78%, 560px);
  padding: 7px 11px 5px;
  border-radius: var(--radius);
  background: var(--bubble-in);
  box-shadow: var(--shadow);
}
.row.in .bubble { border-bottom-left-radius: 6px; }
.row.out .bubble { background: var(--bubble-out); color: var(--bubble-out-text); border-bottom-right-radius: 6px; }
.bubble .text { white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble.jumbo { background: transparent; box-shadow: none; padding: 0 4px; }
.bubble.jumbo .text { font-size: 2.4rem; line-height: 1.25; }
.meta {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  font-size: .7rem;
  color: var(--muted);
  margin-top: 1px;
}
.row.out .meta { color: color-mix(in srgb, var(--bubble-out-text) 60%, transparent); }
.row.pending .bubble { opacity: .7; }
.row.failed .bubble { outline: 1px solid var(--danger); }
.retry {
  display: block;
  margin-top: 4px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--danger);
  font-size: .8rem;
  text-decoration: underline;
  text-align: left;
}

.msg-del {
  flex: none;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: opacity .15s;
}
.row:hover .msg-del, .msg-del:focus-visible { opacity: 1; }
.msg-del:hover { color: var(--danger); }
@media (hover: none) { .msg-del { opacity: .55; } }

/* টাইপিং */
.typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 18px 6px;
  font-size: .8rem;
  color: var(--muted);
  flex: none;
}
.typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  animation: blink 1.2s infinite;
}
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }
.typing em { font-style: normal; margin-left: 6px; }
@keyframes blink {
  0%, 80%, 100% { opacity: .25; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}

/* ইনপুট বার */
.composer {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 8px 10px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex: none;
}
.composer textarea {
  flex: 1;
  min-width: 0;
  resize: none;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 8px 14px;
  background: var(--surface-2);
  min-height: 42px;
  max-height: 140px;
  line-height: 1.5;
  font-size: 1rem;
  outline: none;
}
.composer textarea:focus { border-color: var(--accent); }
.send-btn {
  width: 42px;
  height: 42px;
  flex: none;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  display: grid;
  place-items: center;
  transition: background .15s;
}
.send-btn:disabled { background: var(--surface-3); color: var(--muted); cursor: default; }
.send-btn svg { width: 20px; height: 20px; margin-left: -2px; }

/* ইমোজি প্যানেল */
.emoji-panel {
  flex: none;
  height: 260px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}
.emoji-tabs {
  display: flex;
  gap: 2px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  flex: none;
}
.emoji-tab {
  flex: none;
  width: 40px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  font-size: 20px;
}
.emoji-tab.active { background: var(--accent-soft); }
.emoji-grid {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
  align-content: start;
  padding: 6px 8px;
}
.emoji {
  height: 44px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  font-size: 26px;
  line-height: 1;
}
.emoji:hover { background: var(--surface-3); }

/* বার্তা / টোস্ট */
.banner {
  position: fixed;
  top: max(10px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  max-width: calc(100% - 32px);
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-size: .82rem;
  text-align: center;
  box-shadow: var(--shadow);
}
.toast {
  position: fixed;
  bottom: calc(90px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  max-width: calc(100% - 32px);
  padding: 8px 16px;
  border-radius: 12px;
  background: var(--text);
  color: var(--bg);
  font-size: .9rem;
  box-shadow: var(--shadow);
}
