@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
  --bg: #0a0e1a;
  --bg-card: rgba(17, 24, 39, 0.7);
  --bg-glass: rgba(255, 255, 255, 0.04);
  --border: rgba(255, 255, 255, 0.08);
  --text: #f1f5f9;
  --text-sec: #94a3b8;
  --text-muted: #64748b;
  --accent: #6366f1;
  --accent-light: #818cf8;
  --accent-glow: rgba(99, 102, 241, 0.3);
  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;
  --cyan: #06b6d4;
  --pink: #ec4899;
  --gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a78bfa 100%);
  --radius: 12px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

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

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 20% 20%, rgba(99,102,241,0.06) 0%, transparent 50%),
              radial-gradient(circle at 80% 80%, rgba(139,92,246,0.05) 0%, transparent 50%);
  z-index: -1;
}

.container { max-width: 1200px; margin: 0 auto; padding: 24px 16px 60px; }

/* Header */
.header { text-align: center; padding: 32px 0 24px; }
.header h1 {
  font-size: 1.8rem; font-weight: 800;
  background: var(--gradient); -webkit-background-clip: text;
  -webkit-text-fill-color: transparent; background-clip: text;
}
.header p { color: var(--text-sec); font-size: 0.9rem; margin-top: 4px; }
.header .badge {
  display: inline-block; margin-top: 12px; padding: 6px 16px;
  background: var(--accent-glow); border: 1px solid rgba(99,102,241,0.3);
  border-radius: 100px; font-size: 0.8rem; color: var(--accent-light); font-weight: 600;
}

/* Global Filter Bar */
.filter-bar {
  display: flex; align-items: center; gap: 12px; margin-bottom: 24px;
  padding: 14px 20px; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); backdrop-filter: blur(12px);
  position: sticky; top: 0; z-index: 100; flex-wrap: wrap;
}
.filter-label { font-size: 0.85rem; font-weight: 600; color: var(--text-sec); white-space: nowrap; }
.filter-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  padding: 6px 16px; border: 1px solid var(--border); border-radius: 100px;
  background: var(--bg-glass); color: var(--text-sec); font-family: 'Inter', sans-serif;
  font-size: 0.8rem; font-weight: 500; cursor: pointer; transition: var(--transition);
}
.chip:hover { border-color: var(--accent); color: var(--text); }
.chip.active {
  background: var(--gradient); border-color: var(--accent); color: #fff;
  font-weight: 600; box-shadow: 0 2px 12px var(--accent-glow);
}

/* Stats Grid */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px; margin-bottom: 28px;
}
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; backdrop-filter: blur(12px);
  transition: var(--transition);
}
.stat-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.stat-card .icon { font-size: 1.5rem; margin-bottom: 8px; }
.stat-card .value { font-size: 1.8rem; font-weight: 800; }
.stat-card .label { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; }
.stat-card .sub-label { font-size: 0.68rem; color: var(--text-muted); margin-top: 4px; opacity: 0.7; font-weight: 400; }
.stat-card.accent .value { color: var(--accent-light); }
.stat-card.success .value { color: var(--success); }
.stat-card.warning .value { color: var(--warning); }
.stat-card.pink .value { color: var(--pink); }
.stat-card.cyan .value { color: var(--cyan); }

/* Section */
.section {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px; backdrop-filter: blur(12px);
  margin-bottom: 20px;
}
.section-title {
  font-size: 1.1rem; font-weight: 700; margin-bottom: 16px;
  display: flex; align-items: center; gap: 8px;
}
.section-title .icon { font-size: 1.2rem; }

/* Charts Grid */
.charts-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 20px; margin-bottom: 28px;
}
.chart-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; backdrop-filter: blur(12px);
}
.chart-card h3 {
  font-size: 0.9rem; font-weight: 600; color: var(--text-sec);
  margin-bottom: 12px; display: flex; align-items: center; gap: 8px;
}
.chart-card canvas { max-height: 280px; }

/* Table */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
thead th {
  padding: 10px 12px; text-align: left; font-weight: 600;
  color: var(--text-muted); border-bottom: 1px solid var(--border);
  white-space: nowrap; position: sticky; top: 0; background: var(--bg-card);
}
tbody td {
  padding: 10px 12px; border-bottom: 1px solid rgba(255,255,255,0.03);
  color: var(--text-sec); max-width: 200px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
tbody tr:hover td { background: var(--bg-glass); color: var(--text); }

/* Tags */
.tag {
  display: inline-block; padding: 2px 8px; border-radius: 6px;
  font-size: 0.7rem; font-weight: 500; margin: 1px;
  background: rgba(99,102,241,0.15); color: var(--accent-light); border: 1px solid rgba(99,102,241,0.2);
}

/* Toolbar */
.toolbar {
  display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; align-items: center;
}
.toolbar input, .toolbar select {
  padding: 8px 14px; background: var(--bg-glass); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-family: 'Inter', sans-serif;
  font-size: 0.82rem; outline: none; transition: var(--transition);
}
.toolbar input:focus, .toolbar select:focus {
  border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-glow);
}
.toolbar select { appearance: none; padding-right: 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.toolbar select option { background: #1e293b; }

.btn-export {
  padding: 8px 18px; background: var(--gradient); border: none;
  border-radius: 8px; color: #fff; font-family: 'Inter', sans-serif;
  font-size: 0.82rem; font-weight: 600; cursor: pointer; transition: var(--transition);
}
.btn-export:hover { transform: translateY(-1px); box-shadow: 0 4px 16px var(--accent-glow); }
.toolbar .count { font-size: 0.8rem; color: var(--text-muted); margin-left: auto; }

/* Loading */
.loading { text-align: center; padding: 60px; }
.loading .spinner {
  width: 36px; height: 36px; border: 3px solid rgba(255,255,255,0.1);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin 0.6s linear infinite; margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading p { color: var(--text-muted); font-size: 0.85rem; }

/* Empty */
.empty { text-align: center; padding: 60px; color: var(--text-muted); }
.empty .icon { font-size: 3rem; margin-bottom: 12px; }

/* Responsive */
@media (max-width: 768px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .charts-grid { grid-template-columns: 1fr; }
  .header h1 { font-size: 1.4rem; }
  .toolbar { flex-direction: column; }
  .toolbar .count { margin-left: 0; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .container { padding: 12px 10px 40px; }
}

/* Insight Section */
.insight-section {
  margin-top: 28px;
}
.insight-section .section-title {
  font-size: 1.2rem;
  margin-bottom: 20px;
}
.insight-block {
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 22px;
  margin-bottom: 14px;
  border-left: 3px solid var(--accent);
  transition: var(--transition);
}
.insight-block:hover {
  border-left-color: var(--accent-light);
  background: rgba(255,255,255,0.06);
  transform: translateX(4px);
}
.insight-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--accent-light);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.insight-block p {
  font-size: 0.84rem;
  color: var(--text-sec);
  line-height: 1.75;
  margin: 0;
}
.insight-block p strong {
  color: var(--text);
  font-weight: 600;
}
.insight-summary {
  background: linear-gradient(135deg, rgba(99,102,241,0.08) 0%, rgba(139,92,246,0.08) 100%);
  border-left: 3px solid var(--accent-light);
  border: 1px solid rgba(99,102,241,0.25);
  border-left: 3px solid var(--accent-light);
}
.insight-summary .insight-title {
  color: #a78bfa;
  font-size: 0.92rem;
}
.insight-summary p {
  color: var(--text);
  font-size: 0.86rem;
}
.insight-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 24px;
  font-size: 0.85rem;
}

/* Open Response Sections */
.open-response-section {
  margin-bottom: 20px;
}
.open-response-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.keyword-cloud-card,
.responses-card {
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
}
.keyword-cloud-card h4,
.responses-card h4 {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-sec);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.response-count {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 0.75rem;
}

/* Keyword Cloud */
.keyword-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.kw-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  border-radius: 100px;
  border: 1px solid;
  font-weight: 500;
  cursor: default;
  transition: var(--transition);
  white-space: nowrap;
}
.kw-tag:hover {
  transform: scale(1.08);
  filter: brightness(1.2);
}
.kw-tag small {
  font-size: 0.65em;
  opacity: 0.7;
  font-weight: 400;
}

/* Response Cards */
.responses-scroll {
  max-height: 360px;
  overflow-y: auto;
  padding-right: 6px;
}
.response-item {
  padding: 12px 14px;
  margin-bottom: 8px;
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 8px;
  border-left: 3px solid var(--accent);
  transition: var(--transition);
}
.response-item:hover {
  background: rgba(255,255,255,0.05);
  border-left-color: var(--accent-light);
}
.response-text {
  font-size: 0.8rem;
  color: var(--text-sec);
  line-height: 1.6;
  font-style: italic;
  margin-bottom: 6px;
}
.response-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.7rem;
}
.response-name {
  color: var(--accent-light);
  font-weight: 600;
}
.response-sem {
  color: var(--text-muted);
  background: rgba(99,102,241,0.12);
  padding: 1px 8px;
  border-radius: 100px;
  font-size: 0.65rem;
}
.no-data {
  color: var(--text-muted);
  font-size: 0.8rem;
  text-align: center;
  padding: 20px;
  display: block;
}

@media (max-width: 768px) {
  .open-response-grid { grid-template-columns: 1fr; }
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 100px; }
