/* ===== Variables ===== */
:root {
  --bg: #f5f8fa;
  --bg-card: #ffffff;
  --text: #14171a;
  --text-secondary: #657786;
  --text-muted: #aab8c2;
  --border: #e1e8ed;
  --accent: #1da1f2;
  --accent-hover: #1a91da;
  --danger: #e0245e;
  --success: #17bf63;
  --warning: #ffad1f;
  --radius: 12px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
}

[data-theme="dark"] {
  --bg: #15202b;
  --bg-card: #192734;
  --text: #ffffff;
  --text-secondary: #8899a6;
  --text-muted: #536471;
  --border: #38444d;
  --shadow: 0 2px 8px rgba(0,0,0,0.3);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Theme Toggle ===== */
.theme-toggle {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 100;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: var(--bg-card);
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-toggle:hover { transform: scale(1.05); }
.theme-toggle .sun-icon { display: block; }
.theme-toggle .moon-icon { display: none; }
[data-theme="dark"] .theme-toggle .sun-icon { display: none; }
[data-theme="dark"] .theme-toggle .moon-icon { display: block; }

/* ===== Page Container ===== */
.page-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== Landing Page ===== */
.landing-page {
  flex: 1;
}

.landing-header {
  text-align: center;
  padding: 40px 20px 30px;
}

.landing-logo {
  width: 60px;
  height: 60px;
  margin-bottom: 16px;
  color: var(--accent);
}

.landing-header h1 {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 8px;
}

.landing-header p {
  color: var(--text-secondary);
  font-size: 1rem;
}

/* ===== Search ===== */
.search-wrapper {
  max-width: 500px;
  margin: 0 auto 20px;
  position: relative;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: 50px;
  padding: 12px 20px;
  box-shadow: var(--shadow);
}

.search-box:focus-within {
  border-color: var(--accent);
}

.search-box svg {
  color: var(--text-muted);
  flex-shrink: 0;
}

.search-box input {
  flex: 1;
  border: none;
  background: none;
  font-size: 1rem;
  color: var(--text);
  outline: none;
}

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

.search-clear {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: var(--border);
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-clear:hover {
  background: var(--danger);
  color: white;
}

.search-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: 300px;
  overflow-y: auto;
  z-index: 50;
}

.dropdown-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}

.dropdown-item:last-child { border-bottom: none; }
.dropdown-item:hover { background: var(--bg); }

.dropdown-handle { font-weight: 600; }

.dropdown-badge {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 20px;
  font-weight: 600;
}

/* ===== Recent Searches ===== */
.recent-searches {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.recent-searches > span {
  color: var(--text-muted);
  font-size: 14px;
}

#recentTags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.recent-tag {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
}

.recent-tag:hover {
  border-color: var(--accent);
}

.recent-tag-x {
  color: var(--text-muted);
  font-size: 14px;
}

.recent-tag-x:hover {
  color: var(--danger);
}

/* ===== Browse Grid ===== */
.browse-grid {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.panel h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 16px;
}

.panel h2 svg {
  color: var(--text-muted);
}

.loading-text {
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
  padding: 20px;
}

/* ===== Accordion ===== */
.accordion-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  overflow: hidden;
}

.accordion-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  background: var(--bg);
  cursor: pointer;
}

.accordion-header:hover {
  background: var(--border);
}

.accordion-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cat-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.cat-name {
  font-weight: 600;
  font-size: 14px;
}

.cat-count {
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--bg-card);
  padding: 2px 8px;
  border-radius: 10px;
}

.accordion-icon {
  color: var(--text-muted);
  transition: transform 0.2s;
}

.accordion-item.open .accordion-icon {
  transform: rotate(180deg);
}

.accordion-body {
  display: none;
  padding: 8px;
  background: var(--bg-card);
}

.accordion-item.open .accordion-body {
  display: block;
}

.acc-handle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 8px;
  cursor: pointer;
}

.acc-handle:hover {
  background: var(--bg);
}

.acc-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--border);
}

.acc-name {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
}

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

/* ===== Profiles List ===== */
.profiles-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.profile-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg);
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.1s;
}

.profile-item:hover {
  transform: translateX(4px);
  background: var(--border);
}

.rank {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
}

.rank.gold {
  background: #fff8e7;
  border-color: #ffc107;
  color: #b8860b;
}

.pi-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--border);
}

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

.pi-handle {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pi-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  margin-top: 4px;
}

.pi-badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.pi-stats {
  text-align: right;
}

.pi-count {
  font-size: 18px;
  font-weight: 700;
}

.pi-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.view-all-btn {
  width: 100%;
  margin-top: 16px;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.view-all-btn:hover {
  background: var(--border);
}

/* ===== Stats Bar ===== */
.stats-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 40px;
  padding: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.stat {
  text-align: center;
}

.stat strong {
  display: block;
  font-size: 1.75rem;
  color: var(--accent);
}

.stat span {
  font-size: 13px;
  color: var(--text-secondary);
}

.stat-divider {
  width: 1px;
  height: 40px;
  background: var(--border);
}

/* ===== Results Page ===== */
.results-page {
  flex: 1;
}

.results-header {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}

.back-btn {
  padding: 10px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}

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

.mini-search {
  flex: 1;
  padding: 10px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 14px;
  color: var(--text);
  outline: none;
}

.mini-search:focus {
  border-color: var(--accent);
}

/* ===== Loading ===== */
.loading {
  text-align: center;
  padding: 60px 20px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto 16px;
  animation: spin 0.8s linear infinite;
}

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

.loading p {
  color: var(--text-secondary);
}

/* ===== Profile Card ===== */
.profile-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}

.profile-top {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.profile-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--border);
}

.profile-info h2 {
  font-size: 1.5rem;
  margin-bottom: 4px;
}

.profile-info a {
  font-size: 14px;
  color: var(--text-secondary);
}

.profile-badge {
  margin-bottom: 20px;
}

.badge-large {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
}

.badge-large .dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.badge-desc {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-secondary);
  margin-top: 4px;
}

.profile-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.pstat {
  text-align: center;
  padding: 12px;
  background: var(--bg);
  border-radius: 8px;
}

.pstat strong {
  display: block;
  font-size: 1.25rem;
}

.pstat span {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.twitter-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--text-secondary);
}

.twitter-link:hover {
  color: var(--accent);
}

/* Profile Summary */
.profile-summary {
  margin-top: 20px;
  padding: 16px;
  background: var(--bg);
  border-radius: 10px;
  border-left: 4px solid var(--accent);
}

.profile-summary h4 {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  font-weight: 600;
}

.profile-summary p {
  font-size: 14px;
  line-height: 1.6;
}

/* ===== Grok Section ===== */
.grok-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}

.grok-section h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  margin-bottom: 16px;
}

.grok-section h3 svg {
  color: var(--accent);
}

.grok-section h3 span {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 400;
}

.grok-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.grok-card {
  padding: 16px;
  background: var(--bg);
  border-radius: 10px;
  border-left: 4px solid #9b59b6;
}

.grok-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.grok-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: #9b59b6;
  background: rgba(155, 89, 182, 0.1);
  padding: 4px 10px;
  border-radius: 20px;
}

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

.grok-text {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-secondary);
}

.grok-source {
  margin-top: 10px;
  font-size: 12px;
}

.grok-source a {
  color: var(--text-muted);
}

/* ===== Not Found ===== */
.not-found {
  text-align: center;
  padding: 48px 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.nf-icon {
  font-size: 4rem;
  margin-bottom: 16px;
}

.not-found h2 {
  color: var(--success);
  margin-bottom: 8px;
}

#notFoundHandle {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 12px;
}

.nf-message {
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.report-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 28px;
  background: var(--danger);
  color: white;
  border-radius: 30px;
  font-weight: 600;
}

.report-btn:hover {
  text-decoration: none;
  opacity: 0.9;
}

/* ===== Reports Section ===== */
.reports-section {
  margin-bottom: 40px;
}

.reports-section h3 {
  font-size: 18px;
  margin-bottom: 16px;
}

.reports-section h3 span {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 400;
}

#reportsList {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.report-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.report-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.reporter {
  display: flex;
  align-items: center;
  gap: 10px;
}

.reporter img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
}

.reporter-name {
  font-weight: 600;
  font-size: 14px;
}

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

.report-tags {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.report-cat {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 20px;
  font-weight: 600;
}

.grok-tag {
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 20px;
  font-weight: 600;
  background: rgba(155, 89, 182, 0.15);
  color: #9b59b6;
  border: 1px solid rgba(155, 89, 182, 0.3);
}

.report-body {
  margin-bottom: 12px;
}

.report-evidence {
  padding: 12px;
  background: var(--bg);
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  font-size: 14px;
  color: var(--text-secondary);
}

.report-tweet {
  margin-top: 12px;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.report-tweet-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 6px;
}

.report-tweet-text {
  font-size: 14px;
  margin-bottom: 8px;
}

.report-tweet a {
  font-size: 13px;
}

.report-footer {
  padding-top: 12px;
  border-top: 1px solid var(--border);
  text-align: right;
}

.report-footer a {
  font-size: 14px;
  font-weight: 500;
}

.load-more {
  display: block;
  width: 100%;
  margin-top: 16px;
  padding: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}

.load-more:hover {
  background: var(--bg);
}

/* ===== Footer ===== */
.footer {
  text-align: center;
  padding: 24px;
  margin-top: auto;
  border-top: 1px solid var(--border);
}

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

.disclaimer {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 4px;
}

/* ===== Utility ===== */
.hidden { display: none !important; }

/* ===== Responsive ===== */
@media (max-width: 700px) {
  .browse-grid {
    grid-template-columns: 1fr;
  }
  
  .profiles-panel {
    order: -1;
  }
  
  .profile-top {
    flex-direction: column;
    text-align: center;
  }
  
  .profile-stats {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .results-header {
    flex-direction: column;
  }
  
  .stats-bar {
    flex-direction: column;
    gap: 16px;
  }
  
  .stat-divider {
    width: 60px;
    height: 1px;
  }
  
  .grok-card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
}
