/* ════════════════════════════════════════
   TrendPulse — style.css
   Inspired by trends24.in UI layout
   Clean, data-dense, editorial feel
════════════════════════════════════════ */

/* ── VARIABLES ── */
:root {
  --font-ui: 'Outfit', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;

  /* Dark theme (default) */
  --bg: #0e0e12;
  --bg2: #16161d;
  --bg3: #1e1e28;
  --border: #2c2c3a;
  --border2: #3a3a4d;
  --text: #e8e8f0;
  --text2: #9898b8;
  --text3: #6060808;

  --accent: #6c63ff;
  --accent-glow: rgba(108,99,255,0.18);

  --google:  #ea4335;
  --youtube: #ff0000;
  --reddit:  #ff4500;
  --news:    #10b981;

  --header-bg: rgba(14,14,18,0.95);
  --section-bg: var(--bg2);
  --section-border: var(--border);

  --shadow: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-lg: 0 4px 20px rgba(0,0,0,0.5);

  --radius: 8px;
  --radius-lg: 12px;
}

body.theme-light {
  --bg: #f4f4f8;
  --bg2: #ffffff;
  --bg3: #f0f0f6;
  --border: #dddde8;
  --border2: #c8c8d8;
  --text: #1a1a2e;
  --text2: #5858789;
  --text3: #888898;
  --header-bg: rgba(244,244,248,0.95);
  --section-bg: #ffffff;
  --section-border: #dddde8;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 20px rgba(0,0,0,0.1);
}

/* ── RESET & BASE ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-ui);
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  transition: background .3s, color .3s;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }

.container {
  max-width: 1300px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ── HEADER ── */
.site-header {
  position: sticky; top: 0; z-index: 200;
  background: var(--header-bg);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  height: 52px;
}
.header-inner {
  height: 100%;
  display: flex;
  align-items: center;
  gap: 20px;
}

/* Logo */
.logo {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.logo-pulse {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  animation: logobeat 2s ease-in-out infinite;
}
@keyframes logobeat {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%       { transform: scale(0.7); opacity: 0.5; }
}

/* Nav */
.header-nav {
  display: flex;
  gap: 2px;
}
.nav-link {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 5px 12px;
  border-radius: 5px;
  color: var(--text2);
  transition: background .15s, color .15s;
  text-transform: uppercase;
}
.nav-link:hover { background: var(--bg3); color: var(--text); }
.nav-link.active { background: var(--accent); color: #fff; }

/* Header right */
.header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}
.detected-location {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text2);
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 12px;
}
.location-flag { font-size: 1rem; }

.theme-toggle {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg3);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background .15s;
}
.theme-toggle:hover { background: var(--border); }

/* ── LOCATION BANNER ── */
.location-banner {
  background: linear-gradient(90deg, var(--accent) 0%, #8b5cf6 100%);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 8px 0;
}
.location-banner .container {
  display: flex;
  align-items: center;
  gap: 10px;
}
.banner-flag { font-size: 1.2rem; }
.banner-dismiss {
  margin-left: auto;
  background: rgba(255,255,255,0.2);
  border: none;
  color: #fff;
  width: 22px; height: 22px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.7rem;
  display: flex; align-items: center; justify-content: center;
}

/* ── APP LAYOUT ── */
.app-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 20px;
  padding-top: 20px;
  padding-bottom: 60px;
  align-items: start;
}
@media (max-width: 860px) {
  .app-layout { grid-template-columns: 1fr; }
  .sidebar-left { display: none; }
}

/* ── LEFT SIDEBAR ── */
.sidebar-left {
  position: sticky;
  top: 68px;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.sidebar-section {
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.sidebar-section:last-child { border-bottom: none; }

.sidebar-label {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--text2);
  margin-bottom: 10px;
  text-transform: uppercase;
}

/* Current location card */
.current-location-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  position: relative;
}
.clc-flag { font-size: 1.8rem; line-height: 1; }
.clc-country { font-size: 0.85rem; font-weight: 700; }
.clc-region { font-size: 0.72rem; color: var(--text2); margin-top: 1px; }
.clc-live {
  position: absolute; top: 6px; right: 8px;
  font-family: var(--font-mono);
  font-size: 0.55rem;
  font-weight: 700;
  color: var(--news);
  letter-spacing: 0.08em;
}

/* Country search */
.country-search-wrap { margin-bottom: 8px; }
.country-search {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 0.8rem;
  padding: 7px 10px;
  border-radius: var(--radius);
  transition: border-color .15s;
}
.country-search:focus { outline: none; border-color: var(--accent); }
.country-search::placeholder { color: var(--text2); }

/* Country list */
.country-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  max-height: 320px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.country-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 500;
  transition: background .12s;
  color: var(--text2);
}
.country-item:hover { background: var(--bg3); color: var(--text); }
.country-item.active { background: var(--accent-glow); color: var(--accent); font-weight: 700; }
.country-item .ci-flag { font-size: 1rem; }
.country-item .ci-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.country-item .ci-badge {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  background: var(--accent);
  color: #fff;
  border-radius: 3px;
  padding: 1px 4px;
}

/* Platform toggles */
.platform-toggles { display: flex; flex-direction: column; gap: 2px; }
.platform-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 500;
  transition: background .12s;
  user-select: none;
}
.platform-toggle:hover { background: var(--bg3); }
.platform-toggle input { display: none; }
.pt-icon {
  width: 22px; height: 22px;
  border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem; font-weight: 700;
}
.google-icon  { background: rgba(234,67,53,0.15); color: #ea4335; }
.youtube-icon { background: rgba(255,0,0,0.15); color: #ff4444; }
.reddit-icon  { background: rgba(255,69,0,0.15); color: #ff4500; font-size: 0.65rem; }
.news-icon    { background: rgba(16,185,129,0.15); }
.pt-name { flex: 1; }
.pt-count {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text2);
}
.platform-toggle input:not(:checked) ~ .pt-name { opacity: 0.4; }

/* Stats */
.stats-list { display: flex; flex-direction: column; gap: 6px; }
.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  color: var(--text2);
}
.stat-row strong { color: var(--text); font-weight: 700; font-family: var(--font-mono); font-size: 0.78rem; }

/* ── MAIN CONTENT ── */
.main-content { min-width: 0; }

/* Page heading (like trends24 top) */
.page-heading {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.page-heading h1 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
}
.heading-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  flex-wrap: wrap;
}
.live-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--news);
  letter-spacing: 0.08em;
}
.live-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--news);
  animation: logobeat 1.5s infinite;
}
#heading-time { font-size: 0.75rem; color: var(--text2); }

.refresh-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 6px;
  transition: all .15s;
}
.refresh-btn:hover { border-color: var(--accent); color: var(--accent); }
.refresh-btn.loading .refresh-icon { animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── TIMELINE CONTROLS ── */
.timeline-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  padding: 10px 14px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  scrollbar-width: none;
}
.timeline-controls::-webkit-scrollbar { display: none; }
.timeline-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text2);
  white-space: nowrap;
  flex-shrink: 0;
}
.timeline-hours {
  display: flex;
  gap: 4px;
  flex: 1;
  justify-content: flex-end;
}
.timeline-hour {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  padding: 3px 7px;
  border-radius: 4px;
  cursor: pointer;
  color: var(--text2);
  border: 1px solid transparent;
  transition: all .12s;
  white-space: nowrap;
  flex-shrink: 0;
}
.timeline-hour:hover { border-color: var(--border); color: var(--text); }
.timeline-hour.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── TREND SECTIONS (like trends24 blocks) ── */
.trend-section {
  background: var(--section-bg);
  border: 1px solid var(--section-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 16px;
  transition: opacity .2s;
  box-shadow: var(--shadow);
}
.trend-section.hidden { display: none; }

.section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
}
.section-header.google  { border-bottom-color: rgba(234,67,53,0.25); }
.section-header.youtube { border-bottom-color: rgba(255,0,0,0.25); }
.section-header.reddit  { border-bottom-color: rgba(255,69,0,0.25); }
.section-header.news    { border-bottom-color: rgba(16,185,129,0.25); }

.section-platform-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 0.82rem;
}
.section-header.google  .section-platform-badge { color: #ea4335; }
.section-header.youtube .section-platform-badge { color: #ff4444; }
.section-header.reddit  .section-platform-badge { color: #ff4500; }
.section-header.news    .section-platform-badge { color: #10b981; }
.google-svg { fill: #ea4335; }

.section-location {
  font-size: 0.72rem;
  color: var(--text2);
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2px 10px;
}
.section-count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text2);
}

/* ── TREND LIST ITEMS ── */
.trend-list { padding: 4px 0; }

.trend-item {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  align-items: center;
  gap: 4px;
  padding: 8px 16px;
  border-bottom: 1px solid rgba(128,128,160,0.06);
  text-decoration: none;
  color: inherit;
  transition: background .12s;
  cursor: pointer;
}
.trend-item:last-child { border-bottom: none; }
.trend-item:hover { background: var(--bg3); }

.ti-rank {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text2);
  text-align: right;
  font-weight: 600;
}
.ti-rank.gold   { color: #fbbf24; }
.ti-rank.silver { color: #9ca3af; }
.ti-rank.bronze { color: #cd7c4a; }

.ti-content { min-width: 0; }
.ti-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}
.ti-meta {
  font-size: 0.68rem;
  color: var(--text2);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ti-badge {
  display: inline-block;
  background: rgba(108,99,255,0.12);
  color: var(--accent);
  border-radius: 3px;
  padding: 0 5px;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  margin-right: 5px;
}
.ti-badge.hot { background: rgba(239,68,68,0.12); color: #ef4444; }

.ti-arrow {
  color: var(--text2);
  font-size: 0.75rem;
  opacity: 0;
  transition: opacity .12s, transform .12s;
}
.trend-item:hover .ti-arrow { opacity: 1; transform: translateX(3px); }

/* ── SKELETON LOADING ── */
.skeleton-wrap { padding: 4px 0; }
.skeleton-row {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 4px;
  padding: 10px 16px;
  border-bottom: 1px solid rgba(128,128,160,0.06);
}
.skel {
  background: linear-gradient(90deg, var(--bg3) 0%, var(--border) 50%, var(--bg3) 100%);
  background-size: 200% 100%;
  animation: skel-shimmer 1.4s ease-in-out infinite;
  border-radius: 4px;
}
@keyframes skel-shimmer { to { background-position: -200% 0; } }
.skel-num  { width: 20px; height: 12px; align-self: center; }
.skel-body { display: flex; flex-direction: column; gap: 5px; }
.skel-line { height: 12px; }
.skel-sub  { height: 9px; width: 55%; }

/* ── ERROR STATE ── */
.error-state {
  padding: 28px 16px;
  text-align: center;
  color: var(--text2);
  font-size: 0.82rem;
}
.error-state .ei { font-size: 1.5rem; margin-bottom: 8px; }

/* ── VIEW PANELS ── */
.view-panel { display: none; }
.view-panel.active { display: block; }

/* ── TAG CLOUD VIEW ── */
.tagcloud-container {
  min-height: 400px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 30px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: center;
}
.cloud-tag {
  padding: 6px 16px;
  border-radius: 20px;
  cursor: pointer;
  font-weight: 600;
  border: 1px solid transparent;
  transition: transform .15s, filter .15s;
  line-height: 1;
}
.cloud-tag:hover { transform: scale(1.08); filter: brightness(1.15); }

/* ── TABLE VIEW ── */
.table-wrap { overflow-x: auto; }
.trends-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  font-size: 0.82rem;
}
.trends-table th {
  text-align: left;
  padding: 10px 14px;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text2);
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
}
.trends-table td {
  padding: 9px 14px;
  border-bottom: 1px solid rgba(128,128,160,0.07);
  vertical-align: middle;
}
.trends-table tr:last-child td { border-bottom: none; }
.trends-table tr:hover td { background: var(--bg3); }
.platform-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
}
.chip-google  { background: rgba(234,67,53,0.12); color: #ea4335; }
.chip-youtube { background: rgba(255,0,0,0.12); color: #ff4444; }
.chip-reddit  { background: rgba(255,69,0,0.12); color: #ff4500; }
.chip-news    { background: rgba(16,185,129,0.12); color: #10b981; }

.table-link {
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 600;
}

/* ── TOAST ── */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  transform: translateY(80px);
  opacity: 0;
  transition: all .3s cubic-bezier(.34,1.56,.64,1);
  pointer-events: none;
}
.toast.show { transform: translateY(0); opacity: 1; }

/* ── FOOTER ── */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg2);
  padding: 16px 0;
  font-size: 0.75rem;
  color: var(--text2);
}
.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

/* ── MOBILE ── */
@media (max-width: 600px) {
  .header-nav { display: none; }
  .page-heading h1 { font-size: 1rem; }
  .footer-inner { flex-direction: column; text-align: center; }
}
