/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Screen reader only */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* Fix h1 logo styling */
h1.logo {
  font-size: 1.2rem;
  font-weight: 800;
  background: linear-gradient(135deg, #a89cf9, #6c63ff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  white-space: nowrap;
}

:root {
  --bg:          #0e0e14;
  --surface:     #16161f;
  --surface2:    #1e1e2a;
  --surface3:    #252535;
  --border:      #2a2a3d;
  --accent:      #6c63ff;
  --accent-h:    #574fd6;
  --accent-glow: #6c63ff33;
  --green:       #3ecf8e;
  --red:         #e05c5c;
  --yellow:      #f5c542;
  --text:        #e2e2f0;
  --text-muted:  #7878a0;
  --msg-out-bg:  #2e2870;
  --msg-in-bg:   #1e1e2a;
  --radius:      12px;
  --radius-sm:   8px;
  --header-h:    56px;
}

html, body {
  height: 100%;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

/* ── Header ── */
header {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  flex-shrink: 0;
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
}
.tagline {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ── Main layout ── */
main {
  display: flex;
  height: calc(100vh - var(--header-h));
  overflow: hidden;
}

/* ── Chat Panel (left) ── */
.chat-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  min-width: 0;
}

/* Status bar */
.status-bar {
  padding: 10px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
#statusText { flex: 1; }

.btn-clear-chat {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
  flex-shrink: 0;
}
.btn-clear-chat:hover { border-color: var(--red); color: var(--red); background: #e05c5c11; }
.btn-clear-chat.hidden { display: none; }
.status-bar::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-bar.waiting  { color: var(--yellow);  background: #f5c54211; }
.status-bar.waiting::before  { background: var(--yellow); box-shadow: 0 0 6px var(--yellow); }
.status-bar.searching { color: var(--accent); background: var(--accent-glow); animation: pulse-bg 1.5s ease-in-out infinite; }
.status-bar.searching::before { background: var(--accent); box-shadow: 0 0 6px var(--accent); animation: pulse 1.5s ease-in-out infinite; }
.status-bar.connected { color: var(--green);  background: #3ecf8e11; }
.status-bar.connected::before { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-bar.disconnected { color: var(--red); background: #e05c5c11; }
.status-bar.disconnected::before { background: var(--red); }

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(0.8); }
}
@keyframes pulse-bg {
  0%, 100% { background: var(--accent-glow); }
  50%       { background: transparent; }
}

/* Messages */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.messages::-webkit-scrollbar { width: 5px; }
.messages::-webkit-scrollbar-track { background: transparent; }
.messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* Message rows */
.msg-row {
  display: flex;
  flex-direction: column;
  max-width: 70%;
}
.msg-row.out { align-self: flex-end; align-items: flex-end; }
.msg-row.in  { align-self: flex-start; align-items: flex-start; }

.msg-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 3px;
  padding: 0 4px;
}

.msg-bubble {
  padding: 9px 13px;
  border-radius: var(--radius);
  font-size: 0.93rem;
  line-height: 1.5;
  word-break: break-word;
}
.msg-row.out .msg-bubble {
  background: var(--msg-out-bg);
  border-bottom-right-radius: 3px;
  color: #d8d4ff;
}
.msg-row.in .msg-bubble {
  background: var(--msg-in-bg);
  border: 1px solid var(--border);
  border-bottom-left-radius: 3px;
}

.msg-time {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 3px;
  padding: 0 4px;
}

/* System messages */
.msg-system {
  align-self: center;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 5px 14px;
  border-radius: 50px;
  text-align: center;
  max-width: 90%;
}
.msg-system.connected-msg  { color: var(--green);  border-color: #3ecf8e44; background: #3ecf8e0d; }
.msg-system.disconnected-msg { color: var(--red);  border-color: #e05c5c44; background: #e05c5c0d; }

/* Typing indicator */
.typing-indicator {
  padding: 6px 16px 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
  flex-shrink: 0;
}
.typing-indicator.hidden { display: none; }

/* Input bar */
.input-bar {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
#msgInput {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 10px 14px;
  font-size: 0.93rem;
  outline: none;
  transition: border-color 0.2s;
}
#msgInput:focus { border-color: var(--accent); }
#msgInput::placeholder { color: var(--text-muted); }
#msgInput:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-send {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}
.btn-send:hover:not(:disabled) { background: var(--accent-h); }
.btn-send:disabled { opacity: 0.35; cursor: not-allowed; }

/* ── Controls Panel (right) ── */
.controls-panel {
  width: 240px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 12px;
  overflow-y: auto;
  background: var(--surface);
}
.controls-panel::-webkit-scrollbar { width: 4px; }
.controls-panel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* Cards */
.card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.card.hidden { display: none; }

/* Name section */
#nameSection label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
#nameInput {
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 9px 12px;
  font-size: 0.93rem;
  outline: none;
  transition: border-color 0.2s;
}
#nameInput:focus { border-color: var(--accent); }
#nameInput::placeholder { color: var(--text-muted); }

/* Buttons */
.btn-start {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 11px;
  border-radius: var(--radius-sm);
  font-size: 0.93rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  text-align: center;
}
.btn-start:hover { background: var(--accent-h); transform: translateY(-1px); }
.btn-start:active { transform: translateY(0); }

.btn-stop {
  background: transparent;
  color: var(--red);
  border: 1px solid var(--red);
  padding: 9px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  text-align: center;
}
.btn-stop:hover { background: var(--red); color: #fff; }

/* Stranger card */
.stranger-card { align-items: center; text-align: center; }
.stranger-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #5b8af7);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  border: 2px solid var(--border);
}
.stranger-label { font-size: 0.75rem; color: var(--text-muted); }
.stranger-name  { font-size: 0.95rem; font-weight: 700; }
.stranger-location { font-size: 0.8rem; color: var(--text-muted); }

/* Online count */
.online-card {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.online-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
  flex-shrink: 0;
}
#onlineCount { color: var(--green); font-weight: 700; }

/* Tips */
.tips-card { gap: 8px; }
.tips-title { font-size: 0.85rem; font-weight: 700; }
.tips-card ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.tips-card li {
  font-size: 0.78rem;
  color: var(--text-muted);
  padding-left: 14px;
  position: relative;
}
.tips-card li::before {
  content: '•';
  position: absolute;
  left: 0;
  color: var(--accent);
}

/* ── Responsive ── */
@media (max-width: 600px) {
  html, body { overflow: auto; }
  main { flex-direction: column; height: auto; overflow: visible; }
  .chat-panel { height: 70vh; border-right: none; border-bottom: 1px solid var(--border); }
  .controls-panel { width: 100%; flex-direction: row; flex-wrap: wrap; overflow: visible; }
  .card { flex: 1 1 140px; }
  .msg-row { max-width: 85%; }
}

/* ── Search User Card ── */
.card-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.search-user-row {
  display: flex;
  gap: 6px;
}

#userSearchInput {
  flex: 1;
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 8px 10px;
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.2s;
  min-width: 0;
}
#userSearchInput:focus { border-color: var(--accent); }
#userSearchInput::placeholder { color: var(--text-muted); }

.btn-search-user {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s;
}
.btn-search-user:hover { background: var(--accent-h); }

.search-user-result {
  font-size: 0.82rem;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  line-height: 1.5;
}
.search-user-result.hidden { display: none; }
.search-user-result.info   { color: var(--text-muted); background: var(--surface3); border: 1px solid var(--border); }
.search-user-result.found  { color: var(--green);  background: #3ecf8e0d; border: 1px solid #3ecf8e44; }
.search-user-result.error  { color: var(--red);    background: #e05c5c0d; border: 1px solid #e05c5c44; }
.search-user-result.sending { color: var(--accent); background: var(--accent-glow); border: 1px solid #6c63ff44; }

/* ── Invite Popup ── */
.invite-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease;
}
.invite-overlay.hidden { display: none; }

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.invite-modal {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 300px;
  max-width: 90vw;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  animation: slideUp 0.25s ease;
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.invite-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #5b8af7);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  border: 2px solid var(--border);
}

.invite-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text);
}

.invite-msg {
  font-size: 0.9rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.5;
}

/* Timer bar */
.invite-timer-bar {
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.invite-timer-fill {
  height: 100%;
  width: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width linear;
}

.invite-actions {
  display: flex;
  gap: 10px;
  width: 100%;
}

.btn-invite-accept {
  flex: 1;
  background: var(--green);
  color: #fff;
  border: none;
  padding: 11px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s;
}
.btn-invite-accept:hover { opacity: 0.85; }

.btn-invite-decline {
  flex: 1;
  background: transparent;
  color: var(--red);
  border: 1px solid var(--red);
  padding: 11px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.btn-invite-decline:hover { background: var(--red); color: #fff; }

/* ── SEO FOOTER ── */
.seo-footer {
  background: #1a1a2e;
  border-top: 1px solid rgba(255,255,255,0.08);
  padding: 2.5rem 1.5rem;
  margin-top: 2rem;
  color: #a0a0b8;
  font-size: 0.85rem;
  line-height: 1.7;
}

.seo-footer-inner {
  max-width: 960px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.5rem;
}

.seo-footer h2 {
  font-size: 1rem;
  color: #c8c8e0;
  margin-bottom: 0.5rem;
}

.seo-footer h3 {
  font-size: 0.9rem;
  color: #c8c8e0;
  margin-bottom: 0.4rem;
}

.seo-footer ul,
.seo-footer ol {
  padding-left: 1.2rem;
  margin: 0;
}

.seo-footer li {
  margin-bottom: 0.25rem;
}

.seo-footer p {
  margin: 0;
}
