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

:root {
  --bg-dark: #090d16;
  --bg-card: #131b2e;
  --bg-card-hover: #1b2640;
  --border-color: #24324f;
  --border-highlight: #3b82f6;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --primary-accent: #6366f1;
  --primary-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  --cb-gold: #fbbf24;
  --cb-gold-glow: rgba(251, 191, 36, 0.6);
  --danger-accent: #ef4444;
  --success-accent: #10b981;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-main: 0 10px 30px -5px rgba(0, 0, 0, 0.5);
  --glass-bg: rgba(19, 27, 46, 0.75);
  --glass-border: rgba(255, 255, 255, 0.08);
}

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

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  background-image: 
    radial-gradient(circle at 20% 20%, rgba(99, 102, 241, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(251, 191, 36, 0.06) 0%, transparent 40%);
}

/* Header */
.header {
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: var(--primary-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-family: 'Outfit', sans-serif;
  color: #fff;
  font-size: 1.2rem;
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.5);
}

.brand-text h1 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(90deg, #ffffff 0%, #cbd5e1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-text p {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.header-stats {
  display: flex;
  gap: 1.5rem;
}

.stat-pill {
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid var(--border-color);
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
}

.stat-pill .val {
  font-weight: 700;
  color: var(--primary-accent);
}

.stat-pill.cb .val {
  color: var(--cb-gold);
}

/* Layout */
.main-container {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 1.5rem;
  padding: 1.5rem 2rem;
  flex: 1;
  max-width: 1800px;
  margin: 0 auto;
  width: 100%;
}

/* Sidebar */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.card {
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-main);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

.card-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.05rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Controls */
.filter-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}

.tab-btn {
  background: var(--bg-card-hover);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.tab-btn.active {
  background: var(--primary-accent);
  color: #fff;
  border-color: var(--primary-accent);
}

.select-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}

.select-group label {
  font-size: 0.8rem;
  color: var(--text-muted);

}

.select-wrapper {
  position: relative;
}

select.form-control {
  width: 100%;
  background: #0f172a;
  border: 1px solid var(--border-color);
  color: #fff;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s;
}

select.form-control:focus {
  border-color: var(--primary-accent);
}

.nav-buttons {
  display: flex;
  gap: 0.5rem;
}

.btn {
  background: var(--bg-card-hover);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.55rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  flex: 1;
}

.btn:hover {
  background: #24324f;
  border-color: #38bdf8;
}

.btn-primary {
  background: var(--primary-gradient);
  border: none;
  color: #fff;
}

.btn-primary:hover {
  opacity: 0.9;
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.4);
}

/* Word Summary Card */
.word-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.6rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 0.25rem;
  word-break: break-word;
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(99, 102, 241, 0.2);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 1rem;
}

.summary-item {
  background: rgba(15, 23, 42, 0.6);
  padding: 0.65rem 0.8rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.summary-item .label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.summary-item .value {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  margin-top: 0.2rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.color-swatch-sm {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  display: inline-block;
  border: 1px solid rgba(255, 255, 255, 0.4);
  box-shadow: 0 0 5px rgba(0,0,0,0.5);
}

/* Colorblind response cards list */
.cb-users-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  max-height: 260px;
  overflow-y: auto;
  padding-right: 0.3rem;
}

.cb-user-card {
  background: rgba(251, 191, 36, 0.08);
  border: 1px solid rgba(251, 191, 36, 0.3);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.2s;
}

.cb-user-card:hover {
  background: rgba(251, 191, 36, 0.15);
  transform: translateX(2px);
}

.cb-user-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.cb-user-id {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--cb-gold);
  font-family: monospace;
}

.cb-user-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.cb-user-pick {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.coord-tag {
  background: rgba(0,0,0,0.4);
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  font-weight: 700;
  font-size: 0.82rem;
  color: #fff;
  border: 1px solid var(--border-color);
}

/* Main Display Area */
.display-area {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.board-container-card {
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-main);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.board-toolbar {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.toggle-group {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.toggle-label input {
  accent-color: var(--primary-accent);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

/* Board Grid Layout */
.board-wrapper {
  position: relative;
  max-width: 100%;
  overflow-x: auto;
  padding: 0.5rem;
  border-radius: var(--radius-md);
  background: #060911;
  border: 1px solid var(--border-color);
}

.board-grid-container {
  display: grid;
  /* 1 label col + 30 data cols */
  grid-template-columns: 28px repeat(30, minmax(24px, 32px));
  /* 1 label row + 16 data rows + 1 bottom label row */
  grid-template-rows: 24px repeat(16, minmax(24px, 32px)) 24px;
  gap: 2px;
  user-select: none;
}

.axis-label {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  font-family: monospace;
}

.cell {
  position: relative;
  border-radius: 2px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, z-index 0s;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
}

.cell:hover {
  transform: scale(1.35);
  z-index: 50;
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.8);
  border-radius: 4px;
}

/* Heatmap Overlay */
.cell-overlay {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease;
}

.cell-count-badge {
  font-size: 0.65rem;
  font-weight: 800;
  color: #ffffff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.9), 0 0 5px rgba(0,0,0,0.9);
  pointer-events: none;
  z-index: 2;
}

/* Colorblind Marker Overlay */
.cb-marker {
  position: absolute;
  inset: -2px;
  border: 2px solid var(--cb-gold);
  border-radius: 4px;
  pointer-events: none;
  z-index: 10;
  box-shadow: 0 0 10px var(--cb-gold-glow), inset 0 0 6px var(--cb-gold-glow);
  animation: pulse-cb 2s infinite ease-in-out;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cb-marker::after {
  content: '★';
  font-size: 0.75rem;
  color: var(--cb-gold);
  text-shadow: 0 0 4px #000, 0 0 8px var(--cb-gold);
}

@keyframes pulse-cb {
  0% { transform: scale(1); box-shadow: 0 0 8px var(--cb-gold-glow); }
  50% { transform: scale(1.1); box-shadow: 0 0 16px var(--cb-gold); }
  100% { transform: scale(1); box-shadow: 0 0 8px var(--cb-gold-glow); }
}

/* Tooltip */
.cell-tooltip {
  position: absolute;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-highlight);
  border-radius: var(--radius-md);
  padding: 0.6rem 0.85rem;
  color: #fff;
  font-size: 0.8rem;
  pointer-events: none;
  z-index: 200;
  box-shadow: 0 10px 25px rgba(0,0,0,0.6);
  display: none;
  min-width: 180px;
}

.tooltip-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 0.4rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  padding-bottom: 0.25rem;
}

.tooltip-row {
  display: flex;
  justify-content: space-between;
  margin-top: 0.25rem;
  color: var(--text-muted);
}

.tooltip-row span.val {
  color: #fff;
  font-weight: 600;
}

/* Legend */
.legend-bar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-top: 0.75rem;
  padding: 0.5rem 1rem;
  background: rgba(15, 23, 42, 0.5);
  border-radius: var(--radius-md);
  border: 1px solid rgba(255,255,255,0.05);
  font-size: 0.8rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.legend-color-ramp {
  width: 80px;
  height: 10px;
  border-radius: 3px;
  background: linear-gradient(90deg, rgba(255,255,255,0.1) 0%, rgba(99,102,241,0.6) 50%, rgba(239,68,68,0.9) 100%);
}

.legend-star {
  color: var(--cb-gold);
  font-size: 0.9rem;
}

/* Responsive adjustments */
@media (max-width: 1200px) {
  .main-container {
    grid-template-columns: 1fr;
  }
}
