/* ============================================
   KeywordForge — Premium Glassmorphism Theme
   ============================================ */

:root {
  --primary: #2563EB;
  --primary-light: #3B82F6;
  --accent: #06B6D4;
  --success: #10B981;
  --bg: #F6F8FC;
  --bg-alt: #EEF2F9;
  --surface: rgba(255, 255, 255, 0.6);
  --surface-solid: #ffffff;
  --border: rgba(255, 255, 255, 0.5);
  --text: #0F172A;
  --text-muted: #5B6478;
  --shadow: 0 20px 60px -15px rgba(37, 99, 235, 0.18);
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --font-latin: 'Manrope', 'Plus Jakarta Sans', sans-serif;
  --font-arabic: 'IBM Plex Sans Arabic', sans-serif;
}

[data-theme="dark"] {
  --bg: #0B1120;
  --bg-alt: #0F172A;
  --surface: rgba(255, 255, 255, 0.06);
  --surface-solid: #131C31;
  --border: rgba(255, 255, 255, 0.09);
  --text: #F1F5F9;
  --text-muted: #94A3B8;
  --shadow: 0 20px 60px -15px rgba(6, 182, 212, 0.25);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background: radial-gradient(ellipse at top, var(--bg-alt), var(--bg) 60%);
  color: var(--text);
  font-family: var(--font-latin);
  transition: background 0.4s ease, color 0.4s ease;
  overflow-x: hidden;
}

html[dir="rtl"] body { font-family: var(--font-arabic); }

button, input { font-family: inherit; }

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ---------- Glass surfaces ---------- */
.glass {
  background: var(--surface);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

/* ---------- Floating background orbs ---------- */
.bg-orbs {
  position: fixed;
  inset: 0;
  overflow: hidden;
  z-index: -1;
  pointer-events: none;
}
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.35;
  animation: float 18s ease-in-out infinite;
}
.orb-1 { width: 420px; height: 420px; background: var(--primary); top: -120px; left: -80px; }
.orb-2 { width: 360px; height: 360px; background: var(--accent); bottom: -100px; right: -60px; animation-delay: -6s; }
.orb-3 { width: 280px; height: 280px; background: var(--success); top: 40%; left: 60%; animation-delay: -12s; opacity: 0.2; }

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -40px) scale(1.08); }
  66% { transform: translate(-20px, 30px) scale(0.95); }
}

@media (prefers-reduced-motion: reduce) {
  .orb { animation: none; }
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------- Top navigation ---------- */
.topnav {
  position: sticky;
  top: 0;
  z-index: 40;
  padding: 18px 24px;
}
.topnav-inner {
  max-width: 1180px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  border-radius: 100px;
  background: var(--surface);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-name { font-weight: 800; font-size: 1.05rem; letter-spacing: -0.02em; }

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

.lang-switch {
  display: flex;
  background: var(--bg-alt);
  border-radius: 100px;
  padding: 4px;
  gap: 2px;
}
.lang-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: 100px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.25s ease;
}
.lang-btn[aria-pressed="true"] {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  box-shadow: 0 4px 14px -4px rgba(37, 99, 235, 0.5);
}

.theme-toggle, .history-toggle {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-alt);
  color: var(--text);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.2s ease, background 0.2s ease;
  position: relative;
}
.theme-toggle:hover, .history-toggle:hover { transform: translateY(-2px); background: var(--surface-solid); }
.icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: inline; }

/* ---------- Layout ---------- */
.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 60px 24px 120px;
}

/* ---------- Hero ---------- */
.hero { text-align: center; margin-bottom: 48px; }
.hero-eyebrow {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--primary);
  background: rgba(37, 99, 235, 0.1);
  padding: 6px 16px;
  border-radius: 100px;
  margin-bottom: 20px;
  animation: fadeSlideUp 0.6s ease both;
}
.hero-title {
  font-size: clamp(2rem, 5vw, 3.4rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin: 0 0 16px;
  background: linear-gradient(135deg, var(--text) 20%, var(--primary) 70%, var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: fadeSlideUp 0.7s ease both;
  animation-delay: 0.05s;
}
.hero-subtitle {
  max-width: 640px;
  margin: 0 auto 40px;
  color: var(--text-muted);
  font-size: 1.05rem;
  line-height: 1.6;
  animation: fadeSlideUp 0.7s ease both;
  animation-delay: 0.1s;
}

@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Search card ---------- */
.search-card {
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px 10px 22px;
  border-radius: var(--radius-lg);
  animation: fadeSlideUp 0.8s ease both;
  animation-delay: 0.15s;
}
html[dir="rtl"] .search-card { padding: 10px 22px 10px 10px; }

.search-icon { color: var(--text-muted); font-size: 1.1rem; }
.search-input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 1.05rem;
  padding: 14px 6px;
  outline: none;
}
.search-input::placeholder { color: var(--text-muted); }

.generate-btn {
  position: relative;
  border: none;
  cursor: pointer;
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  padding: 14px 26px;
  border-radius: 100px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: 0 10px 30px -8px rgba(37, 99, 235, 0.55);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  white-space: nowrap;
}
.generate-btn:hover { transform: translateY(-2px) scale(1.02); box-shadow: 0 14px 36px -6px rgba(37, 99, 235, 0.65); }
.generate-btn:active { transform: translateY(0) scale(0.98); }
.btn-icon { font-size: 1rem; }
.btn-spinner {
  display: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  animation: spin 0.7s linear infinite;
}
.generate-btn.loading .btn-label,
.generate-btn.loading .btn-icon { display: none; }
.generate-btn.loading .btn-spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Recent / popular pills ---------- */
.recent-pills, .popular-pills {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 8px;
  margin-top: 18px;
}
.pill {
  border: 1px solid var(--border);
  background: var(--surface-solid);
  color: var(--text-muted);
  padding: 7px 16px;
  border-radius: 100px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}
.pill:hover { color: #fff; background: linear-gradient(135deg, var(--primary), var(--accent)); border-color: transparent; transform: translateY(-2px); }

.popular-block { margin-top: 34px; }
.popular-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* ---------- Stats bar ---------- */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
  border-radius: var(--radius-lg);
  padding: 26px 32px;
  margin-bottom: 32px;
  animation: fadeSlideUp 0.5s ease both;
}
.stat { text-align: center; position: relative; }
.stat-value {
  display: block;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.stat-label { font-size: 0.8rem; color: var(--text-muted); font-weight: 600; }
.stat-bar {
  height: 4px;
  background: var(--bg-alt);
  border-radius: 100px;
  margin-top: 8px;
  overflow: hidden;
}
.stat-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 100px;
  transition: width 1s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ---------- Result panels ---------- */
.results {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 24px;
}
.small-panel { grid-column: span 1; }
#hashtagPanel, #keywordPanel { grid-column: span 1; }

.result-panel {
  border-radius: var(--radius-lg);
  padding: 26px;
  animation: fadeSlideUp 0.5s ease both;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}
.panel-title { display: flex; align-items: center; gap: 10px; }
.panel-title i { color: var(--primary); font-size: 1.2rem; }
.panel-title h2 { font-size: 1.05rem; font-weight: 800; margin: 0; letter-spacing: -0.01em; }
.panel-count {
  background: var(--bg-alt);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 100px;
}
.panel-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.ghost-btn {
  display: flex; align-items: center; gap: 6px;
  border: 1px solid var(--border);
  background: var(--surface-solid);
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 7px 12px;
  border-radius: 100px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.ghost-btn:hover { background: var(--primary); color: #fff; border-color: var(--primary); transform: translateY(-1px); }
.ghost-btn i { font-size: 0.9rem; }

/* ---------- Hashtag chips ---------- */
.chip-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.hashtag-chip {
  position: relative;
  overflow: hidden;
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 8px 9px 16px;
  border-radius: 100px;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  animation: chipIn 0.35s ease both;
}
html[dir="rtl"] .hashtag-chip { padding: 9px 16px 9px 8px; }
.hashtag-chip:hover { transform: translateY(-2px) scale(1.03); box-shadow: 0 8px 20px -8px rgba(37, 99, 235, 0.4); }
.hashtag-chip .chip-copy {
  width: 24px; height: 24px;
  border-radius: 50%;
  border: none;
  background: rgba(37, 99, 235, 0.12);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 0.78rem;
}
.hashtag-chip .chip-copy:hover { background: var(--primary); color: #fff; }
@keyframes chipIn { from { opacity: 0; transform: scale(0.85); } to { opacity: 1; transform: scale(1); } }

.ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(37, 99, 235, 0.35);
  transform: scale(0);
  animation: ripple 0.6s ease-out;
  pointer-events: none;
}
@keyframes ripple { to { transform: scale(3.5); opacity: 0; } }

/* ---------- Keyword list ---------- */
.keyword-list { display: flex; flex-direction: column; gap: 10px; max-height: 560px; overflow-y: auto; padding-right: 4px; }
.keyword-list::-webkit-scrollbar { width: 6px; }
.keyword-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }

.keyword-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  animation: fadeSlideUp 0.35s ease both;
}
.keyword-card:hover { transform: translateX(2px); box-shadow: 0 8px 20px -10px rgba(0,0,0,0.15); }
html[dir="rtl"] .keyword-card:hover { transform: translateX(-2px); }

.kw-icon { color: var(--accent); font-size: 1rem; flex-shrink: 0; }
.kw-main { flex: 1; min-width: 0; }
.kw-text { font-weight: 700; font-size: 0.92rem; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kw-source { font-size: 0.72rem; color: var(--text-muted); font-weight: 600; }

.kw-popularity {
  display: flex; align-items: center; gap: 6px;
  width: 70px; flex-shrink: 0;
}
.kw-bar { flex: 1; height: 5px; background: var(--border); border-radius: 100px; overflow: hidden; }
.kw-bar-fill { height: 100%; background: linear-gradient(90deg, var(--success), var(--accent)); border-radius: 100px; }
.kw-percent { font-size: 0.7rem; font-weight: 700; color: var(--text-muted); width: 28px; text-align: right; }
html[dir="rtl"] .kw-percent { text-align: left; }

.kw-star, .kw-copy {
  width: 28px; height: 28px; border-radius: 50%;
  border: none; background: transparent; color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
  transition: all 0.2s ease;
}
.kw-star:hover, .kw-copy:hover { background: var(--surface-solid); color: var(--primary); }
.kw-star.active { color: #F59E0B; }

/* ---------- Pill lists (questions / long-tail / related) ---------- */
.pill-list { display: flex; flex-wrap: wrap; gap: 8px; }
.pill-list .pill { background: var(--bg-alt); }

/* ---------- Empty state ---------- */
.empty-state {
  display: flex; align-items: center; justify-content: center;
  min-height: 160px;
}
.empty-icon { font-size: 2.4rem; color: var(--border); }

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed;
  top: 0; right: -340px;
  width: 320px;
  height: 100%;
  padding: 90px 22px 22px;
  z-index: 50;
  transition: right 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  overflow-y: auto;
  border-radius: 0;
}
html[dir="rtl"] .sidebar { right: auto; left: -340px; transition-property: left; }
.sidebar.open { right: 0; }
html[dir="rtl"] .sidebar.open { left: 0; }

.sidebar-section { margin-bottom: 28px; }
.sidebar-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sidebar-header h3 { font-size: 0.95rem; font-weight: 800; margin: 0; }
.text-btn { background: none; border: none; color: var(--primary); font-weight: 700; font-size: 0.78rem; cursor: pointer; }

.sidebar-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.sidebar-list li {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-alt);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.2s ease;
}
.sidebar-list li:hover { background: var(--surface-solid); }
.sidebar-empty { color: var(--text-muted); font-size: 0.82rem; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: var(--bg);
  padding: 12px 22px;
  border-radius: 100px;
  font-size: 0.85rem;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease;
  z-index: 100;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .results { grid-template-columns: 1fr; }
  .stats-bar { grid-template-columns: repeat(2, 1fr); }
  .sidebar { width: 86%; }
}
@media (max-width: 520px) {
  .search-card { flex-wrap: wrap; padding: 16px; }
  .generate-btn { width: 100%; justify-content: center; }
  .topnav-inner { flex-wrap: wrap; gap: 10px; border-radius: 24px; }
}
