/* ===== THE FLEX — Modern Premium Social Design ===== */
:root {
  --bg: #0b0d12;
  --bg-elevated: #13161e;
  --bg-card: #181c27;
  --bg-hover: #1f2433;
  --border: #2a3042;
  --text: #f0f2f7;
  --text-secondary: #9aa3b8;
  --text-muted: #6b7388;
  --primary: #7c5cfc;
  --primary-hover: #6a4ae8;
  --accent: #00d4aa;
  --accent-soft: rgba(0, 212, 170, 0.12);
  --danger: #ff5c7a;
  --warning: #ffb020;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 8px 32px rgba(0,0,0,0.4);
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --font-display: 'Outfit', 'Inter', sans-serif;
}

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

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

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select {
  font-family: inherit;
  font-size: 1rem;
  color: var(--text);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  width: 100%;
  outline: none;
  transition: border-color 0.2s;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--primary);
}
textarea { resize: vertical; min-height: 100px; }

.hidden { display: none !important; }

/* ===== AUTH SCREEN ===== */
.auth-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 30% 20%, #1a1430 0%, var(--bg) 60%);
  z-index: 1000;
  padding: 1.5rem;
}
.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
  text-align: center;
}
.auth-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
}
.auth-logo h1 {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}
.logo-icon { font-size: 2.2rem; }
.auth-tagline {
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
  font-size: 0.95rem;
}
.auth-heading {
  margin-bottom: 1.5rem;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.85rem 1.4rem;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.95rem;
  transition: all 0.2s;
  width: 100%;
}
.btn-google {
  background: #fff;
  color: #1f1f1f;
}
.btn-google:hover { background: #f0f0f0; }
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-outline:hover { background: var(--bg-hover); }
.btn-link {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-top: 1rem;
}
.btn-link:hover { color: var(--text); }
.divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1.25rem 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.phone-form { margin-top: 0.5rem; }
.phone-form input { margin-bottom: 0.75rem; }
.auth-field-label {
  display: block;
  margin: 0.25rem 0 0.4rem;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  text-align: left;
}
.auth-message {
  margin-top: 1rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid rgba(124, 92, 252, 0.35);
  border-radius: var(--radius-sm);
  background: rgba(124, 92, 252, 0.1);
  color: #c8bcff;
  font-size: 0.85rem;
  text-align: left;
}
.auth-message.error {
  border-color: rgba(255, 92, 122, 0.4);
  background: rgba(255, 92, 122, 0.1);
  color: #ff9bad;
}
.auth-message.success {
  border-color: rgba(0, 212, 170, 0.35);
  background: var(--accent-soft);
  color: var(--accent);
}
.auth-note {
  margin-top: 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ===== HEADER ===== */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  background: rgba(11, 13, 18, 0.85);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  gap: 1rem;
}
.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}
.logo-text {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}
.header-center { flex: 1; max-width: 480px; }
.search-box {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.5rem 1rem;
}
.search-box input {
  border: none;
  background: transparent;
  padding: 0;
  font-size: 0.9rem;
}
.search-box svg { color: var(--text-muted); flex-shrink: 0; }
.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  transition: background 0.2s;
}
.icon-btn:hover { background: var(--bg-hover); }
.user-menu {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.5rem 0.25rem 0.25rem;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--primary);
}
.user-name {
  font-weight: 600;
  font-size: 0.9rem;
  padding-right: 0.4rem;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== MAIN LAYOUT ===== */
.main {
  display: grid;
  grid-template-columns: 240px 1fr 300px;
  gap: 1.5rem;
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.5rem;
  min-height: calc(100vh - 64px);
}
@media (max-width: 1100px) {
  .main { grid-template-columns: 200px 1fr; }
  .right-panel { display: none; }
}
@media (max-width: 768px) {
  .main { grid-template-columns: 1fr; padding: 1rem; }
  .sidebar { display: none; }
  .header-center { display: none; }
  .user-name { display: none; }
}

/* Sidebar */
.sidebar {
  position: sticky;
  top: 80px;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
.nav { display: flex; flex-direction: column; gap: 0.35rem; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.2s;
  text-align: left;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
}
.categories-panel h3 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}
.category-list { display: flex; flex-direction: column; gap: 0.25rem; }
.cat-btn {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  font-size: 0.9rem;
  color: var(--text-secondary);
  transition: all 0.15s;
}
.cat-btn:hover, .cat-btn.active {
  background: var(--bg-hover);
  color: var(--text);
}

/* Feed */
.feed-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  background: var(--bg-elevated);
  padding: 0.35rem;
  border-radius: 12px;
  border: 1px solid var(--border);
}
.tab {
  flex: 1;
  padding: 0.65rem;
  border-radius: 9px;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-secondary);
  transition: all 0.2s;
}
.tab.active {
  background: var(--primary);
  color: #fff;
}
.posts-container {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Post Card */
.post-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.2s;
}
.post-card:hover { border-color: #3a4258; }
.post-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem 0.5rem;
}
.post-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--primary);
}
.post-meta { flex: 1; }
.post-author {
  font-weight: 700;
  font-size: 0.95rem;
}
.post-time {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.post-cats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.25rem;
}
.cat-tag {
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.post-body {
  padding: 0.5rem 1.25rem 1rem;
}
.post-text {
  font-size: 1rem;
  line-height: 1.55;
  white-space: pre-wrap;
  margin-bottom: 0.75rem;
}
.post-media {
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 0.75rem;
  background: #000;
  max-height: 420px;
}
.post-media img, .post-media video {
  width: 100%;
  max-height: 420px;
  object-fit: cover;
  display: block;
}
.post-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  text-decoration: none;
  color: inherit;
  transition: background 0.2s;
}
.post-link:hover { background: var(--bg-hover); }
.link-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}
.link-info { overflow: hidden; }
.link-title {
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.link-url {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Reactions */
.post-footer {
  padding: 0.5rem 1rem 1rem;
  border-top: 1px solid var(--border);
}
.reactions-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}
.reaction-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid transparent;
  font-size: 0.85rem;
  color: var(--text-secondary);
  transition: all 0.15s;
}
.reaction-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.reaction-btn.active {
  border-color: var(--primary);
  background: rgba(124, 92, 252, 0.15);
  color: var(--primary);
  font-weight: 600;
}
.reaction-count {
  font-size: 0.8rem;
  font-weight: 600;
}

/* Right panel */
.right-panel {
  position: sticky;
  top: 80px;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.panel-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}
.panel-card h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 1rem;
}
.trending-item, .suggested-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.15s;
}
.trending-item:hover, .suggested-item:hover {
  background: var(--bg-hover);
}
.trending-thumb {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--bg-elevated);
}
.trending-info { flex: 1; overflow: hidden; }
.trending-title {
  font-weight: 600;
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.trending-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ===== MODAL ===== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
}
.modal-content {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
}
.close-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1.5rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
}
.close-btn:hover { background: var(--bg-hover); color: var(--text); }
.modal-body { padding: 1.5rem; display: flex; flex-direction: column; gap: 1rem; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
}
.modal-footer .btn { width: auto; min-width: 120px; }
.form-row label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}
.media-source-tabs {
  display: flex;
  gap: 0.4rem;
  padding: 0.25rem;
  margin-bottom: 0.65rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.media-source-tab {
  flex: 1;
  padding: 0.55rem 0.75rem;
  border-radius: 7px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 600;
}
.media-source-tab:hover { color: var(--text); }
.media-source-tab.active {
  background: var(--bg-card);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
}
.media-file-picker {
  display: inline-flex !important;
  width: fit-content;
  align-items: center;
  padding: 0.65rem 1rem;
  margin: 0 0.65rem 0 0 !important;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text) !important;
  cursor: pointer;
}
.media-file-picker:hover { border-color: var(--primary); }
.media-file-name {
  color: var(--text-muted);
  font-size: 0.8rem;
  overflow-wrap: anywhere;
}
.sub-cats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.sub-cat-chip {
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
}
.sub-cat-chip:hover { border-color: var(--primary); }
.sub-cat-chip.selected {
  background: rgba(124, 92, 252, 0.2);
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 600;
}
.media-preview {
  border-radius: 12px;
  overflow: hidden;
  max-height: 200px;
  display: none;
}
.media-preview img, .media-preview video {
  width: 100%;
  max-height: 200px;
  object-fit: cover;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
}
.empty-state .emoji { font-size: 3rem; margin-bottom: 1rem; }
.empty-state h3 { color: var(--text); margin-bottom: 0.5rem; }

/* Profile */
.profile-header {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  margin-bottom: 1.5rem;
}
.profile-avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  margin: 0 auto 1rem;
  object-fit: cover;
  border: 3px solid var(--primary);
}
.profile-name {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 800;
}
.profile-stats {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-top: 1.25rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
}
.profile-stats strong { color: var(--text); display: block; font-size: 1.2rem; }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #3a4258; }
