:root {
  --sidebar-bg: #12172b;
  --sidebar-text: #b7bdd6;
  --sidebar-active-bg: #232a49;
  --sidebar-active-text: #ffffff;

  --bg-gradient: linear-gradient(135deg, #eef3fb 0%, #f6f2ea 45%, #ecf5f0 100%);
  --card-bg: #ffffff;
  --text-main: #14162a;
  --text-muted: #676e8a;
  --text-soft: #6b7085;
  --border-soft: #e6e8f0;

  --accent: #4f5bd5;
  --accent-soft: #eef0fd;

  --strong: #c2410c;
  --strong-bg: #fff1e8;
  --medium: #8a5407;
  --medium-bg: #fef7e6;
  --niche: #5f6673;
  --niche-bg: #f1f2f5;

  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow-card: 0 10px 30px -18px rgba(20, 22, 42, 0.25);
}

* { box-sizing: border-box; }

/* Kontrol form tidak mewarisi font secara default — tanpa ini semuanya jadi Arial */
button, input, select, textarea { font-family: inherit; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  background: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text-main);
}

body {
  display: flex;
  min-height: 100vh;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--text-main);
  color: #fff;
  padding: 12px 20px;
  border-radius: 0 0 var(--radius-sm) 0;
  text-decoration: none;
  font-weight: 600;
}
.skip-link:focus { left: 0; }

/* ---------- Fokus keyboard ---------- */

:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
.idea-card:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
  border-color: var(--accent);
}
.sidebar :focus-visible,
.show-sidebar-btn:focus-visible {
  outline: 3px solid #8f9bff;
  outline-offset: 2px;
}

/* ---------- Sidebar ---------- */

.sidebar {
  width: 270px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 26px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  transition: margin-left 0.2s ease;
}

.sidebar.hidden { margin-left: -270px; }

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.brand-icon {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: var(--accent);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
}

.brand-title { font-weight: 700; color: #fff; font-size: 14px; }
.brand-subtitle { font-size: 11px; color: #9aa0bd; }

.icon-btn {
  background: rgba(255,255,255,0.06);
  border: none;
  color: #cfd3e6;
  width: 34px; height: 34px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}
.icon-btn:hover { background: rgba(255,255,255,0.14); }

.sidebar-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #9299b8;
  margin: 0 0 10px;
  font-weight: 600;
}

.category-list {
  list-style: none;
  margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 2px;
}

.category-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 9px 10px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13.5px;
  color: var(--sidebar-text);
  text-align: left;
}

.category-item:hover { background: rgba(255,255,255,0.07); }
.category-item.active { background: var(--sidebar-active-bg); color: var(--sidebar-active-text); }

.category-item .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #6d759c;
  display: inline-block;
  margin-right: 9px;
  flex-shrink: 0;
}
.category-item.active .dot { background: #8f9bff; }

.category-item .count {
  background: rgba(255,255,255,0.1);
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  color: #bcc1d8;
  flex-shrink: 0;
}
.category-item.active .count { background: rgba(255,255,255,0.2); color: #fff; }

.category-item .label-wrap { display: flex; align-items: center; }

.shortcut-btn {
  display: block;
  width: 100%;
  text-align: left;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  color: var(--sidebar-text);
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  margin-bottom: 6px;
}
.shortcut-btn:hover { background: rgba(255,255,255,0.1); }
.shortcut-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.sidebar-note {
  margin-top: auto;
  background: rgba(124,140,255,0.1);
  border: 1px solid rgba(124,140,255,0.22);
  border-radius: var(--radius-md);
  padding: 14px;
  font-size: 12px;
  line-height: 1.55;
  color: #c3c9e6;
}
.sidebar-note-title { font-weight: 600; color: #e4e7f7; margin-bottom: 6px; font-size: 12.5px; }
.sidebar-note p { margin: 0; }

.show-sidebar-btn {
  position: fixed;
  top: 16px; left: 16px;
  z-index: 20;
  background: var(--sidebar-bg);
  color: #fff;
  border: none;
  width: 40px; height: 40px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 15px;
}

/* ---------- Main ---------- */

.main { flex: 1; padding: 28px 34px 60px; min-width: 0; }

.topbar { display: none; align-items: center; gap: 12px; }
.topbar-title { font-weight: 700; }

.hero {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 34px 38px;
  box-shadow: var(--shadow-card);
}

.hero-badge {
  display: inline-block;
  background: var(--accent-soft);
  color: #3d47b0;
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 999px;
  margin-bottom: 16px;
}

.hero h1 {
  font-size: 34px;
  line-height: 1.2;
  margin: 0 0 14px;
  max-width: 760px;
  letter-spacing: -0.01em;
}

.hero > p {
  color: var(--text-muted);
  font-size: 15px;
  max-width: 640px;
  line-height: 1.6;
  margin: 0 0 22px;
}

.hero-tip {
  display: flex;
  gap: 12px;
  background: var(--accent-soft);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  font-size: 13.5px;
  max-width: 640px;
  align-items: flex-start;
}
.hero-tip-icon { font-size: 16px; }
.hero-tip div { color: #4a5185; line-height: 1.55; }
.hero-tip strong { color: #2b3168; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-top: 20px;
}

.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  box-shadow: var(--shadow-card);
}
.stat-number { font-size: 26px; font-weight: 800; }
.stat-label { color: var(--text-muted); font-size: 12.5px; margin-top: 2px; }

/* ---------- Filter bar (sticky supaya tetap terjangkau di 99 kartu) ---------- */

.filter-bar {
  margin-top: 20px;
  background: var(--card-bg);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  box-shadow: 0 6px 20px -12px rgba(20, 22, 42, 0.4);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 15;
}

.filter-bar input[type="search"] {
  flex: 1 1 200px;
  min-width: 160px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft);
  font-size: 13.5px;
  background: #fafbfe;
  color: var(--text-main);
}
.filter-bar input[type="search"]:focus { border-color: var(--accent); }

.filter-bar select {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft);
  font-size: 13px;
  background: #fafbfe;
  color: var(--text-main);
  cursor: pointer;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  cursor: pointer;
}

#resetBtn {
  background: var(--text-main);
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}
#resetBtn:hover { opacity: 0.9; }

.results-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 16px 2px 14px;
  font-size: 13px;
  color: var(--text-muted);
}

.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 11.5px; }
.legend-item { display: inline-flex; align-items: center; gap: 5px; color: var(--text-soft); }
.legend-star {
  width: 20px; height: 20px;
  border-radius: 6px;
  font-size: 11px;
}

/* ---------- Grid kartu ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(255px, 1fr));
  gap: 18px;
}
.grid:focus { outline: none; }

.idea-card {
  background: var(--card-bg);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-card);
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 0.15s ease, border-color 0.15s ease;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: inherit;
}
.idea-card:hover { transform: translateY(-2px); border-color: var(--border-soft); }

.idea-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.idea-number {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  background: #f4f5fa;
  padding: 3px 9px;
  border-radius: 8px;
}

.star-badge {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: var(--text-main);
  color: #ffd75e;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
}
.star-badge.off { background: #f1f2f6; color: #64697c; }

.idea-title {
  display: block;
  font-size: 16.5px;
  font-weight: 700;
  line-height: 1.35;
}

.badge-row { display: flex; gap: 6px; flex-wrap: wrap; }

.badge {
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
.badge.signal-strong { background: var(--strong-bg); color: var(--strong); }
.badge.signal-medium { background: var(--medium-bg); color: var(--medium); }
.badge.signal-niche { background: var(--niche-bg); color: var(--niche); }
.badge.buyer { background: #f1f0fb; color: #4f46b8; }
.badge.difficulty { background: #eef7f0; color: #1a6b3b; }
.badge.score { background: #f4f5fa; color: #565c78; }

.idea-desc {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.55;
  flex: 1;
}

.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }

.chip {
  font-size: 11.5px;
  color: #4b5170;
  background: #f4f5fa;
  padding: 4px 9px;
  border-radius: 8px;
}

.idea-link {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  margin-top: 4px;
}

/* ---------- Status kosong ---------- */

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 48px 24px;
  background: var(--card-bg);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
}
.empty-state-icon { font-size: 32px; margin-bottom: 10px; }
.empty-state h3 { margin: 0 0 6px; font-size: 18px; }
.empty-state p { margin: 0 0 18px; color: var(--text-muted); font-size: 13.5px; }
.empty-state button {
  background: var(--text-main);
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

/* ---------- Kembali ke atas ---------- */

.back-to-top {
  position: fixed;
  right: 22px; bottom: 22px;
  z-index: 25;
  width: 46px; height: 46px;
  border-radius: 50%;
  border: none;
  background: var(--text-main);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  box-shadow: 0 8px 22px -8px rgba(0,0,0,0.5);
}
.back-to-top:hover { background: var(--accent); }

/* ---------- Modal ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 17, 32, 0.55);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
  z-index: 50;
}
.modal-overlay.open { display: flex; }

.modal {
  background: #fff;
  border-radius: 22px;
  max-width: 780px;
  width: 100%;
  padding: 30px 34px 34px;
  position: relative;
  box-shadow: 0 30px 60px -20px rgba(0,0,0,0.35);
}
.modal:focus { outline: none; }

.modal-close {
  position: absolute;
  top: 22px; right: 26px;
  background: #eceef5;
  border: none;
  width: 36px; height: 36px;
  border-radius: 10px;
  font-size: 14px;
  cursor: pointer;
  color: #3c4155;
}
.modal-close:hover { background: #dfe2ee; }

.modal-header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  padding-right: 46px;
}

.modal-id {
  background: var(--text-main);
  color: #fff;
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 700;
}

.modal-category { color: #3d47b0; font-weight: 600; font-size: 13.5px; }

.modal-recommended {
  background: #fff6da;
  color: #7a5f06;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
}

.modal h2 { font-size: 27px; margin: 0 0 12px; }

.modal-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }

.modal-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 20px;
}

.info-card {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 16px;
}

.info-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-soft);
  font-weight: 700;
  margin-bottom: 8px;
}

.info-text { font-size: 14px; line-height: 1.55; color: var(--text-main); }

.modal-features { margin-bottom: 22px; }

.validation-box {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 18px;
  margin-bottom: 20px;
}
.validation-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 13.5px;
  margin-bottom: 12px;
}
.validation-hint { font-size: 11.5px; color: var(--text-soft); font-weight: 500; }

.validation-links { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.validation-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--text-main);
  color: #fff;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}
.validation-link:hover { background: var(--accent); }

.validation-tips { font-size: 12px; color: var(--text-muted); margin: 12px 0 0; line-height: 1.55; }

.prompt-box {
  background: #f7f8fc;
  border: 1px dashed #d0d4e8;
  border-radius: var(--radius-md);
  padding: 18px;
}
.prompt-title { font-weight: 700; font-size: 14px; margin-bottom: 8px; }
.prompt-text { font-size: 13.5px; line-height: 1.6; color: #383d55; margin: 0 0 14px; }
.prompt-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.prompt-actions button {
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
}
#copyPromptBtn { background: var(--text-main); color: #fff; }
#copyPromptBtn.copied, #shareBtn.copied { background: #1a6b3b; color: #fff; }
.prompt-actions .secondary { background: #eceef5; color: #3c4155; }

/* ---------- Responsif ---------- */

@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .modal-info-grid { grid-template-columns: 1fr; }
  .validation-links { grid-template-columns: 1fr; }
}

/* Sidebar keluar dari alur sebelum grid kehilangan kolom keduanya */
@media (max-width: 1024px) {
  .sidebar {
    position: fixed;
    z-index: 30;
    margin-left: -270px;
    box-shadow: 0 0 40px rgba(0,0,0,0.35);
  }
  .sidebar.visible { margin-left: 0; }
  .topbar {
    display: flex;
    position: sticky;
    top: 0;
    z-index: 16;
    margin: -18px -16px 14px;
    padding: 10px 16px;
    background: var(--card-bg);
    box-shadow: 0 4px 14px -10px rgba(20,22,42,0.5);
  }
  .filter-bar { top: 56px; }
  .main { padding: 18px 16px 40px; }
  .hero { padding: 24px 22px; }
  .hero h1 { font-size: 26px; }
  .show-sidebar-btn { display: none; }
}

@media (max-width: 720px) {
  .stats { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .filter-bar { padding: 12px; }
  .filter-bar select, .checkbox-label, #resetBtn { flex: 1 1 auto; }
  .legend { display: none; }

  .modal-overlay { padding: 0; }
  .modal {
    border-radius: 18px 18px 0 0;
    padding: 22px 16px 28px;
    min-height: 100%;
  }
  .modal h2 { font-size: 21px; }
  /* Tombol tutup dipatok ke viewport supaya tidak ikut tergulung ke atas */
  .modal-close {
    position: fixed;
    top: 12px; right: 12px;
    z-index: 60;
    width: 44px; height: 44px;
    box-shadow: 0 4px 14px -4px rgba(0,0,0,0.4);
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .idea-card:hover { transform: none; }
}
