/* ═══════════════════════════════════════════════════════════════════════════════
   Vineyes Social Intelligence Dashboard — Design System
   Premium dark-mode glassmorphism theme
   ═══════════════════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ── CSS Custom Properties ──────────────────────────────────────────────────── */
:root {
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-card: rgba(255, 255, 255, 0.04);
  --bg-card-hover: rgba(255, 255, 255, 0.07);
  --bg-sidebar: rgba(15, 23, 42, 0.95);
  --bg-input: rgba(255, 255, 255, 0.06);

  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.15);

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-glow: rgba(99, 102, 241, 0.3);
  --gradient-accent: linear-gradient(135deg, #6366f1, #8b5cf6);

  --positive: #10b981;
  --positive-bg: rgba(16, 185, 129, 0.12);
  --negative: #ef4444;
  --negative-bg: rgba(239, 68, 68, 0.12);
  --neutral-color: #6b7280;
  --neutral-bg: rgba(107, 114, 128, 0.12);
  --warning: #f59e0b;

  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.4);
  --blur: blur(20px);
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset & Base ───────────────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

#root {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────────────────────────── */
.sidebar {
  width: 280px;
  min-height: 100vh;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  backdrop-filter: var(--blur);
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo h1 {
  font-size: 18px;
  font-weight: 700;
  background: var(--gradient-accent);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-logo .logo-icon {
  width: 36px;
  height: 36px;
  background: var(--gradient-accent);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: white;
}

.filter-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.filter-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.filter-input,
.filter-select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text-primary);
  padding: 8px 12px;
  font-size: 13px;
  font-family: inherit;
  transition: var(--transition);
  width: 100%;
}

.filter-input:focus,
.filter-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.filter-select {
  cursor: pointer;
}

.filter-select option {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

/* ── Main Content ───────────────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: 280px;
  padding: 32px 40px;
  min-height: 100vh;
  background: linear-gradient(180deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
}

.page-header {
  margin-bottom: 32px;
}

.page-header h2 {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 6px;
}

.page-header p {
  font-size: 14px;
  color: var(--text-secondary);
}

/* ── Nav Tabs ───────────────────────────────────────────────────────────────── */
.nav-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 32px;
  overflow-x: auto;
}

.nav-tab {
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  border: none;
  background: transparent;
  white-space: nowrap;
  font-family: inherit;
}

.nav-tab:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
}

.nav-tab.active {
  background: var(--gradient-accent);
  color: white;
  font-weight: 600;
  box-shadow: 0 4px 12px var(--accent-glow);
}

/* ── Grid Layouts ───────────────────────────────────────────────────────────── */
.grid-6 {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 16px;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.grid-1 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

@media (max-width: 1400px) {
  .grid-6 {
    grid-template-columns: repeat(3, 1fr);
  }

  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 1024px) {

  .grid-3,
  .grid-4,
  .grid-6 {
    grid-template-columns: repeat(2, 1fr);
  }

  .sidebar {
    width: 240px;
  }

  .main-content {
    margin-left: 240px;
    padding: 24px;
  }
}

@media (max-width: 768px) {

  .grid-2,
  .grid-3,
  .grid-4,
  .grid-6 {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }

  .main-content {
    margin-left: 0;
  }
}

/* ── Card ───────────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  backdrop-filter: var(--blur);
  transition: var(--transition);
}

.card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
  box-shadow: var(--shadow);
}

.card-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.card-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  font-weight: 400;
}

/* ── KPI Card ───────────────────────────────────────────────────────────────── */
.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  backdrop-filter: var(--blur);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--gradient-accent);
  opacity: 0;
  transition: var(--transition);
}

.kpi-card:hover::before {
  opacity: 1;
}

.kpi-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow);
}

.kpi-icon {
  font-size: 20px;
  margin-bottom: 8px;
}

.kpi-value {
  font-size: 28px;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 4px;
}

.kpi-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

/* ── AI Insight Box ─────────────────────────────────────────────────────────── */
.ai-insight {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(139, 92, 246, 0.05));
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: var(--radius);
  padding: 24px;
  position: relative;
  overflow: hidden;
}

.ai-insight::before {
  content: '✨';
  position: absolute;
  top: 16px;
  right: 16px;
  font-size: 20px;
  opacity: 0.6;
}

.ai-insight-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-weight: 600;
  font-size: 14px;
  color: var(--accent-hover);
}

.ai-insight-body {
  font-size: 14px;
  line-height: 1.8;
  color: var(--text-secondary);
  white-space: pre-wrap;
}

.ai-insight-loading {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 13px;
}

.pulse {
  width: 10px;
  height: 10px;
  background: var(--accent);
  border-radius: 50%;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 0.4;
    transform: scale(0.8);
  }

  50% {
    opacity: 1;
    transform: scale(1.2);
  }
}

/* ── Chart Card ─────────────────────────────────────────────────────────────── */
.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  backdrop-filter: var(--blur);
}

.chart-card-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
}

.chart-card-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  padding: 10px 20px;
  border-radius: var(--radius-xs);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-primary {
  background: var(--gradient-accent);
  color: white;
  box-shadow: 0 4px 12px var(--accent-glow);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px var(--accent-glow);
}

.btn-secondary {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  border-color: var(--border-hover);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* ── Sentiment Badges ───────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  text-transform: capitalize;
}

.badge-positive {
  background: var(--positive-bg);
  color: var(--positive);
}

.badge-negative {
  background: var(--negative-bg);
  color: var(--negative);
}

.badge-neutral {
  background: var(--neutral-bg);
  color: var(--neutral-color);
}

/* ── Data Table ─────────────────────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

.data-table thead th {
  background: rgba(255, 255, 255, 0.04);
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
}

.data-table tbody td {
  padding: 10px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  color: var(--text-secondary);
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

/* ── Chat ───────────────────────────────────────────────────────────────────── */
.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 240px);
  min-height: 400px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chat-msg {
  max-width: 80%;
  padding: 14px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.7;
  animation: msgIn 0.3s ease;
}

@keyframes msgIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chat-msg.user {
  align-self: flex-end;
  background: var(--gradient-accent);
  color: white;
  border-bottom-right-radius: 4px;
}

.chat-msg.assistant {
  align-self: flex-start;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-bottom-left-radius: 4px;
  white-space: pre-wrap;
}

.chat-input-bar {
  display: flex;
  gap: 12px;
  padding: 16px 0 0;
  border-top: 1px solid var(--border);
}

.chat-input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 12px 16px;
  font-size: 14px;
  font-family: inherit;
  transition: var(--transition);
}

.chat-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ── Bar Chart (simple CSS bars) ────────────────────────────────────────────── */
.bar-chart {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.bar-label {
  width: 180px;
  flex-shrink: 0;
  font-size: 13px;
  color: var(--text-secondary);
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  flex: 1;
  height: 28px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-xs);
  overflow: hidden;
  position: relative;
}

.bar-fill {
  height: 100%;
  border-radius: var(--radius-xs);
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 600;
  color: white;
  min-width: fit-content;
}

.bar-fill.accent {
  background: var(--gradient-accent);
}

.bar-fill.positive {
  background: linear-gradient(90deg, #059669, #10b981);
}

.bar-fill.negative {
  background: linear-gradient(90deg, #dc2626, #ef4444);
}

.bar-fill.neutral {
  background: linear-gradient(90deg, #4b5563, #6b7280);
}

/* ── Donut Chart (CSS) ──────────────────────────────────────────────────────── */
.donut-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 32px;
  padding: 20px;
}

.donut-legend {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Loading Skeleton ───────────────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, rgba(255, 255, 255, 0.06) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: skeleton 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes skeleton {
  0% {
    background-position: 200% 0;
  }

  100% {
    background-position: -200% 0;
  }
}

.skeleton-kpi {
  height: 100px;
}

.skeleton-chart {
  height: 300px;
}

.skeleton-text {
  height: 20px;
  width: 80%;
  margin-bottom: 8px;
}

/* ── Scrollbar ──────────────────────────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ── Fade-in animation ──────────────────────────────────────────────────────── */
.fade-in {
  animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Multiselect (custom) ───────────────────────────────────────────────────── */
.multi-select-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: rgba(99, 102, 241, 0.15);
  color: var(--accent-hover);
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
}

.tag-remove {
  cursor: pointer;
  opacity: 0.6;
  font-size: 14px;
}

.tag-remove:hover {
  opacity: 1;
}

/* ── Evidence panel ─────────────────────────────────────────────────────────── */
.evidence-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  max-height: 300px;
  overflow-y: auto;
}

.evidence-item {
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.evidence-item:last-child {
  border-bottom: none;
}

/* ── Sidebar Toggle Button ─────────────────────────────────────────────────── */
.sidebar-toggle {
  position: fixed;
  left: 254px;
  top: 16px;
  z-index: 150;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: var(--blur);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.sidebar-toggle:hover {
  color: var(--text-primary);
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.15);
  box-shadow: 0 4px 16px var(--accent-glow);
}

.sidebar-toggle.collapsed {
  left: 12px;
}

/* ── Sidebar Collapse ──────────────────────────────────────────────────────── */
.sidebar {
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.25s ease;
}

.sidebar.sidebar-collapsed {
  transform: translateX(-100%);
  opacity: 0;
  pointer-events: none;
}

.main-content {
  transition: margin-left 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.main-content.sidebar-is-collapsed {
  margin-left: 0 !important;
}

/* ── Sidebar Filters Container ─────────────────────────────────────────────── */
.sidebar-filters {
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
  overflow-y: auto;
  padding-right: 4px;
}

/* ── Checkbox Group ────────────────────────────────────────────────────────── */
.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: var(--transition);
  font-size: 12px;
  color: var(--text-secondary);
  user-select: none;
}

.checkbox-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
}

.checkbox-item.checked {
  background: rgba(99, 102, 241, 0.1);
  color: var(--text-primary);
}

.checkbox-box {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: var(--transition);
}

.checkbox-item.checked .checkbox-box {
  background: var(--gradient-accent);
  border-color: var(--accent);
  box-shadow: 0 2px 6px var(--accent-glow);
}

.checkbox-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.3;
}

.checkbox-toggle {
  background: none;
  border: none;
  color: var(--accent-hover);
  font-size: 11px;
  cursor: pointer;
  padding: 4px 10px;
  text-align: left;
  font-family: inherit;
  transition: var(--transition);
}

.checkbox-toggle:hover {
  color: var(--text-primary);
}

/* ── Sentiment Dot ─────────────────────────────────────────────────────────── */
.sentiment-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-left: auto;
}