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

:root {
  --bg: #08080f;
  --surface: #10101a;
  --surface2: #16162a;
  --border: #1e1e35;
  --cyan: #00d4ff;
  --purple: #7c3aed;
  --green: #00ff88;
  --text: #e2e8f0;
  --muted: #64748b;
  --danger: #ff4444;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  height: 100vh;
  overflow: hidden;
}

/* ── PIN SCREEN ── */
#pin-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  z-index: 100;
}

.pin-box { text-align: center; width: 320px; }

.pin-logo {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 48px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--cyan), var(--purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 8px;
  letter-spacing: -1px;
}

.pin-sub { color: var(--muted); font-size: 14px; margin-bottom: 40px; }

.pin-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
  color: var(--text);
  font-size: 20px;
  text-align: center;
  letter-spacing: 8px;
  outline: none;
  transition: border-color 0.2s;
}

.pin-input:focus { border-color: var(--cyan); }

.pin-btn {
  width: 100%;
  margin-top: 16px;
  padding: 14px;
  background: linear-gradient(135deg, var(--cyan), var(--purple));
  border: none;
  border-radius: 12px;
  color: #fff;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}

.pin-btn:hover { opacity: 0.9; }
.pin-err { color: var(--danger); font-size: 13px; margin-top: 10px; }

/* ── TG AUTH ── */
#tg-screen {
  position: fixed; inset: 0;
  display: none; align-items: center; justify-content: center;
  background: var(--bg);
  z-index: 99;
}

.tg-box { text-align: center; width: 320px; }
.tg-title { font-family: 'Space Grotesk', sans-serif; font-size: 22px; font-weight: 600; margin-bottom: 8px; }
.tg-sub { color: var(--muted); font-size: 13px; margin-bottom: 32px; }

/* ── MAIN LAYOUT ── */
#app {
  display: none;
  height: 100vh;
  grid-template-columns: 320px 1fr;
  grid-template-rows: 56px 1fr;
}

/* Header */
.header {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: 16px;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.header-logo {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 20px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--cyan), var(--purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header-status {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--muted);
  margin-left: auto;
}

.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.status-dot.online { background: var(--green); box-shadow: 0 0 6px var(--green); }

.header-channel { display: flex; align-items: center; gap: 8px; }
.channel-label { font-size: 12px; color: var(--muted); }

.channel-input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 10px;
  color: var(--text);
  font-size: 13px;
  width: 180px;
  outline: none;
}

/* Sidebar */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow: hidden;
}

.sidebar-tabs { display: flex; border-bottom: 1px solid var(--border); }

.tab {
  flex: 1;
  padding: 12px;
  text-align: center;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s;
  border-bottom: 2px solid transparent;
}

.tab.active { color: var(--cyan); border-bottom-color: var(--cyan); }

#chat-panel { display: flex; flex-direction: column; flex: 1; overflow: hidden; }
#groups-panel { display: none; flex-direction: column; flex: 1; overflow: hidden; }

/* Chat */
.chat-messages {
  flex: 1; overflow-y: auto;
  padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
}

.msg {
  max-width: 90%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.5;
}

.msg.bot {
  background: var(--surface2);
  border: 1px solid var(--border);
  align-self: flex-start;
  border-top-left-radius: 4px;
}

.msg.user {
  background: linear-gradient(135deg, rgba(0,212,255,0.15), rgba(124,58,237,0.15));
  border: 1px solid rgba(0,212,255,0.2);
  align-self: flex-end;
  border-top-right-radius: 4px;
}

.chat-input-wrap {
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex; gap: 8px;
}

.chat-input {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  color: var(--text);
  font-size: 13px;
  outline: none;
  resize: none;
  font-family: 'Inter', sans-serif;
  transition: border-color 0.2s;
}

.chat-input:focus { border-color: var(--cyan); }

.send-btn {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--cyan), var(--purple));
  border: none; border-radius: 10px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
  transition: opacity 0.2s;
}

.send-btn:hover { opacity: 0.85; }

/* Groups */
.groups-header {
  padding: 12px 16px;
  display: flex; justify-content: space-between; align-items: center;
  border-bottom: 1px solid var(--border);
}

.groups-title { font-size: 12px; color: var(--muted); font-weight: 500; }

.gen-btn {
  padding: 6px 12px;
  background: linear-gradient(135deg, var(--cyan), var(--purple));
  border: none; border-radius: 8px;
  color: #fff; font-size: 11px; font-weight: 600;
  cursor: pointer;
  font-family: 'Space Grotesk', sans-serif;
  transition: opacity 0.2s;
}

.gen-btn:hover { opacity: 0.85; }

.groups-list { flex: 1; overflow-y: auto; padding: 8px; }

.group-item {
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  display: flex; align-items: center; gap: 10px;
  transition: background 0.15s;
  border: 1px solid transparent;
}

.group-item:hover { background: var(--surface2); }
.group-item.selected { background: rgba(0,212,255,0.08); border-color: rgba(0,212,255,0.2); }

.group-check {
  width: 16px; height: 16px;
  border: 1.5px solid var(--border);
  border-radius: 4px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; transition: all 0.15s;
}

.group-item.selected .group-check { background: var(--cyan); border-color: var(--cyan); color: #000; }

.group-info { flex: 1; min-width: 0; }
.group-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.group-members { font-size: 11px; color: var(--muted); margin-top: 2px; }

.group-del {
  color: var(--muted); font-size: 14px;
  opacity: 0; cursor: pointer;
  transition: all 0.15s; padding: 2px 4px;
}

.group-item:hover .group-del { opacity: 1; }
.group-del:hover { color: var(--danger); }

/* Main */
.main { display: flex; flex-direction: column; overflow: hidden; }

.main-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}

.main-title { font-family: 'Space Grotesk', sans-serif; font-size: 16px; font-weight: 600; }

.count-badge {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2px 10px;
  font-size: 12px; color: var(--muted);
}

.filter-btns { margin-left: auto; display: flex; gap: 8px; }

.filter-btn {
  padding: 5px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted); font-size: 12px;
  cursor: pointer; transition: all 0.15s;
  font-family: 'Inter', sans-serif;
}

.filter-btn.active, .filter-btn:hover { border-color: var(--cyan); color: var(--cyan); }

/* Comments */
.comments-grid {
  flex: 1; overflow-y: auto;
  padding: 20px 24px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
  align-content: start;
}

.comment-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  transition: border-color 0.2s;
}

.comment-card:hover { border-color: rgba(0,212,255,0.3); }
.comment-card.posted { opacity: 0.5; }

.card-group {
  font-size: 11px; color: var(--cyan); font-weight: 500;
  margin-bottom: 8px;
  display: flex; align-items: center; gap: 6px;
}

.card-post {
  font-size: 12px; color: var(--muted); line-height: 1.5;
  margin-bottom: 12px; padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-comment { font-size: 13px; line-height: 1.6; color: var(--text); margin-bottom: 14px; }

.card-actions { display: flex; gap: 8px; }

.card-copy {
  flex: 1; padding: 8px;
  background: rgba(0,212,255,0.1);
  border: 1px solid rgba(0,212,255,0.2);
  border-radius: 8px; color: var(--cyan);
  font-size: 12px; font-weight: 500;
  cursor: pointer; transition: all 0.15s;
  font-family: 'Inter', sans-serif;
}

.card-copy:hover { background: rgba(0,212,255,0.2); }
.card-copy.copied { color: var(--green); border-color: rgba(0,255,136,0.3); }

.card-done {
  padding: 8px 12px;
  background: rgba(0,255,136,0.08);
  border: 1px solid rgba(0,255,136,0.2);
  border-radius: 8px; color: var(--green);
  font-size: 12px; cursor: pointer;
  transition: all 0.15s;
  font-family: 'Inter', sans-serif;
}

.card-done:hover { background: rgba(0,255,136,0.15); }

.card-del {
  padding: 8px;
  background: rgba(255,68,68,0.08);
  border: 1px solid rgba(255,68,68,0.15);
  border-radius: 8px; color: var(--danger);
  font-size: 12px; cursor: pointer;
  transition: all 0.15s;
  font-family: 'Inter', sans-serif;
}

.card-del:hover { background: rgba(255,68,68,0.15); }

.empty-state { grid-column: 1 / -1; text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-text { font-size: 14px; }

/* Loading */
.loading { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.dot-anim { display: flex; gap: 3px; }
.dot-anim span {
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--cyan);
  animation: bounce 1.2s infinite;
}
.dot-anim span:nth-child(2) { animation-delay: 0.2s; }
.dot-anim span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
  40% { transform: scale(1.2); opacity: 1; }
}

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