/* QuickChat – final color theme */
:root {
  --teal: #0f766e;
  --cyan: #0e8f9a;
  --indigo: #4f6bed;
  --teal-soft: #e6f4f1;
  --chat-bg: #eef3f7;
  --ink: #1f2937;
  --mute: #64748b;
  --line: #dbe3ea;
  --err: #ef4444;
  --seen: #9ff0ff;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  margin: 0;
  height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: #fff;
  color: var(--ink);
  color-scheme: light;
}
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.hidden { display: none !important; }

/* Login Screen */
#login { min-height: 100%; display: grid; place-items: center; padding: 24px; background: #f8fafc; }
#login form { width: 100%; max-width: 380px; background: #fff; padding: 32px; border-radius: 14px; border: 1px solid #cfd8e0; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05); }
#login h1 { margin: 0 0 6px; font-size: 28px; letter-spacing: -0.02em; color: var(--teal); font-weight: 700; }
#login p { margin: 0 0 20px; color: var(--mute); font-size: 14px; line-height: 1.5; }
.field { display: flex; gap: 8px; }
.field input { flex: 1; min-width: 0; }
#randomName { white-space: nowrap; }
input[type=text] { width: 100%; padding: 12px 14px; border: 1px solid #cfd8e0; border-radius: 10px; font-size: 15px; outline: none; }
input[type=text]:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15); }
.btn { border: 0; border-radius: 10px; padding: 12px 18px; font-weight: 600; cursor: pointer; background: #2563eb; color: #fff; font-size: 16px; }
.btn:hover { background: #1d4ed8; }
#login .btn { width: 100%; margin-top: 12px; background: linear-gradient(135deg, var(--teal), var(--indigo)); }
.err { color: var(--err); min-height: 1.4em; margin: 8px 0 0; font-size: 14px; }
.captcha { margin-top: 12px; }

/* App Layout */
#app, .app { display: flex; height: 100%; min-height: 480px; width: 100%; }
aside { width: 330px; min-width: 320px; max-width: 40%; border-right: 1px solid #dbe3ea; display: flex; flex-direction: column; background: #fff; flex-shrink: 0; }

/* Left top bar: "@laptop" + Blocked + Leave */
.me, .sidebar-header {
  height: 76px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--teal);
  color: #fff;
}
.me b, .sidebar-header b, .me #meName {
  font-size: 18px;
  font-weight: 700;
  display: block;
}
.me small, .sidebar-header .subtitle {
  display: block;
  color: rgba(255, 255, 255, 0.8);
  font-size: 11.5px;
  white-space: nowrap;      /* keep on one line */
  margin-top: 2px;
}

/* Sidebar Header Buttons (Blocked on top, Leave below) */
.me-btns {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 5px;
  flex-shrink: 0;
}
.me-btns button, .me button, #leave, .sidebar-header button {
  background: #fff !important;
  border: 1px solid #fff !important;
  color: #0f766e !important;
  font-weight: 600 !important;
  border-radius: 6px !important;
  padding: 4px 10px !important;
  font-size: 12px !important;
  line-height: 1.25;
  cursor: pointer;
  white-space: nowrap;
  text-align: center;
  transition: all 0.15s ease;
}
.me-btns button:hover, .me button:hover, #leave:hover, .sidebar-header button:hover {
  background: #e6f4f1 !important;
  border-color: #e6f4f1 !important;
  transform: translateY(-1px);
}

/* Search Box */
.search { padding: 14px 16px; border-bottom: 1px solid #e5ebf0; }
.search input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #cfd8e0;
  border-radius: 10px;
  font-size: 15px;
  outline: none;
}
.search input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
  outline: none;
}
#results { margin-top: 8px; }

/* "Conversations" label + active conversation */
.label, .conversations-label {
  padding: 12px 18px 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--teal);
  letter-spacing: 0.03em;
}
#list { overflow-y: auto; flex: 1; }
.row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  padding: 13px 16px;
  cursor: pointer;
  font-size: 16px;
  color: var(--ink);
  border-bottom: 1px solid #e5ebf0;
  transition: background 0.15s ease, border-left 0.15s ease;
  user-select: none;
  box-sizing: border-box;
}
.row:hover { background: #f8fafc; }
.row.active, .conversation.active {
  background: var(--teal-soft) !important;
  border-left: 4px solid var(--teal) !important;
  font-weight: 600;
}
.row.pinned {
  background: #fbfdfd;
}

/* Pinned badge next to username */
.pin-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--teal);
  margin-left: 2px;
  flex-shrink: 0;
}

/* Row action buttons (Pin & Remove) */
.row-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  transform: translateX(4px);
  flex-shrink: 0;
}
.row:hover .row-actions,
.row:focus-within .row-actions {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}
@media (hover: none) {
  .row-actions {
    opacity: 0.85;
    pointer-events: auto;
    transform: none;
  }
}

.row-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #64748b;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.row-btn:hover {
  transform: scale(1.08);
}
.row-btn.pin-btn:hover {
  background: #e6f4f1;
  color: var(--teal);
  border-color: var(--teal);
}
.row-btn.pin-btn.active {
  background: var(--teal);
  color: #ffffff;
  border-color: var(--teal);
}
.row-btn.remove-btn:hover {
  background: #fee2e2;
  color: #dc2626;
  border-color: #f87171;
}

/* Online dot: solid and sharp, no glow */
.dot, .online-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #22c55e !important;
  box-shadow: none !important;
  flex-shrink: 0;
}
.dot.off { background: var(--mute) !important; opacity: 0.5; }
.row .n { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .t { color: var(--teal); font-size: 13px; }
.badge { background: var(--teal); color: #fff; border-radius: 99px; font-size: 12px; padding: 1px 8px; }
.empty { padding: 16px; color: var(--mute); font-size: 14px; }

/* Main Chat Area */
main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: #fff; position: relative; }

/* Right top bar: "@shafaqq" + Block */
.head, .chat-header {
  height: 76px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--teal);
  color: #fff;
  border-bottom: none;
}
.ttl { flex: 1; min-width: 0; }
.ttl b, .head #title {
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  display: block;
}
.ttl small, .head #sub, .chat-header .status {
  display: block;
  color: #b9f5d0 !important;   /* "online" */
  font-size: 14px;
  font-weight: 400;
  margin-top: 2px;
}

/* Block button: red */
.head #blockBtn, #blockBtn, .chat-header .block-btn {
  background: #dc2626 !important;
  border: 1px solid #dc2626 !important;
  color: #fff !important;
  font-weight: 600 !important;
  border-radius: 8px !important;
  padding: 8px 16px !important;
  font-size: 14px !important;
  cursor: pointer;
  transition: background 0.15s ease;
}
.head #blockBtn:hover, #blockBtn:hover, .chat-header .block-btn:hover {
  background: #b91c1c !important;
  border-color: #b91c1c !important;
}
.back { display: none; background: none; border: 0; font-size: 22px; cursor: pointer; color: #fff; margin-right: 8px; }

/* Info strip: "Chats are shown to both of you..." (Yellow banner from user code) */
.note, .chat-notice {
  padding: 9px 20px;
  font-size: 13px;
  background: #fef08a !important;
  color: #713f12 !important;
  border-bottom: 1px solid #facc15 !important;
  font-weight: 500;
}

/* Message area */
#msgs, .messages {
  flex: 1;
  overflow-y: auto;
  background: var(--chat-bg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Messages - Compact natural chat bubbles */
.msg {
  max-width: min(72%, 520px);
  padding: 9px 14px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.4;
  overflow-wrap: anywhere;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 4px 10px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.msg-body {
  white-space: pre-wrap;
  flex: 1 1 auto;
  min-width: 0;
}

/* Sent bubble (Right) */
.msg.mine, .msg.sent {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--teal), var(--cyan)) !important;
  color: #fff !important;
  border-bottom-right-radius: 4px;
}
.msg.mine .meta, .msg.sent .meta {
  color: rgba(255, 255, 255, 0.85);
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  flex-shrink: 0;
  user-select: none;
}

/* Received bubble (Left) */
.msg:not(.mine), .msg.received {
  align-self: flex-start;
  background: #fff !important;
  color: var(--ink) !important;
  border-left: 3px solid var(--indigo) !important;
  border-bottom-left-radius: 4px;
}
.msg:not(.mine) .meta, .msg.received .meta {
  color: var(--mute);
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  flex-shrink: 0;
  user-select: none;
}

.meta .edit, .meta .unsend {
  background: none;
  border: 0;
  padding: 0;
  font-size: 11px;
  text-decoration: underline;
  cursor: pointer;
  color: inherit;
  margin-right: 5px;
  opacity: 0.85;
  transition: opacity 0.15s ease;
}
.meta .edit:hover, .meta .unsend:hover {
  opacity: 1;
}
.tick {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  line-height: 1;
}
.tick-svg {
  display: inline-block;
  vertical-align: -1px;
}
.tick.seen {
  color: var(--seen);
}
.msg a { color: inherit; text-decoration: underline; }
.sys { align-self: center; color: var(--mute); font-size: 13px; }
.placeholder { margin: auto; color: var(--mute); text-align: center; padding: 24px; }

/* Bars */
.bar { display: flex; align-items: center; gap: 8px; padding: 8px 14px; background: var(--chat-bg); border-top: 1px solid #e5ebf0; font-size: 14px; }
.bar span { flex: 1; }

/* Message input + Send button */
#send, .composer {
  display: flex;
  gap: 10px;
  padding: 12px;
  background: #fff;
  border-top: 1px solid #e5ebf0;
}
#send input, .composer input {
  flex: 1;
  min-width: 0;
  padding: 14px 16px;
  border: 2px solid #cfd8e0;
  border-radius: 12px;
  font-size: 16px;
  outline: none;
}
#send input:focus, .composer input:focus {
  border-color: var(--indigo);
  outline: none;
}
#send .btn, .composer .send-btn {
  border: 0;
  border-radius: 12px;
  padding: 0 26px;
  font-size: 17px;
  font-weight: 600;
  background: #2563eb !important;      /* blue */
  color: #fff !important;
  cursor: pointer;
  transition: background 0.15s ease;
}
#send .btn:hover, .composer .send-btn:hover {
  background: #1d4ed8 !important;
}

@media (max-width: 700px) {
  #app.chat aside { display: none; }
  #app:not(.chat) main { display: none; }
  aside { width: 100%; max-width: 100%; }
  .back { display: block; }
}

/* ==========================================================================
   Custom Modal Popup & Toast Notifications
   ========================================================================== */

/* Modal Backdrop */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}
.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

/* Modal Card */
.modal-card {
  background: #ffffff;
  width: 100%;
  max-width: 390px;
  border-radius: 20px;
  box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.25), 0 0 0 1px rgba(226, 232, 240, 0.8);
  padding: 24px;
  transform: scale(0.92) translateY(8px);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
  text-align: center;
}
.modal-overlay.open .modal-card {
  transform: scale(1) translateY(0);
}

.modal-icon-wrap {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-icon-wrap.danger {
  background: #fee2e2;
  color: #dc2626;
}
.modal-icon-wrap.primary {
  background: #e6f4f1;
  color: #0f766e;
}

.modal-title {
  font-size: 19px;
  font-weight: 700;
  color: #0f172a;
  margin: 0 0 8px;
}
.modal-desc {
  font-size: 14.5px;
  color: #64748b;
  margin: 0 0 24px;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  gap: 10px;
}
.modal-btn {
  flex: 1;
  padding: 11px 16px;
  font-size: 14.5px;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
  border: none;
}
.modal-btn.cancel {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
}
.modal-btn.cancel:hover {
  background: #e2e8f0;
  color: #1e293b;
}
.modal-btn.confirm-danger {
  background: #dc2626;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.25);
}
.modal-btn.confirm-danger:hover {
  background: #b91c1c;
}
.modal-btn.confirm-primary {
  background: #0f766e;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(15, 118, 110, 0.25);
}
.modal-btn.confirm-primary:hover {
  background: #0d655e;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 10000;
  pointer-events: none;
}
.toast {
  background: #0f172a;
  color: #ffffff;
  padding: 10px 18px;
  border-radius: 99px;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
  pointer-events: auto;
  opacity: 0;
  transform: translateY(-10px) scale(0.95);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.toast.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}
.toast.warning {
  background: #78350f;
  color: #fef3c7;
  border: 1px solid #b45309;
}
.toast.success {
  background: #064e3b;
  color: #d1fae5;
  border: 1px solid #059669;
}

/* Blocked Users Modal */
.blocked-list {
  max-height: 240px;
  overflow-y: auto;
  margin: 16px 0;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #f8fafc;
}
.blocked-user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid #e2e8f0;
  background: #ffffff;
  transition: background 0.15s ease;
}
.blocked-user-row:last-child {
  border-bottom: none;
}
.blocked-user-row:hover {
  background: #fdfefe;
}
.blocked-user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: #1e293b;
  font-size: 14.5px;
}
.blocked-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ef4444;
  flex-shrink: 0;
}
.unblock-action-btn {
  background: #e6f4f1;
  color: var(--teal);
  border: 1px solid #99f6e4;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}
.unblock-action-btn:hover {
  background: var(--teal);
  color: #ffffff;
  border-color: var(--teal);
  transform: scale(1.04);
}
.empty-blocked {
  padding: 28px 16px;
  text-align: center;
  color: #64748b;
  font-size: 14px;
}

/* ==========================================================================
   Emoji Picker & Composer Button
   ========================================================================== */

.emoji-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  border: 2px solid #cfd8e0;
  background: #f8fafc;
  color: #64748b;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
  padding: 0;
}
.emoji-btn:hover {
  background: #e6f4f1;
  color: var(--teal);
  border-color: var(--teal);
  transform: scale(1.04);
}
.emoji-btn.active {
  background: var(--teal);
  color: #fff;
  border-color: var(--teal);
}

.emoji-picker {
  position: absolute;
  bottom: 74px;
  left: 14px;
  width: 320px;
  max-width: calc(100vw - 28px);
  background: #ffffff;
  border: 1px solid #dbe3ea;
  border-radius: 16px;
  box-shadow: 0 15px 35px -5px rgba(15, 23, 42, 0.2), 0 0 0 1px rgba(226, 232, 240, 0.8);
  z-index: 100;
  animation: emojiPop 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}
@keyframes emojiPop {
  from { opacity: 0; transform: translateY(8px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.emoji-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid #edf2f7;
  background: #f8fafc;
}
.emoji-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.02em;
}
.emoji-tabs {
  display: flex;
  gap: 3px;
}
.emoji-tab {
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  transition: all 0.15s ease;
  opacity: 0.65;
}
.emoji-tab:hover {
  opacity: 1;
  background: #e2e8f0;
}
.emoji-tab.active {
  opacity: 1;
  background: #e6f4f1;
  transform: scale(1.1);
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  padding: 8px;
  max-height: 200px;
  overflow-y: auto;
  user-select: none;
}
.emoji-item {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  font-size: 20px;
  border-radius: 8px;
  cursor: pointer;
  background: none;
  border: none;
  transition: transform 0.12s ease, background 0.12s ease;
}
.emoji-item:hover {
  background: #e6f4f1;
  transform: scale(1.22);
}
