/* css/chat.css */

/* ════════════════════════════════════════════════
   CHAT TAB SHELL
   ════════════════════════════════════════════════ */
.chat-tab {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  position: relative;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 12px;
  background: rgba(8,13,26,0.85);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  flex-shrink: 0;
}

.chat-header-title {
  font-family: 'Sora', sans-serif;
  font-size: 22px; font-weight: 800;
}

.chat-header-actions { display: flex; gap: 4px; }

.chat-hbtn {
  width: 38px; height: 38px;
  background: none; border: none;
  color: #7B5CFF;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background 0.18s;
}

.chat-hbtn:hover { background: rgba(123,92,255,0.12); }

/* ── Subtabs ── */
.chat-subtabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-subtab {
  flex: 1;
  padding: 12px;
  background: none; border: none;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px; font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.18s;
}

.chat-subtab.active {
  color: #7B5CFF;
  border-bottom-color: #7B5CFF;
  font-weight: 700;
}

/* ── Chat list ── */
.chat-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 80px;
}

/* ── Chat tile ── */
.chat-tile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  transition: background 0.15s;
}

.chat-tile:hover { background: rgba(255,255,255,0.04); }

.ct-avatar {
  width: 50px; height: 50px;
  border-radius: 50%;
  background: rgba(123,92,255,0.15);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700; color: #a78bfa;
  flex-shrink: 0;
  overflow: hidden;
}

.ct-avatar img { width: 100%; height: 100%; object-fit: cover; }
.ct-avatar-group { background: rgba(208,86,160,0.15); color: #f0abfc; }

.ct-info { flex: 1; min-width: 0; }

.ct-name {
  font-weight: 700; font-size: 15px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.ct-last {
  font-size: 13px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-top: 3px;
}

.ct-meta {
  display: flex; flex-direction: column;
  align-items: flex-end; gap: 5px;
  flex-shrink: 0;
}

.ct-time { font-size: 11px; color: var(--muted); }

.ct-badge {
  background: #7B5CFF;
  color: #fff;
  font-size: 11px; font-weight: 700;
  border-radius: 100px;
  padding: 2px 8px;
  min-width: 20px; text-align: center;
}

/* ── FAB ── */
.chat-fab {
  position: absolute;
  bottom: 88px; right: 16px;
  width: 52px; height: 52px;
  background: #7B5CFF;
  border: none; border-radius: 50%;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(123,92,255,0.45);
  transition: transform 0.2s;
  z-index: 5;
}

.chat-fab:hover { transform: scale(1.08); }

/* ── Menu ── */
.chat-menu-list { display: flex; flex-direction: column; gap: 4px; padding-bottom: 8px; }

.chat-menu-item {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  background: none; border: none;
  color: var(--text);
  font-size: 15px; font-weight: 500;
  cursor: pointer;
  border-radius: 12px;
  transition: background 0.15s;
  text-align: left;
  width: 100%;
  font-family: 'DM Sans', sans-serif;
}

.chat-menu-item:hover { background: rgba(255,255,255,0.06); }
.chat-menu-item-danger { color: #fca5a5; }
.chat-menu-item-danger:hover { background: rgba(239,68,68,0.1); }
.chat-menu-icon { font-size: 18px; }

/* ── Attach grid ── */
.chat-attach-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 12px;
  margin: 16px 0;
}

.chat-attach-btn {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: color-mix(in srgb, var(--ac) 12%, transparent);
  border: none; border-radius: 16px;
  padding: 16px 8px;
  cursor: pointer;
  transition: background 0.18s;
}

.chat-attach-btn:hover { background: color-mix(in srgb, var(--ac) 20%, transparent); }
.chat-attach-btn span  { font-size: 28px; }
.chat-attach-btn small { font-size: 11px; color: var(--text); font-weight: 500; }

/* ════════════════════════════════════════════════
   CHAT SCREEN
   ════════════════════════════════════════════════ */
.cs-page {
  display: flex; flex-direction: column;
  height: 100%; background: var(--dark);
  overflow: hidden;
}

.cs-header {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  background: rgba(8,13,26,0.9);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  flex-shrink: 0;
}

.cs-back-btn {
  width: 36px; height: 36px;
  background: none; border: none;
  color: #7B5CFF;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
  transition: background 0.15s;
}

.cs-back-btn:hover { background: rgba(123,92,255,0.12); }

.cs-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: rgba(123,92,255,0.15);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700; color: #a78bfa;
  flex-shrink: 0; overflow: hidden;
}

.cs-avatar img { width: 100%; height: 100%; object-fit: cover; }
.cs-avatar-group { background: rgba(208,86,160,0.15); color: #f0abfc; }

.cs-header-info { flex: 1; min-width: 0; }
.cs-header-name { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cs-header-status { font-size: 12px; color: var(--muted); }

/* ── Messages ── */
.cs-messages {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px;
  display: flex; flex-direction: column; gap: 2px;
}

.cs-empty {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  margin: auto;
  padding: 40px;
}

/* ── Bubbles ── */
.cs-bubble-wrap {
  display: flex;
  max-width: 75%;
  user-select: none;
}

.cs-mine   { align-self: flex-end;   }
.cs-theirs { align-self: flex-start; }

.cs-bubble {
  padding: 10px 14px;
  border-radius: 18px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  max-width: 100%;
  word-break: break-word;
}

.cs-bubble-me {
  background: #7B5CFF;
  border-bottom-right-radius: 4px;
}

.cs-bubble-them {
  background: rgba(255,255,255,0.1);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.cs-msg-text { font-size: 15px; line-height: 1.4; }
.cs-bubble-me   .cs-msg-text { color: #fff; }
.cs-bubble-them .cs-msg-text { color: var(--text); }

.cs-bubble-meta {
  display: flex; align-items: center; justify-content: flex-end;
  gap: 4px; margin-top: 4px;
}

.cs-bubble-time { font-size: 10px; }
.cs-bubble-me   .cs-bubble-time { color: rgba(255,255,255,0.65); }
.cs-bubble-them .cs-bubble-time { color: var(--muted); }

.cs-read-tick { font-size: 11px; color: rgba(255,255,255,0.75); }

/* ── Reply quote ── */
.cs-bubble-reply {
  display: flex; gap: 8px;
  margin-bottom: 8px;
  background: rgba(255,255,255,0.12);
  border-radius: 8px;
  padding: 6px 10px;
  overflow: hidden;
}

.cs-reply-bar-mini {
  width: 3px; flex-shrink: 0;
  background: rgba(255,255,255,0.7);
  border-radius: 2px;
}

.cs-reply-quote {
  font-size: 12px; color: rgba(255,255,255,0.8);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ── Media in bubbles ── */
.cs-msg-image {
  max-width: 200px; max-height: 200px;
  border-radius: 12px; object-fit: cover;
  display: block;
}

.cs-msg-file {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 0;
}

.cs-msg-file-icon { font-size: 24px; }
.cs-msg-file-name { font-size: 13px; font-weight: 600; }
.cs-msg-file-size { font-size: 11px; color: rgba(255,255,255,0.65); }

/* ── Reply preview bar ── */
.cs-reply-preview {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: rgba(255,255,255,0.05);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.cs-reply-bar {
  width: 3px; height: 36px; flex-shrink: 0;
  background: #7B5CFF; border-radius: 2px;
}

.cs-reply-info { flex: 1; min-width: 0; }
.cs-reply-label { font-size: 11px; color: #7B5CFF; font-weight: 600; }
.cs-reply-text  { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.cs-reply-close {
  background: none; border: none; color: var(--muted);
  font-size: 15px; cursor: pointer; padding: 4px;
}

/* ── Input bar ── */
.cs-input-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  background: rgba(8,13,26,0.95);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(12px);
  flex-shrink: 0;
}

.cs-attach-btn {
  width: 38px; height: 38px;
  background: none; border: none;
  color: #7B5CFF;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
  border-radius: 50%;
  transition: background 0.18s;
}

.cs-attach-btn:hover { background: rgba(123,92,255,0.12); }

.cs-input {
  flex: 1;
  background: rgba(255,255,255,0.06);
  border: none;
  border-radius: 22px;
  padding: 10px 16px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  font-family: 'DM Sans', sans-serif;
  resize: none;
}

.cs-input::placeholder { color: rgba(187,184,212,0.7); }

.cs-send-btn {
  width: 42px; height: 42px;
  background: rgba(123,92,255,0.2);
  border: none; border-radius: 50%;
  color: #7B5CFF;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
  transition: all 0.18s;
}

.cs-send-btn:hover { background: #7B5CFF; color: #fff; }

/* ════════════════════════════════════════════════
   NEW CHAT SCREEN
   ════════════════════════════════════════════════ */
.nc-page {
  display: flex; flex-direction: column;
  height: 100%; background: var(--dark);
  overflow: hidden;
}

.nc-body {
  flex: 1; overflow-y: auto; padding: 20px 16px;
}

.nc-section-title {
  font-family: 'Sora', sans-serif;
  font-size: 18px; font-weight: 800;
  margin-bottom: 8px;
}

.nc-hint { font-size: 14px; color: var(--muted); margin-bottom: 20px; line-height: 1.5; }

.nc-phone-row {
  display: flex; gap: 0;
  background: rgba(255,255,255,0.05);
  border: 1.5px solid rgba(123,92,255,0.35);
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 14px;
}

.nc-cc-btn {
  padding: 14px 16px;
  background: none;
  border: none; border-right: 1.5px solid rgba(123,92,255,0.2);
  color: #7B5CFF;
  font-size: 15px; font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  font-family: 'DM Sans', sans-serif;
  transition: background 0.18s;
}

.nc-cc-btn:hover { background: rgba(123,92,255,0.1); }

.nc-phone-input {
  flex: 1;
  background: none; border: none;
  padding: 14px 16px;
  color: var(--text); font-size: 15px;
  outline: none;
  font-family: 'DM Sans', sans-serif;
}

.nc-phone-input::placeholder { color: rgba(187,184,212,0.6); }

.nc-search-btn {
  width: 100%;
  height: 50px;
  background: #7B5CFF;
  color: #fff;
  border: none; border-radius: 14px;
  font-family: 'Sora', sans-serif;
  font-size: 15px; font-weight: 700;
  cursor: pointer;
  transition: opacity 0.18s;
  margin-bottom: 24px;
}

.nc-search-btn:hover { opacity: 0.88; }

.nc-error {
  display: flex; align-items: flex-start; gap: 10px;
  background: rgba(239,68,68,0.08);
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 14px; color: #fca5a5;
  line-height: 1.5;
}

.nc-found-label {
  font-size: 13px; font-weight: 700; color: #7B5CFF;
  margin-bottom: 10px;
}

.nc-user-tile {
  display: flex; align-items: center; gap: 12px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 16px;
  cursor: pointer;
  transition: background 0.18s;
}

.nc-user-tile:hover { background: rgba(255,255,255,0.09); }

.nc-msg-btn {
  background: #7B5CFF; color: #fff;
  border: none; border-radius: 100px;
  padding: 8px 18px;
  font-size: 13px; font-weight: 700;
  cursor: pointer;
  font-family: 'Sora', sans-serif;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ════════════════════════════════════════════════
   CREATE GROUP SCREEN
   ════════════════════════════════════════════════ */
.cg-page {
  display: flex; flex-direction: column;
  height: 100%; background: var(--dark);
  overflow: hidden;
}

.cg-header-info { flex: 1; }
.cg-selected-count { font-size: 12px; color: #7B5CFF; font-weight: 600; display: block; }

.cg-create-btn {
  background: #7B5CFF; color: #fff;
  border: none; border-radius: 100px;
  padding: 8px 20px;
  font-family: 'Sora', sans-serif;
  font-size: 13px; font-weight: 700;
  cursor: pointer;
  transition: opacity 0.18s;
  flex-shrink: 0;
}

.cg-create-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.cg-name-wrap { padding: 12px 16px; border-bottom: 1px solid var(--border); }

.cg-name-input {
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1.5px solid rgba(123,92,255,0.3);
  border-radius: 14px;
  padding: 12px 16px;
  color: var(--text); font-size: 15px;
  outline: none;
  font-family: 'DM Sans', sans-serif;
  transition: border-color 0.18s;
}

.cg-name-input:focus { border-color: #7B5CFF; }
.cg-name-input::placeholder { color: rgba(187,184,212,0.6); }

.cg-selected-strip {
  display: flex; gap: 10px;
  padding: 10px 16px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.cg-chip {
  display: flex; align-items: center; gap: 6px;
  background: rgba(123,92,255,0.15);
  border-radius: 100px;
  padding: 5px 10px 5px 5px;
  white-space: nowrap;
  flex-shrink: 0;
}

.cg-chip-avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: #7B5CFF;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}

.cg-chip span { font-size: 13px; font-weight: 600; }

.cg-chip-remove {
  background: none; border: none;
  color: var(--muted); font-size: 12px;
  cursor: pointer; padding: 0 2px;
}

.cg-user-count {
  font-size: 12px; color: var(--muted);
  padding: 8px 16px;
  flex-shrink: 0;
}

.cg-search-wrap { padding: 6px 16px 8px; flex-shrink: 0; }

.cg-user-list {
  flex: 1; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.cg-user-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  transition: background 0.15s;
}

.cg-user-row:hover { background: rgba(255,255,255,0.04); }

.cg-checkbox {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.2);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: all 0.18s;
}

.cg-checked {
  background: #7B5CFF;
  border-color: #7B5CFF;
}

/* ── Responsive ── */
@media (max-width: 400px) {
  .cs-bubble-wrap { max-width: 85%; }
  .chat-attach-grid { grid-template-columns: 1fr 1fr; }
}