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

:root {
  --primary: #053cfe;
  --primary-dark: #0330d4;
  --yellow: #f1ff9b;
  --light-blue: #edf1ff;
  --pale-blue: #d2dcff;
  --text: #0a0a0a;
  --text-secondary: #666;
  --white: #ffffff;
  --border: #e2e8f0;
  --radius: 12px;
  --radius-pill: 48px;
  --shadow: 0 4px 20px rgba(0,0,0,0.08);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.06);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

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

/* ── Header ── */
header {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 0 40px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.logo-icon {
  width: 32px;
  height: 32px;
  background: var(--primary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-icon svg { color: white; }

.logo-text {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.logo-text span { color: var(--primary); }

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

.header-right a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

/* ── Layout ── */
.app-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  min-height: calc(100vh - 60px);
}

/* ── Sidebar ── */
aside {
  background: var(--white);
  border-right: 1px solid var(--border);
  padding: 32px 24px;
  position: sticky;
  top: 60px;
  height: calc(100vh - 60px);
  overflow-y: auto;
}

.sidebar-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.search-form { display: flex; flex-direction: column; gap: 16px; }

.form-group { display: flex; flex-direction: column; gap: 6px; }

label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

input[type="text"], select {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--white);
  outline: none;
  transition: border-color 0.15s;
}

input[type="text"]:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(5,60,254,0.08);
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--light-blue);
  border-radius: 10px;
}

.toggle-label { font-size: 13px; font-weight: 500; }
.toggle-sub { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }

.toggle {
  width: 40px; height: 22px;
  background: var(--border);
  border-radius: 11px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}

.toggle.on { background: var(--primary); }

.toggle::after {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  background: white;
  border-radius: 50%;
  top: 3px; left: 3px;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle.on::after { transform: translateX(18px); }

.btn-analyze {
  width: 100%;
  padding: 13px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-pill);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  letter-spacing: -0.01em;
}

.btn-analyze:hover { background: var(--primary-dark); }
.btn-analyze:active { transform: scale(0.98); }
.btn-analyze:disabled { background: #b0b8d4; cursor: not-allowed; transform: none; }

/* App cards in sidebar */
.apps-section { margin-top: 28px; }
.apps-section-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.app-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  background: var(--white);
}

.app-card img {
  width: 40px; height: 40px;
  border-radius: 9px;
  object-fit: cover;
  flex-shrink: 0;
}

.app-card-info { flex: 1; min-width: 0; }
.app-card-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-card-dev { font-size: 11px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-card-meta { display: flex; align-items: center; gap: 6px; margin-top: 3px; }

.store-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.store-badge.apple { background: #f0f0f0; color: #333; }
.store-badge.google { background: #e8f5e9; color: #2e7d32; }

.rating-badge {
  font-size: 11px;
  font-weight: 600;
  color: #f59e0b;
}

/* ── Main content ── */
main {
  padding: 32px 40px;
  max-width: 1100px;
}

/* ── Progress ── */
#progress-area {
  margin-bottom: 24px;
}

.progress-bar-wrap {
  height: 4px;
  background: var(--pale-blue);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 10px;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--primary), #7c3aed);
  width: 0%;
  transition: width 0.4s ease;
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% { opacity: 1; }
  50% { opacity: 0.7; }
  100% { opacity: 1; }
}

.progress-text {
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.spinner {
  width: 14px; height: 14px;
  border: 2px solid var(--pale-blue);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

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

/* ── Empty state ── */
#empty-state {
  text-align: center;
  padding: 80px 40px;
}

.empty-icon {
  width: 64px; height: 64px;
  background: var(--light-blue);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
}

.empty-title { font-size: 22px; font-weight: 700; margin-bottom: 8px; letter-spacing: -0.02em; }
.empty-sub { font-size: 15px; color: var(--text-secondary); max-width: 380px; margin: 0 auto; }

/* ── Section headers ── */
.section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  margin-top: 36px;
}

.section-header:first-child { margin-top: 0; }

.section-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.section-pill {
  font-size: 12px;
  font-weight: 600;
  background: var(--light-blue);
  color: var(--primary);
  padding: 3px 10px;
  border-radius: var(--radius-pill);
}

/* ── Charts grid ── */
#charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 8px;
}

.chart-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.chart-card.full-width { grid-column: 1 / -1; }

.chart-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.chart-title .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--primary);
  flex-shrink: 0;
}

.chart-canvas-wrap { position: relative; height: 220px; }

/* ── Skeleton loader ── */
.skeleton {
  background: linear-gradient(90deg, #f0f4ff 25%, #e0e8ff 50%, #f0f4ff 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s infinite;
  border-radius: 8px;
  height: 220px;
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Report ── */
#report-section { margin-top: 36px; }

#report-content {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 36px;
  box-shadow: var(--shadow-sm);
  line-height: 1.75;
}

#report-content h1 { font-size: 24px; font-weight: 800; letter-spacing: -0.03em; margin-bottom: 6px; }
#report-content h2 { font-size: 18px; font-weight: 700; margin-top: 28px; margin-bottom: 12px; letter-spacing: -0.02em; }
#report-content h3 { font-size: 15px; font-weight: 600; margin-top: 20px; margin-bottom: 8px; }
#report-content p { margin-bottom: 12px; }
#report-content ul, #report-content ol { padding-left: 20px; margin-bottom: 12px; }
#report-content li { margin-bottom: 4px; }
#report-content em { color: var(--text-secondary); font-style: italic; }
#report-content strong { font-weight: 600; }

#report-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 14px;
}

#report-content th {
  background: var(--light-blue);
  font-weight: 600;
  text-align: left;
  padding: 10px 12px;
  border: 1px solid var(--pale-blue);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--primary);
}

#report-content td {
  padding: 9px 12px;
  border: 1px solid var(--border);
  vertical-align: top;
}

#report-content tr:nth-child(even) td { background: #fafbff; }

#report-content blockquote {
  border-left: 3px solid var(--primary);
  padding-left: 16px;
  color: var(--text-secondary);
  margin: 16px 0;
}

.export-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: var(--yellow);
  color: var(--text);
  border: none;
  border-radius: var(--radius-pill);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  text-decoration: none;
  margin-top: 20px;
}

.export-btn:hover { opacity: 0.85; }

/* ── Review Browser ── */
#reviews-section { margin-top: 36px; }

.review-filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  align-items: center;
}

.filter-search {
  flex: 1;
  min-width: 200px;
  padding: 9px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-pill);
  font-family: inherit;
  font-size: 13px;
  outline: none;
}

.filter-search:focus { border-color: var(--primary); }

.filter-select {
  padding: 9px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-pill);
  font-family: inherit;
  font-size: 13px;
  background: var(--white);
  cursor: pointer;
  outline: none;
}

.filter-select:focus { border-color: var(--primary); }

.review-count-badge {
  font-size: 13px;
  color: var(--text-secondary);
  margin-left: auto;
  white-space: nowrap;
}

#review-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.review-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  transition: box-shadow 0.15s;
}

.review-card:hover { box-shadow: var(--shadow-sm); }

.review-card-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 8px;
}

.review-stars { color: #f59e0b; font-size: 13px; letter-spacing: 1px; }

.review-meta { flex: 1; }
.review-author { font-size: 13px; font-weight: 600; }
.review-date-ver { font-size: 11px; color: var(--text-secondary); margin-top: 1px; }

.sentiment-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  flex-shrink: 0;
}

.sentiment-badge.positive { background: #dcfce7; color: #15803d; }
.sentiment-badge.negative { background: #fee2e2; color: #dc2626; }
.sentiment-badge.mixed { background: #fef9c3; color: #a16207; }
.sentiment-badge.neutral { background: #f1f5f9; color: #475569; }

.review-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
}

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

.review-footer {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.emotion-tag {
  font-size: 11px;
  padding: 2px 8px;
  background: var(--light-blue);
  color: var(--primary);
  border-radius: var(--radius-pill);
  font-weight: 500;
}

.key-phrase {
  font-size: 11px;
  color: var(--text-secondary);
  font-style: italic;
  margin-left: auto;
}

.store-icon { font-size: 13px; }

/* ── Error state ── */
.error-banner {
  background: #fee2e2;
  border: 1px solid #fca5a5;
  border-radius: var(--radius);
  padding: 14px 18px;
  color: #dc2626;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 16px;
}

/* ── Responsive ── */
@media (max-width: 900px) {
  .app-layout { grid-template-columns: 1fr; }
  aside { position: static; height: auto; border-right: none; border-bottom: 1px solid var(--border); }
  main { padding: 24px 20px; }
  #charts-grid { grid-template-columns: 1fr; }
}
