/* ═══════════════════════════════════════════
   #CHAT — style.css
   Theme: Light green, clean, modern
═══════════════════════════════════════════ */

:root {
  --green-50:  #f0faf4;
  --green-100: #d8f3e3;
  --green-200: #b3e6c8;
  --green-300: #7dd3a8;
  --green-400: #4abe84;
  --green-500: #2da866;
  --green-600: #1e8f52;
  --accent:    #3cbf79;
  --accent-dk: #1e8f52;

  --bg:        #f5fcf7;
  --surface:   #ffffff;
  --surface2:  #f0faf4;
  --border:    #d0eddb;

  --text-1:    #1a2e22;
  --text-2:    #4a6858;
  --text-3:    #88a895;

  --red:       #e05252;
  --red-light: #fdeaea;

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;

  --shadow-sm: 0 2px 8px rgba(45,168,102,0.08);
  --shadow-md: 0 8px 32px rgba(45,168,102,0.12);
  --shadow-lg: 0 20px 60px rgba(45,168,102,0.18);

  --sidebar-w: 300px;
  --font: 'Nunito', sans-serif;
  --mono: 'Space Mono', monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-1);
  font-size: 15px;
  line-height: 1.5;
  overflow: hidden;
}

/* ── SCREENS ── */
.screen { display: none; width: 100vw; height: 100vh; }
.screen.active { display: flex; }

/* ══════════════════════════════════════════
   AUTH
══════════════════════════════════════════ */
#auth-screen {
  align-items: center;
  justify-content: center;
  background: var(--green-50);
  position: relative;
  overflow: hidden;
}

.auth-bg { position: absolute; inset: 0; pointer-events: none; }

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.35;
}
.blob1 { width: 500px; height: 500px; background: var(--green-300); top: -120px; left: -100px; animation: drift1 9s ease-in-out infinite alternate; }
.blob2 { width: 400px; height: 400px; background: var(--green-200); bottom: -80px; right: -60px; animation: drift2 11s ease-in-out infinite alternate; }
.blob3 { width: 300px; height: 300px; background: var(--green-400); top: 50%; left: 55%; animation: drift1 7s ease-in-out infinite alternate-reverse; }

@keyframes drift1 { from { transform: translate(0,0) scale(1); } to { transform: translate(30px,40px) scale(1.08); } }
@keyframes drift2 { from { transform: translate(0,0) scale(1); } to { transform: translate(-20px,30px) scale(1.1); } }

.auth-card {
  position: relative;
  z-index: 1;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 40px 36px 36px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
}

.logo {
  font-family: var(--mono);
  font-size: 2.4rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -1px;
  text-align: center;
  margin-bottom: 4px;
}

.tagline {
  text-align: center;
  color: var(--text-3);
  font-size: 0.85rem;
  margin-bottom: 28px;
  letter-spacing: 0.5px;
}

/* TAB BAR */
.tab-bar {
  display: flex;
  gap: 6px;
  background: var(--green-50);
  border-radius: var(--radius-md);
  padding: 5px;
  margin-bottom: 24px;
}

.tab-btn {
  flex: 1;
  padding: 9px 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-2);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}
.tab-btn.active {
  background: var(--surface);
  color: var(--accent-dk);
  box-shadow: var(--shadow-sm);
}
.tab-btn:not(.active):hover { background: var(--green-100); }

/* FORM PANELS */
.form-panel { display: none; flex-direction: column; gap: 12px; }
.form-panel.active { display: flex; }

/* INPUT GROUP */
.input-group {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--green-50);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.input-group:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(60,191,121,0.12);
}
.input-icon { font-size: 1rem; flex-shrink: 0; opacity: 0.7; }
.input-group input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 13px 0;
  font-family: var(--font);
  font-size: 0.9rem;
  color: var(--text-1);
  outline: none;
}
.input-group input::placeholder { color: var(--text-3); }

/* BUTTONS */
.btn-primary {
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
  box-shadow: 0 4px 16px rgba(60,191,121,0.3);
  margin-top: 4px;
}
.btn-primary:hover { background: var(--accent-dk); box-shadow: 0 6px 20px rgba(60,191,121,0.4); }
.btn-primary:active { transform: scale(0.98); }

.btn-secondary {
  width: 100%;
  padding: 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-2);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-secondary:hover { background: var(--green-50); border-color: var(--accent); color: var(--accent-dk); }

.form-error {
  font-size: 0.82rem;
  color: var(--red);
  min-height: 18px;
  text-align: center;
}
.form-error.success { color: var(--accent-dk); }

/* AVATAR UPLOAD */
.avatar-upload-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
.avatar-label { cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.avatar-preview {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: var(--green-100);
  border: 2px dashed var(--green-300);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  transition: border-color 0.2s;
}
.avatar-preview:hover { border-color: var(--accent); }
.avatar-preview img { width: 100%; height: 100%; object-fit: cover; }
.avatar-plus { font-size: 1.6rem; color: var(--green-400); }
.avatar-hint { font-size: 0.78rem; color: var(--text-3); }

/* ══════════════════════════════════════════
   MAIN APP
══════════════════════════════════════════ */
#app-screen { flex-direction: row; }

/* SIDEBAR */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1.5px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 18px 14px;
  border-bottom: 1.5px solid var(--border);
}

.logo-small {
  font-family: var(--mono);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.5px;
}

/* ICON BUTTONS */
.icon-btn {
  width: 36px; height: 36px;
  border: none; border-radius: var(--radius-sm);
  background: var(--green-50);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  transition: background 0.2s;
}
.icon-btn:hover { background: var(--green-100); }
.icon-btn.danger { background: var(--red-light); }
.icon-btn.danger:hover { background: #fad4d4; }
.icon-btn.danger-light { background: transparent; opacity: 0.7; }
.icon-btn.danger-light:hover { opacity: 1; background: var(--red-light); }

/* SEARCH PANEL */
.search-panel {
  padding: 12px 14px;
  border-bottom: 1.5px solid var(--border);
  background: var(--green-50);
}
.search-panel input {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-family: var(--font);
  font-size: 0.88rem;
  background: var(--surface);
  outline: none;
  color: var(--text-1);
}
.search-panel input:focus { border-color: var(--accent); }

#search-results { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }

.search-result-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
}
.search-result-item:hover { background: var(--green-100); }
.search-result-item .info { flex: 1; }
.search-result-item .info .name { font-weight: 700; font-size: 0.88rem; }
.search-result-item .info .email { font-size: 0.76rem; color: var(--text-3); }

/* CHAT LIST */
.chat-list-label {
  padding: 14px 18px 6px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-3);
}

.chat-list { flex: 1; overflow-y: auto; padding: 0 10px 10px; }
.chat-list::-webkit-scrollbar { width: 4px; }
.chat-list::-webkit-scrollbar-track { background: transparent; }
.chat-list::-webkit-scrollbar-thumb { background: var(--green-200); border-radius: 4px; }

.chat-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 10px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.15s;
  position: relative;
}
.chat-item:hover { background: var(--green-50); }
.chat-item.active { background: var(--green-100); }

.chat-item .info { flex: 1; overflow: hidden; }
.chat-item .info .name { font-weight: 700; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item .info .preview { font-size: 0.78rem; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.unread-badge {
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  border-radius: 99px;
  padding: 2px 7px;
  min-width: 20px;
  text-align: center;
}

/* SIDEBAR FOOTER */
.sidebar-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  border-top: 1.5px solid var(--border);
  background: var(--green-50);
}
.my-profile {
  display: flex; align-items: center; gap: 10px;
  cursor: pointer; flex: 1;
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  transition: background 0.15s;
}
.my-profile:hover { background: var(--green-100); }
.my-name { font-weight: 700; font-size: 0.88rem; }

/* AVATARS */
.avatar {
  border-radius: 50%;
  background: var(--green-200);
  overflow: hidden;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800;
  color: var(--accent-dk);
  font-size: 0.85rem;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 38px; height: 38px; }
.avatar.lg { width: 80px; height: 80px; font-size: 1.6rem; }
.avatar.xs { width: 28px; height: 28px; font-size: 0.7rem; }

/* ── CHAT AREA ── */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--bg);
}

.empty-state {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 14px; color: var(--text-3);
  text-align: center; line-height: 1.8;
}
.empty-logo {
  font-family: var(--mono);
  font-size: 3.5rem;
  font-weight: 700;
  color: var(--green-200);
  letter-spacing: -2px;
}

.chat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px;
  background: var(--surface);
  border-bottom: 1.5px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.chat-partner-info { display: flex; align-items: center; gap: 12px; }
.partner-name { font-weight: 800; font-size: 1rem; }
.partner-id { font-size: 0.78rem; color: var(--text-3); }

/* MESSAGES */
.messages-wrap {
  flex: 1; overflow-y: auto;
  padding: 20px;
  display: flex; flex-direction: column;
}
.messages-wrap::-webkit-scrollbar { width: 4px; }
.messages-wrap::-webkit-scrollbar-thumb { background: var(--green-200); border-radius: 4px; }

.messages-list { display: flex; flex-direction: column; gap: 6px; margin-top: auto; }

.msg-row {
  display: flex; align-items: flex-end; gap: 8px;
  max-width: 70%;
  animation: msgIn 0.2s ease;
}
@keyframes msgIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.msg-row.me { align-self: flex-end; flex-direction: row-reverse; }
.msg-row.them { align-self: flex-start; }

.bubble {
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 0.92rem;
  line-height: 1.5;
  word-break: break-word;
  max-width: 100%;
}
.msg-row.me .bubble {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.msg-row.them .bubble {
  background: var(--surface);
  color: var(--text-1);
  border: 1.5px solid var(--border);
  border-bottom-left-radius: 4px;
}

.msg-time {
  font-size: 0.68rem;
  color: var(--text-3);
  margin-bottom: 2px;
  white-space: nowrap;
}
.msg-row.me .msg-time { text-align: right; }

.msg-date-divider {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-3);
  margin: 12px 0 6px;
  position: relative;
}
.msg-date-divider::before, .msg-date-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 35%;
  height: 1px;
  background: var(--border);
}
.msg-date-divider::before { left: 0; }
.msg-date-divider::after { right: 0; }

/* MESSAGE INPUT */
.message-input-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 20px;
  background: var(--surface);
  border-top: 1.5px solid var(--border);
}
.message-input-bar input {
  flex: 1;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-family: var(--font);
  font-size: 0.92rem;
  background: var(--green-50);
  outline: none;
  color: var(--text-1);
  transition: border-color 0.2s;
}
.message-input-bar input:focus { border-color: var(--accent); background: var(--surface); }

.send-btn {
  width: 44px; height: 44px;
  border: none; border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s, transform 0.1s;
  box-shadow: 0 4px 14px rgba(60,191,121,0.3);
  flex-shrink: 0;
}
.send-btn:hover { background: var(--accent-dk); }
.send-btn:active { transform: scale(0.92); }

/* ══════════════════════════════════════════
   MODALS
══════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.25);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.modal-card {
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 36px 32px 28px;
  width: 100%; max-width: 420px;
  box-shadow: var(--shadow-lg);
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 12px;
}
.modal-card.wide { max-width: 700px; }

.modal-title {
  font-size: 1.15rem;
  font-weight: 900;
  color: var(--text-1);
}
.modal-title.sm { font-size: 0.95rem; }

.modal-close {
  position: absolute; top: 16px; right: 16px;
  width: 32px; height: 32px;
  border: none; border-radius: 50%;
  background: var(--green-50);
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.2s;
}
.modal-close:hover { background: var(--green-100); }

.divider { border: none; border-top: 1.5px solid var(--border); margin: 4px 0; }

.profile-email {
  font-size: 0.82rem;
  color: var(--text-3);
  text-align: center;
}

/* ADMIN */
.admin-tabs { display: flex; gap: 6px; padding-bottom: 12px; border-bottom: 1.5px solid var(--border); }
.admin-section { padding-top: 12px; }
.admin-section.hidden { display: none; }

.admin-search-input {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-family: var(--font);
  font-size: 0.88rem;
  outline: none;
  margin-bottom: 10px;
}
.admin-search-input:focus { border-color: var(--accent); }

.admin-user-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  margin-bottom: 6px;
  background: var(--green-50);
}
.admin-user-row .info { flex: 1; }
.admin-user-row .info .name { font-weight: 700; font-size: 0.9rem; }
.admin-user-row .info .email { font-size: 0.78rem; color: var(--text-3); }
.admin-user-row .actions { display: flex; gap: 6px; }
.btn-sm {
  padding: 5px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-family: var(--font);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-sm:hover { background: var(--green-100); border-color: var(--accent); }
.btn-sm.danger { border-color: var(--red); color: var(--red); }
.btn-sm.danger:hover { background: var(--red-light); }

.report-row {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 6px;
  background: var(--green-50);
}
.report-row .meta { font-size: 0.78rem; color: var(--text-3); margin-bottom: 4px; }
.report-row .reason { font-weight: 700; font-size: 0.88rem; }
.report-row .detail { font-size: 0.82rem; color: var(--text-2); margin-top: 2px; }

/* REPORT */
.report-select {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-family: var(--font);
  font-size: 0.88rem;
  background: var(--green-50);
  color: var(--text-1);
  outline: none;
}
.report-select:focus { border-color: var(--accent); }
.report-textarea {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-family: var(--font);
  font-size: 0.88rem;
  background: var(--green-50);
  color: var(--text-1);
  outline: none;
  resize: vertical;
  min-height: 80px;
}
.report-textarea:focus { border-color: var(--accent); }

/* UTILITIES */
.hidden { display: none !important; }

/* Admin button in sidebar */
#admin-btn-wrap {
  padding: 0 14px 10px;
}
.btn-admin {
  width: 100%;
  padding: 8px;
  border: 1.5px solid var(--green-300);
  border-radius: var(--radius-sm);
  background: var(--green-50);
  color: var(--accent-dk);
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-admin:hover { background: var(--green-100); }

/* Admin chat messages inside admin panel */
#admin-chat-messages .msg-row { max-width: 60%; }
#admin-chat-messages {
  max-height: 340px;
  overflow-y: auto;
  background: var(--green-50);
  border-radius: var(--radius-sm);
  padding: 12px;
  border: 1.5px solid var(--border);
  margin-top: 10px;
}
#admin-chat-list {
  display: flex; flex-direction: column; gap: 6px;
  max-height: 160px;
  overflow-y: auto;
}
.admin-chat-partner {
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.88rem;
  transition: background 0.15s;
}
.admin-chat-partner:hover { background: var(--green-100); }
.admin-chat-partner.active { background: var(--green-100); border-color: var(--accent); font-weight: 700; }

/* Toast */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text-1);
  color: #fff;
  padding: 11px 22px;
  border-radius: 99px;
  font-size: 0.88rem;
  font-weight: 700;
  z-index: 9999;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}
.toast.show { opacity: 1; }

/* Responsive — basic mobile adjustments */
@media (max-width: 600px) {
  :root { --sidebar-w: 100vw; }
  #app-screen { flex-direction: column; }
  .sidebar { height: auto; max-height: 50vh; }
  .chat-area { flex: 1; }
}
