/* ============================================================
   MasterZap — Design System
   Versão 4.0.2 — MSN Edition
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ── CSS Variables ─────────────────────────────────────────── */
:root {
  /* Brand Colors */
  --primary:        #1565C0;
  --primary-light:  #1976D2;
  --primary-dark:   #0D47A1;
  --primary-glow:   rgba(21, 101, 192, 0.35);

  --accent:         #76C442;
  --accent-dark:    #5EA832;
  --accent-glow:    rgba(118, 196, 66, 0.35);

  --online:         #4CAF50;
  --offline:        #9E9E9E;
  --away:           #FF9800;

  /* Chat Bubbles */
  --bubble-sent:    #76C442;
  --bubble-recv:    #1565C0;

  /* Nudge */
  --nudge-bg:       #FFE4E8;
  --nudge-border:   #F48FB1;
  --nudge-text:     #B71C1C;

  /* Surfaces */
  --bg:             #F2F4F7;
  --bg-secondary:   #E8EAED;
  --card:           #FFFFFF;
  --card-hover:     #F8F9FA;

  /* Text */
  --text:           #1A1A2E;
  --text-secondary: #5F6368;
  --text-muted:     #9AA0A6;
  --text-on-primary:#FFFFFF;

  /* Borders */
  --border:         #DFE1E5;
  --border-focus:   #1565C0;

  /* Spacing */
  --sp-xs:  4px;
  --sp-sm:  8px;
  --sp-md:  16px;
  --sp-lg:  24px;
  --sp-xl:  32px;
  --sp-2xl: 48px;

  /* Radius */
  --r-sm:   8px;
  --r-md:   12px;
  --r-lg:   16px;
  --r-xl:   20px;
  --r-2xl:  28px;
  --r-full: 9999px;

  /* Shadows */
  --sh-xs:   0 1px 3px rgba(0,0,0,.08);
  --sh-sm:   0 2px 8px rgba(0,0,0,.10);
  --sh-md:   0 4px 16px rgba(0,0,0,.12);
  --sh-lg:   0 8px 28px rgba(0,0,0,.14);
  --sh-blue: 0 4px 20px rgba(21,101,192,.45);
  --sh-green:0 4px 20px rgba(118,196,66,.45);

  /* Layout */
  --max-w:        430px;
  --header-h:     64px;
  --bottom-nav-h: 70px;

  /* Transitions */
  --t-fast:   0.15s ease;
  --t-normal: 0.25s ease;
  --t-slow:   0.4s ease;

  /* Font */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ── Reset & Base ───────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  height: 100dvh;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  overflow: hidden;
}

a {
  text-decoration: none;
  color: inherit;
}

img { display: block; max-width: 100%; }

input, button, textarea, select {
  font-family: var(--font);
  font-size: 1rem;
}

button { cursor: pointer; border: none; background: none; }

ul, ol { list-style: none; }

/* ── App Shell ──────────────────────────────────────────────── */
.app-shell {
  width: 100%;
  max-width: var(--max-w);
  height: 100dvh;
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

/* ── Typography ─────────────────────────────────────────────── */
.text-xs     { font-size: 11px; }
.text-sm     { font-size: 13px; }
.text-base   { font-size: 15px; }
.text-md     { font-size: 17px; }
.text-lg     { font-size: 20px; }
.text-xl     { font-size: 24px; }
.text-2xl    { font-size: 30px; }

.font-light  { font-weight: 300; }
.font-normal { font-weight: 400; }
.font-medium { font-weight: 500; }
.font-semi   { font-weight: 600; }
.font-bold   { font-weight: 700; }
.font-black  { font-weight: 800; }

.text-primary   { color: var(--primary); }
.text-accent    { color: var(--accent-dark); }
.text-muted     { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-center    { text-align: center; }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-sm);
  width: 100%;
  padding: 15px var(--sp-lg);
  border-radius: var(--r-full);
  font-weight: 600;
  font-size: 16px;
  transition: all var(--t-normal);
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0);
  transition: background var(--t-fast);
}

.btn:hover::after {
  background: rgba(255,255,255,0.12);
}

.btn:active {
  transform: scale(0.97);
}

/* Primary — Blue Glossy */
.btn-primary {
  background: linear-gradient(180deg, #2979FF 0%, #1565C0 50%, #0D47A1 100%);
  color: #fff;
  box-shadow: var(--sh-blue), inset 0 1px 0 rgba(255,255,255,0.25);
}

.btn-primary:hover {
  box-shadow: 0 6px 24px rgba(21,101,192,.6), inset 0 1px 0 rgba(255,255,255,0.25);
}

/* Accent — Green Glossy */
.btn-accent {
  background: linear-gradient(180deg, #92D050 0%, #76C442 50%, #5EA832 100%);
  color: #fff;
  box-shadow: var(--sh-green), inset 0 1px 0 rgba(255,255,255,0.25);
}

/* Danger — Red Glossy */
.btn-danger {
  background: linear-gradient(180deg, #EF5350 0%, #C62828 100%);
  color: #fff;
  box-shadow: 0 4px 16px rgba(198,40,40,.35);
}

/* Ghost */
.btn-ghost {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--border);
}

.btn-ghost:hover {
  background: var(--bg-secondary);
}

/* Icon Button */
.btn-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--r-full);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--t-fast);
  flex-shrink: 0;
}

.btn-icon:hover {
  background: var(--bg-secondary);
}

/* ── Inputs ─────────────────────────────────────────────────── */
.input-group {
  display: flex;
  flex-direction: column;
  gap: var(--sp-xs);
}

.input-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: var(--sp-xs);
}

.input-label svg, .input-label .icon {
  color: var(--text-secondary);
  flex-shrink: 0;
}

.input-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-wrap svg.input-icon {
  position: absolute;
  left: 14px;
  color: var(--text-muted);
  pointer-events: none;
  flex-shrink: 0;
}

.input {
  width: 100%;
  padding: 13px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  outline: none;
}

.input.has-icon {
  padding-left: 44px;
}

.input.has-toggle {
  padding-right: 48px;
}

.input::placeholder {
  color: var(--text-muted);
}

.input:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.input-toggle {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  display: flex;
  align-items: center;
  transition: color var(--t-fast);
}

.input-toggle:hover { color: var(--primary); }

/* Checkbox */
.checkbox-row {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  cursor: pointer;
  user-select: none;
}

.checkbox-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}

.checkbox-row label {
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
}

/* ── Avatar ─────────────────────────────────────────────────── */
.avatar {
  border-radius: var(--r-full);
  object-fit: cover;
  flex-shrink: 0;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.avatar-sm  { width: 36px; height: 36px; font-size: 14px; }
.avatar-md  { width: 44px; height: 44px; font-size: 17px; }
.avatar-lg  { width: 56px; height: 56px; font-size: 22px; }
.avatar-xl  { width: 88px; height: 88px; font-size: 32px; }

.avatar-wrap {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
}

.status-dot {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--card);
  background: var(--offline);
}

.status-dot.online  { background: var(--online); animation: pulse-online 2s infinite; }
.status-dot.away    { background: var(--away); }
.status-dot.offline { background: var(--offline); }

.status-dot-lg {
  width: 18px;
  height: 18px;
  border: 3px solid #fff;
  bottom: 3px;
  right: 3px;
}

/* ── Status Badge ───────────────────────────────────────────── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-xs);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  box-shadow: var(--sh-xs);
}

.status-badge .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--online);
  animation: pulse-online 2s infinite;
}

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
  overflow: hidden;
}

/* ── Header ─────────────────────────────────────────────────── */
.header {
  height: var(--header-h);
  background: var(--card);
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  padding: 0 var(--sp-md);
  box-shadow: 0 1px 0 var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}

.header-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  flex: 1;
}

/* ── Bottom Navigation ──────────────────────────────────────── */
.bottom-nav {
  height: var(--bottom-nav-h);
  background: var(--card);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  position: sticky;
  bottom: 0;
  z-index: 100;
  flex-shrink: 0;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  transition: color var(--t-fast);
  position: relative;
  cursor: pointer;
  text-decoration: none;
}

.nav-item svg { transition: transform var(--t-fast); }

.nav-item:hover {
  color: var(--primary-light);
}

.nav-item:hover svg {
  transform: translateY(-2px);
}

.nav-item.active {
  color: var(--primary);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 25%;
  right: 25%;
  height: 3px;
  background: var(--primary);
  border-radius: 0 0 var(--r-sm) var(--r-sm);
}

.nav-badge {
  position: absolute;
  top: 8px;
  right: calc(50% - 18px);
  background: #F44336;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 17px;
  height: 17px;
  border-radius: var(--r-full);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid #fff;
}

/* ── Scrollable Content ─────────────────────────────────────── */
.scroll-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.scroll-area::-webkit-scrollbar { width: 4px; }
.scroll-area::-webkit-scrollbar-track { background: transparent; }
.scroll-area::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ── Chat Bubbles ───────────────────────────────────────────── */
.messages-area {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--sp-md);
  padding-bottom: var(--sp-xl);
}

.msg-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-width: 78%;
}

.msg-group.sent  { align-self: flex-end; align-items: flex-end; }
.msg-group.recv  { align-self: flex-start; align-items: flex-start; }

.bubble {
  padding: 11px 15px;
  font-size: 15px;
  line-height: 1.45;
  word-break: break-word;
  position: relative;
  animation: bubble-in var(--t-normal) ease both;
}

/* Sent — Green */
.bubble.sent {
  background: var(--bubble-sent);
  color: #fff;
  border-radius: var(--r-xl) var(--r-xl) var(--r-sm) var(--r-xl);
  box-shadow: 0 2px 8px rgba(118,196,66,.3);
}

/* Received — Blue */
.bubble.recv {
  background: var(--bubble-recv);
  color: #fff;
  border-radius: var(--r-xl) var(--r-xl) var(--r-xl) var(--r-sm);
  box-shadow: 0 2px 8px rgba(21,101,192,.25);
}

/* First/last bubble rounding adjustments */
.msg-group.sent  .bubble:last-child  { border-bottom-right-radius: var(--r-xl); }
.msg-group.recv  .bubble:last-child  { border-bottom-left-radius: var(--r-xl); }

.bubble-time {
  font-size: 11px;
  color: var(--text-muted);
  padding: 0 4px;
  margin-top: 2px;
}

/* Date Separator */
.date-sep {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: var(--sp-md) 0;
}

.date-sep span {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 14px;
  border-radius: var(--r-full);
  letter-spacing: 0.5px;
}

/* Nudge Notification */
.nudge-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-sm);
  background: var(--nudge-bg);
  border: 1px solid var(--nudge-border);
  border-radius: var(--r-full);
  padding: 8px 20px;
  font-size: 13px;
  font-weight: 600;
  color: var(--nudge-text);
  align-self: center;
  animation: nudge-shake 0.5s ease;
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: var(--bubble-recv);
  border-radius: var(--r-xl) var(--r-xl) var(--r-xl) var(--r-sm);
  align-self: flex-start;
  width: fit-content;
  opacity: 0.8;
}

.typing-dot {
  width: 7px;
  height: 7px;
  background: rgba(255,255,255,0.85);
  border-radius: 50%;
  animation: typing-bounce 1.2s infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

/* ── Chat Input Bar ─────────────────────────────────────────── */
.chat-input-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-xs);
  padding: 10px 12px;
  background: var(--card);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  box-sizing: border-box;
}

.chat-input {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--r-full);
  padding: 9px 14px;
  font-size: 14px;
  outline: none;
  color: var(--text);
  transition: border-color var(--t-fast);
}

.chat-input::placeholder { color: var(--text-muted); }

.chat-input:focus {
  border-color: var(--primary);
  background: #fff;
}

.btn-send {
  width: 40px;
  height: 40px;
  border-radius: var(--r-full);
  background: linear-gradient(135deg, var(--primary-light), var(--primary-dark));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: var(--sh-blue);
  transition: all var(--t-normal);
}

.btn-send:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 20px rgba(21,101,192,.55);
}

.btn-send:active { transform: scale(0.95); }

/* ── Contact List Item ──────────────────────────────────────── */
.contact-item {
  display: flex;
  align-items: center;
  gap: var(--sp-md);
  padding: 12px var(--sp-md);
  cursor: pointer;
  transition: background var(--t-fast);
  text-decoration: none;
  color: inherit;
  position: relative;
}

.contact-item:hover, .contact-item:focus {
  background: var(--card-hover);
}

.contact-item:not(:last-child)::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 76px;
  right: 0;
  height: 1px;
  background: var(--border);
}

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

.contact-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.contact-preview {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.contact-time {
  font-size: 12px;
  color: var(--text-muted);
}

.unread-badge {
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  border-radius: var(--r-full);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

/* ── Settings List ──────────────────────────────────────────── */
.settings-section {
  padding: 0 var(--sp-md);
}

.settings-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text-muted);
  padding: var(--sp-md) 0 var(--sp-sm);
  text-transform: uppercase;
}

.settings-card {
  background: var(--card);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-xs);
  overflow: hidden;
}

.settings-item {
  display: flex;
  align-items: center;
  gap: var(--sp-md);
  padding: 15px var(--sp-md);
  cursor: pointer;
  transition: background var(--t-fast);
  position: relative;
  text-decoration: none;
  color: inherit;
}

.settings-item:hover { background: var(--card-hover); }

.settings-item:not(:last-child)::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 54px;
  right: 0;
  height: 1px;
  background: var(--border);
}

.settings-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.settings-icon.blue   { background: #E3F2FD; color: #1565C0; }
.settings-icon.green  { background: #E8F5E9; color: #2E7D32; }
.settings-icon.orange { background: #FFF3E0; color: #E65100; }
.settings-icon.purple { background: #F3E5F5; color: #6A1B9A; }
.settings-icon.red    { background: #FFEBEE; color: #B71C1C; }

.settings-content { flex: 1; min-width: 0; }
.settings-title { font-size: 15px; font-weight: 500; }
.settings-sub   { font-size: 12px; color: var(--text-muted); margin-top: 1px; }

.settings-chevron { color: var(--text-muted); flex-shrink: 0; }

/* ── Auth Pages ─────────────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  background: linear-gradient(160deg, #E8F0FE 0%, #F2F4F7 50%, #E8F5E9 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--sp-lg) var(--sp-md);
  gap: var(--sp-lg);
}

.auth-logo-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-sm);
}

.auth-logo {
  width: 90px;
  height: 90px;
  object-fit: contain;
}

.auth-title {
  font-size: 28px;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.5px;
}

.auth-sub {
  font-size: 14px;
  color: var(--text-secondary);
  text-align: center;
}

.auth-card {
  background: var(--card);
  border-radius: var(--r-2xl);
  padding: var(--sp-xl) var(--sp-lg);
  box-shadow: var(--sh-md);
  width: 100%;
  max-width: 370px;
  display: flex;
  flex-direction: column;
  gap: var(--sp-md);
}

.auth-footer {
  font-size: 13px;
  color: var(--text-secondary);
  text-align: center;
}

.auth-footer a {
  color: var(--accent-dark);
  font-weight: 600;
}

.auth-footer a:hover {
  text-decoration: underline;
}

.auth-link-primary {
  color: var(--primary);
  font-weight: 600;
  font-size: 13px;
}

.auth-link-primary:hover {
  text-decoration: underline;
}

.page-footer {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  flex-wrap: wrap;
  justify-content: center;
}

.page-footer a:hover { text-decoration: underline; }

/* Divider */
.divider {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  color: var(--text-muted);
  font-size: 12px;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Error / Success messages */
.msg-error {
  background: #FFEBEE;
  color: #B71C1C;
  border: 1px solid #FFCDD2;
  border-radius: var(--r-md);
  padding: 10px var(--sp-md);
  font-size: 13px;
  font-weight: 500;
  display: none;
  align-items: center;
  gap: var(--sp-sm);
}

.msg-error.show { display: flex; }

.msg-success {
  background: #E8F5E9;
  color: #2E7D32;
  border: 1px solid #C8E6C9;
  border-radius: var(--r-md);
  padding: 10px var(--sp-md);
  font-size: 13px;
  font-weight: 500;
  display: none;
  align-items: center;
  gap: var(--sp-sm);
}

.msg-success.show { display: flex; }

/* Spinner */
.spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: none;
}

.loading .spinner { display: block; }
.loading .btn-text { display: none; }

/* ── Profile Page ───────────────────────────────────────────── */
.profile-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-sm);
  padding: var(--sp-xl) var(--sp-md) var(--sp-lg);
}

.profile-name {
  font-size: 22px;
  font-weight: 700;
}

.profile-email {
  font-size: 14px;
  color: var(--primary-light);
  font-weight: 500;
}

.status-input {
  width: 100%;
  max-width: 280px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  padding: 10px 14px;
  font-size: 14px;
  color: var(--text-secondary);
  font-style: italic;
  outline: none;
  text-align: center;
  transition: border-color var(--t-fast);
}

.status-input:focus {
  border-color: var(--primary);
  background: #fff;
}

/* ── Search Bar ─────────────────────────────────────────────── */
.search-bar {
  padding: var(--sp-sm) var(--sp-md);
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.search-wrap svg {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 10px 14px 10px 40px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--r-full);
  font-size: 14px;
  outline: none;
  color: var(--text);
  transition: border-color var(--t-fast);
}

.search-input::placeholder { color: var(--text-muted); }
.search-input:focus { border-color: var(--primary); background: #fff; }

/* ── Section Header ─────────────────────────────────────────── */
.section-header {
  padding: var(--sp-md) var(--sp-md) var(--sp-sm);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ── Empty State ────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-md);
  padding: var(--sp-2xl) var(--sp-lg);
  text-align: center;
  color: var(--text-muted);
}

.empty-state svg {
  opacity: 0.35;
}

/* ── Toast ──────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: calc(var(--bottom-nav-h) + 16px);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #333;
  color: #fff;
  padding: 10px 20px;
  border-radius: var(--r-full);
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  transition: all var(--t-normal);
  pointer-events: none;
  white-space: nowrap;
  z-index: 999;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Animations ─────────────────────────────────────────────── */
@keyframes pulse-online {
  0%, 100% { box-shadow: 0 0 0 0 rgba(76,175,80,0.5); }
  50%       { box-shadow: 0 0 0 4px rgba(76,175,80,0); }
}

@keyframes bubble-in {
  from { opacity: 0; transform: translateY(6px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes nudge-shake {
  0%,100% { transform: translateX(0); }
  20%     { transform: translateX(-5px); }
  40%     { transform: translateX(5px); }
  60%     { transform: translateX(-3px); }
  80%     { transform: translateX(3px); }
}

@keyframes typing-bounce {
  0%,60%,100% { transform: translateY(0); }
  30%         { transform: translateY(-5px); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slide-up {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

.fade-in  { animation: fade-in 0.3s ease both; }
.slide-up { animation: slide-up 0.35s ease both; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (min-width: 430px) {
  body {
    background: #D8DCE3;
    align-items: center;
  }

  .app-shell {
    border-radius: var(--r-2xl);
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    height: 100vh;
    max-height: 900px;
  }

  .auth-page {
    justify-content: center;
    padding: var(--sp-xl);
  }
}

/* ── Utility ────────────────────────────────────────────────── */
.flex         { display: flex; }
.flex-col     { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm  { gap: var(--sp-sm); }
.gap-md  { gap: var(--sp-md); }
.w-full  { width: 100%; }
.hidden  { display: none !important; }
.p-md    { padding: var(--sp-md); }
.mt-sm   { margin-top: var(--sp-sm); }
.mt-md   { margin-top: var(--sp-md); }
.mt-lg   { margin-top: var(--sp-lg); }

/* ── Contact menu button ─────────────────────────────────────── */
.contact-menu-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-full);
  flex-shrink: 0;
  transition: background var(--t-fast), color var(--t-fast);
  line-height: 1;
}

.contact-menu-btn:hover {
  background: var(--bg-secondary);
  color: var(--text);
}

/* ── Context Menu ────────────────────────────────────────────── */
.ctx-menu {
  position: fixed;
  background: var(--card);
  border-radius: var(--r-md);
  box-shadow: var(--sh-lg);
  border: 1px solid var(--border);
  z-index: 9999;
  overflow: hidden;
  min-width: 180px;
  animation: fade-in 0.15s ease both;
}

.ctx-item {
  display: block;
  width: 100%;
  padding: 12px var(--sp-md);
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
  transition: background var(--t-fast);
}

.ctx-item:hover { background: var(--card-hover); }
.ctx-item.danger { color: #C62828; }
.ctx-item.danger:hover { background: #FFEBEE; }

/* ── Modal Overlay ───────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-normal);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal-box {
  background: var(--card);
  border-radius: var(--r-2xl) var(--r-2xl) 0 0;
  width: 100%;
  max-width: var(--max-w);
  padding: var(--sp-md) var(--sp-md) var(--sp-xl);
  transform: translateY(40px);
  transition: transform var(--t-normal);
  max-height: 85vh;
  overflow-y: auto;
}

.modal-overlay.active .modal-box {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-md);
  padding: var(--sp-sm) 0;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
}

.modal-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: var(--sp-xs);
}

/* ── Search Result Card ──────────────────────────────────────── */
.search-result-card {
  display: flex;
  align-items: center;
  gap: var(--sp-md);
  padding: var(--sp-md);
  background: var(--bg);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  animation: fade-in 0.2s ease both;
}

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

.search-result-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-email {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-loading,
.search-empty {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  padding: var(--sp-md);
}

/* ── Friend Request Cards ────────────────────────────────────── */
.request-card {
  display: flex;
  align-items: center;
  gap: var(--sp-md);
  padding: 12px var(--sp-md);
  animation: fade-in 0.2s ease both;
  position: relative;
}

.request-card:not(:last-child)::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 76px;
  right: 0;
  height: 1px;
  background: var(--border);
}

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

.request-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.request-sub {
  font-size: 12px;
  color: var(--text-muted);
}

.request-actions {
  display: flex;
  gap: var(--sp-xs);
  flex-shrink: 0;
}

.req-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--r-full);
  border: none;
  cursor: pointer;
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--t-fast);
}

.req-btn.accept {
  background: #E8F5E9;
  color: #2E7D32;
}

.req-btn.accept:hover {
  background: #C8E6C9;
  transform: scale(1.08);
}

.req-btn.reject {
  background: #FFEBEE;
  color: #B71C1C;
}

.req-btn.reject:hover {
  background: #FFCDD2;
  transform: scale(1.08);
}

/* ── Chat Header ────────────────────────────────────────────── */
.chat-header {
  height: var(--header-h);
  background: var(--card);
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  padding: 0 var(--sp-md);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}

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

.chat-header-name {
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-header-status {
  font-size: 12px;
  color: var(--online);
  font-weight: 500;
}

.chat-header-status.offline {
  color: var(--text-muted);
}

.chat-header-actions {
  display: flex;
  gap: var(--sp-xs);
}

.messages-wrap {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  background: var(--bg);
}

.messages-wrap::-webkit-scrollbar { width: 4px; }
.messages-wrap::-webkit-scrollbar-track { background: transparent; }
.messages-wrap::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
