/* assets/css/app.css */
:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #a5b4fc;
  --secondary: #ec4899;
  --bg: #0f0f14;
  --bg-card: #1a1a2e;
  --bg-card2: #16213e;
  --bg-hover: #1e1e35;
  --border: #2a2a45;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --transition: .2s ease;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, textarea, select { font-family: inherit; font-size: 1rem; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ===== LAYOUT ===== */
.app-layout {
  display: flex;
  min-height: 100vh;
  max-width: 768px;
  margin: 0 auto;
  position: relative;
}

.main-content {
  flex: 1;
  padding-bottom: 80px; /* space for bottom nav */
}

/* ===== TOP BAR ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(15,15,20,0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar-logo {
  font-size: 1.4rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
}

.topbar-actions { display: flex; align-items: center; gap: 8px; }

/* ===== BOTTOM NAV ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 768px;
  background: rgba(26,26,46,0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 8px 0 12px;
  z-index: 100;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 16px;
  border-radius: 12px;
  color: var(--text-dim);
  transition: var(--transition);
  cursor: pointer;
  font-size: 0.65rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.nav-item svg { width: 22px; height: 22px; }
.nav-item.active, .nav-item:hover { color: var(--primary); }
.nav-item.active svg { filter: drop-shadow(0 0 6px var(--primary)); }

.nav-item-center {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white !important;
  border-radius: 50%;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: -16px;
  box-shadow: 0 4px 16px rgba(99,102,241,0.5);
  transition: var(--transition);
}
.nav-item-center:hover { transform: scale(1.1); }
.nav-item-center svg { width: 24px; height: 24px; }

/* ===== CARDS ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: var(--transition);
}

.card:hover { border-color: var(--primary); box-shadow: 0 0 20px rgba(99,102,241,0.1); }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.9rem;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  box-shadow: 0 4px 15px rgba(99,102,241,0.4);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(99,102,241,0.5); }

.btn-secondary {
  background: var(--bg-card2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }

.btn-danger {
  background: rgba(239,68,68,0.15);
  color: var(--danger);
  border: 1px solid rgba(239,68,68,0.3);
}
.btn-danger:hover { background: var(--danger); color: white; }

.btn-success {
  background: rgba(16,185,129,0.15);
  color: var(--success);
  border: 1px solid rgba(16,185,129,0.3);
}

.btn-sm { padding: 6px 14px; font-size: 0.8rem; border-radius: 8px; }
.btn-icon { padding: 8px; border-radius: 10px; }
.btn-full { width: 100%; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-control {
  width: 100%;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  color: var(--text);
  outline: none;
  transition: var(--transition);
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}

.form-control::placeholder { color: var(--text-dim); }

textarea.form-control { min-height: 120px; resize: vertical; }

.form-error {
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.3);
  color: var(--danger);
  padding: 12px 16px;
  border-radius: 12px;
  margin-bottom: 16px;
  font-size: 0.9rem;
  line-height: 1.6;
}

.form-success {
  background: rgba(16,185,129,0.1);
  border: 1px solid rgba(16,185,129,0.3);
  color: var(--success);
  padding: 12px 16px;
  border-radius: 12px;
  margin-bottom: 16px;
  font-size: 0.9rem;
}

/* ===== AUTH PAGES ===== */
.auth-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 32px 28px;
  box-shadow: var(--shadow);
}

.auth-logo {
  text-align: center;
  font-size: 2.5rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
  letter-spacing: -1px;
}

.auth-subtitle {
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 28px;
  font-size: 0.9rem;
}

.auth-divider {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.85rem;
  margin: 20px 0;
  position: relative;
}
.auth-divider::before, .auth-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 42%;
  height: 1px;
  background: var(--border);
}
.auth-divider::before { left: 0; }
.auth-divider::after { right: 0; }

/* ===== CLAN CARDS ===== */
.clan-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin: 16px 0;
}

.clan-option {
  position: relative;
}

.clan-option input[type=radio] { display: none; }

.clan-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px;
  background: var(--bg-card2);
  border: 2px solid var(--border);
  border-radius: 16px;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
}

.clan-option input:checked + .clan-label {
  border-color: var(--primary);
  background: rgba(99,102,241,0.1);
  box-shadow: 0 0 20px rgba(99,102,241,0.2);
}

.clan-label:hover { border-color: var(--text-muted); }

.clan-icon { font-size: 2rem; }
.clan-name { font-weight: 700; font-size: 0.9rem; }
.clan-members { font-size: 0.75rem; color: var(--text-dim); }

/* ===== AVATAR ===== */
.avatar {
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.avatar-sm { width: 36px; height: 36px; }
.avatar-md { width: 48px; height: 48px; }
.avatar-lg { width: 72px; height: 72px; }
.avatar-xl { width: 96px; height: 96px; }

.avatar-placeholder {
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}
.avatar-placeholder.avatar-sm { width: 36px; height: 36px; font-size: 0.85rem; }
.avatar-placeholder.avatar-md { width: 48px; height: 48px; font-size: 1rem; }
.avatar-placeholder.avatar-lg { width: 72px; height: 72px; font-size: 1.5rem; }
.avatar-placeholder.avatar-xl { width: 96px; height: 96px; font-size: 2rem; }

/* ===== POST CARD ===== */
.post-card { margin-bottom: 12px; }

.post-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
}

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

.post-username {
  font-weight: 700;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

.post-meta {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.clan-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 700;
  background: rgba(99,102,241,0.15);
  color: var(--primary-light);
  border: 1px solid rgba(99,102,241,0.2);
}

.post-image {
  width: 100%;
  max-height: 400px;
  object-fit: cover;
}

.post-body { padding: 14px 16px 4px; }

.post-title {
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.4;
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-content {
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 12px 14px;
}

.action-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 10px;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  transition: var(--transition);
}

.action-btn:hover { color: var(--primary); background: rgba(99,102,241,0.1); }
.action-btn.liked { color: var(--secondary); }
.action-btn.liked:hover { background: rgba(236,72,153,0.1); }
.action-btn svg { width: 20px; height: 20px; }

/* ===== PAGE HEADER ===== */
.page-header {
  padding: 20px 16px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.page-title {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.3px;
}

.page-back {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text);
  transition: var(--transition);
}
.page-back:hover { border-color: var(--primary); color: var(--primary); }

/* ===== ADMIN ===== */
.admin-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

@media (max-width: 768px) {
  .admin-layout { grid-template-columns: 1fr; }
  .admin-sidebar { display: none; }
}

.admin-sidebar {
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  padding: 24px 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.admin-logo {
  padding: 0 20px 24px;
  font-size: 1.3rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}

.admin-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  color: var(--text-muted);
  font-weight: 500;
  transition: var(--transition);
  border-left: 3px solid transparent;
  font-size: 0.9rem;
}

.admin-nav-item:hover, .admin-nav-item.active {
  color: var(--primary);
  background: rgba(99,102,241,0.08);
  border-left-color: var(--primary);
}

.admin-nav-item svg { width: 18px; height: 18px; }

.admin-main { padding: 28px; overflow-x: hidden; }

.admin-main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.admin-page-title { font-size: 1.5rem; font-weight: 800; }

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

@media (min-width: 1024px) { .stats-grid { grid-template-columns: repeat(4, 1fr); } }

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
}

.stat-value { font-size: 1.8rem; font-weight: 800; line-height: 1; }
.stat-label { font-size: 0.8rem; color: var(--text-muted); font-weight: 500; }

/* Admin table */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.admin-table th {
  text-align: left;
  padding: 12px 16px;
  color: var(--text-dim);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card2);
}

.admin-table td {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(42,42,69,0.5);
  vertical-align: middle;
}

.admin-table tr:hover td { background: var(--bg-hover); }

.admin-table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  overflow-x: auto;
}

/* ===== BADGES ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-admin { background: rgba(239,68,68,0.15); color: var(--danger); }
.badge-moderator { background: rgba(245,158,11,0.15); color: var(--warning); }
.badge-user { background: rgba(99,102,241,0.15); color: var(--primary); }
.badge-active { background: rgba(16,185,129,0.15); color: var(--success); }
.badge-banned { background: rgba(239,68,68,0.15); color: var(--danger); }

/* ===== SECTION ===== */
.section-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 24px 24px 0 0;
  padding: 28px 24px 36px;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.3s ease;
}

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

.modal-handle {
  width: 40px;
  height: 4px;
  background: var(--border);
  border-radius: 4px;
  margin: 0 auto 20px;
}

.modal-title { font-size: 1.2rem; font-weight: 800; margin-bottom: 20px; }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
}
.empty-state-icon { font-size: 3rem; margin-bottom: 16px; }
.empty-state-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 8px; color: var(--text); }
.empty-state-text { font-size: 0.9rem; line-height: 1.6; }

/* ===== UTILITY ===== */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.p-4 { padding: 16px; }
.px-4 { padding-left: 16px; padding-right: 16px; }
.text-muted { color: var(--text-muted); }
.text-dim { color: var(--text-dim); }
.text-sm { font-size: 0.85rem; }
.text-xs { font-size: 0.75rem; }
.font-bold { font-weight: 700; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* STORIES BAR */
.stories-bar {
  display: flex;
  gap: 12px;
  padding: 12px 16px;
  overflow-x: auto;
  scrollbar-width: none;
}
.stories-bar::-webkit-scrollbar { display: none; }

.story-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  cursor: pointer;
}

.story-ring {
  padding: 3px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
}

.story-ring.seen {
  background: var(--border);
}

.story-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 3px solid var(--bg);
  object-fit: cover;
}

.story-name {
  font-size: 0.7rem;
  color: var(--text-muted);
  max-width: 60px;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== FEED TABS ===== */
.feed-tabs {
  display: flex;
  gap: 0;
  padding: 0 16px 0;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 57px;
  z-index: 90;
  background: rgba(15,15,20,0.92);
  backdrop-filter: blur(20px);
}

.feed-tab {
  flex: 1;
  padding: 12px 16px;
  text-align: center;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-dim);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: var(--transition);
}

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

/* Clan color dots */
.clan-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Search */
.search-bar {
  padding: 10px 16px;
  position: sticky;
  top: 57px;
  z-index: 90;
  background: var(--bg);
}

.search-input-wrap {
  position: relative;
}

.search-input-wrap svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-dim);
}

.search-input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 16px 11px 42px;
  color: var(--text);
  outline: none;
  transition: var(--transition);
}

.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}

/* Admin mobile top nav */
.admin-mobile-nav {
  display: none;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

@media (max-width: 768px) {
  .admin-mobile-nav { display: flex; }
  .admin-main { padding: 16px; }
}

/* Pagination */
.pagination {
  display: flex;
  gap: 6px;
  justify-content: center;
  padding: 20px 16px;
  flex-wrap: wrap;
}

.page-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.page-btn.active { background: var(--primary); border-color: var(--primary); color: white; }
.page-btn:hover:not(.active) { border-color: var(--primary); color: var(--primary); }

/* Toggle switch */
.toggle-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toggle {
  position: relative;
  width: 46px;
  height: 26px;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--border);
  border-radius: 26px;
  transition: var(--transition);
}

.toggle-slider::before {
  position: absolute;
  content: '';
  width: 20px;
  height: 20px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  transition: var(--transition);
}

.toggle input:checked + .toggle-slider { background: var(--primary); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

/* Color input */
input[type=color] {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: none;
  cursor: pointer;
  padding: 2px;
}

/* Admin section card */
.admin-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
  overflow: hidden;
}

.admin-section-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.admin-section-body { padding: 20px; }
