/* ============================
   Design Tokens
   ============================ */
:root {
  /* Colors - Primary */
  --purple-50: #faf5ff;
  --purple-100: #f3e8ff;
  --purple-200: #e9d5ff;
  --purple-300: #d8b4fe;
  --purple-400: #c084fc;
  --purple-500: #a855f7;
  --purple-600: #9333ea;
  --purple-700: #7e22ce;
  
  /* Colors - Blue */
  --blue-50: #eff6ff;
  --blue-100: #dbeafe;
  --blue-500: #3b82f6;
  --blue-600: #2563eb;
  
  /* Colors - Green */
  --green-50: #f0fdf4;
  --green-100: #dcfce7;
  --green-500: #22c55e;
  --green-600: #16a34a;
  
  /* Colors - Orange */
  --orange-50: #fff7ed;
  --orange-100: #ffedd5;
  --orange-500: #f97316;
  --orange-600: #ea580c;
  
  /* Colors - Red */
  --red-50: #fef2f2;
  --red-100: #fee2e2;
  --red-500: #ef4444;
  --red-600: #dc2626;
  
  /* Colors - Neutral */
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  
  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.5rem;
  --font-size-3xl: 1.875rem;
  
  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  
  /* Border Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-full: 9999px;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  
  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 300ms ease;
}

/* ============================
   Reset & Base
   ============================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  font-size: var(--font-size-base);
  line-height: 1.5;
  color: var(--gray-900);
  background: var(--gray-50);
}

/* ============================
   App Layout
   ============================ */
.app {
  display: flex;
  min-height: 100vh;
}

/* ============================
   Sidebar
   ============================ */
.sidebar {
  width: 260px;
  background: white;
  border-right: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
}

.sidebar-header {
  padding: var(--space-6);
  border-bottom: 1px solid var(--gray-100);
}

.logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.logo-icon {
  width: 32px;
  height: 32px;
  color: var(--purple-600);
}

.logo-text {
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--gray-900);
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  color: var(--gray-600);
  text-decoration: none;
  font-size: var(--font-size-sm);
  font-weight: 500;
  transition: all var(--transition-fast);
}

.nav-item:hover {
  background: var(--gray-100);
  color: var(--gray-900);
}

.nav-item.active {
  background: var(--purple-50);
  color: var(--purple-700);
}

.nav-item svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.nav-badge {
  margin-left: auto;
  font-size: var(--font-size-xs);
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: var(--gray-200);
  color: var(--gray-600);
}

.nav-badge.accent {
  background: var(--purple-100);
  color: var(--purple-700);
}

.sidebar-footer {
  padding: var(--space-4);
  border-top: 1px solid var(--gray-100);
}

.usage-meter {
  padding: var(--space-4);
  background: var(--gray-50);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-3);
}

.usage-header {
  display: flex;
  justify-content: space-between;
  font-size: var(--font-size-xs);
  color: var(--gray-600);
  margin-bottom: var(--space-2);
}

.usage-count {
  font-weight: 600;
  color: var(--gray-900);
}

.usage-bar {
  height: 6px;
  background: var(--gray-200);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.usage-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--purple-500), var(--purple-600));
  border-radius: var(--radius-full);
  transition: width var(--transition-slow);
}

/* ============================
   Main Content
   ============================ */
.main {
  flex: 1;
  margin-left: 260px;
  padding: var(--space-8);
  max-width: 1400px;
}

/* ============================
   Header
   ============================ */
.header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--space-8);
}

.page-title {
  font-size: var(--font-size-3xl);
  font-weight: 700;
  color: var(--gray-900);
}

.page-subtitle {
  font-size: var(--font-size-sm);
  color: var(--gray-500);
  margin-top: var(--space-1);
}

.header-right {
  display: flex;
  gap: var(--space-3);
}

/* ============================
   Buttons
   ============================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  font-size: var(--font-size-sm);
  font-weight: 500;
  border-radius: var(--radius-lg);
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn svg {
  width: 18px;
  height: 18px;
}

.btn-primary {
  background: var(--purple-600);
  color: white;
}

.btn-primary:hover {
  background: var(--purple-700);
}

.btn-secondary {
  background: white;
  color: var(--gray-700);
  border: 1px solid var(--gray-300);
}

.btn-secondary:hover {
  background: var(--gray-50);
  border-color: var(--gray-400);
}

.btn-ghost {
  background: transparent;
  color: var(--gray-600);
}

.btn-ghost:hover {
  background: var(--gray-100);
  color: var(--gray-900);
}

.btn-sm {
  padding: var(--space-2) var(--space-3);
  font-size: var(--font-size-xs);
}

/* ============================
   Stats Grid
   ============================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-6);
  margin-bottom: var(--space-8);
}

.stat-card {
  background: white;
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: var(--space-4);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-100);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-icon svg {
  width: 24px;
  height: 24px;
}

.stat-icon.purple {
  background: var(--purple-100);
  color: var(--purple-600);
}

.stat-icon.blue {
  background: var(--blue-100);
  color: var(--blue-600);
}

.stat-icon.orange {
  background: var(--orange-100);
  color: var(--orange-600);
}

.stat-icon.green {
  background: var(--green-100);
  color: var(--green-600);
}

.stat-content {
  display: flex;
  flex-direction: column;
}

.stat-value {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1.2;
}

.stat-label {
  font-size: var(--font-size-sm);
  color: var(--gray-500);
}

.stat-trend {
  width: 100%;
  font-size: var(--font-size-xs);
  font-weight: 500;
  margin-top: var(--space-1);
}

.stat-trend.up {
  color: var(--green-600);
}

.stat-trend.down {
  color: var(--red-600);
}

.stat-trend.neutral {
  color: var(--gray-500);
}

/* ============================
   Content Grid
   ============================ */
.content-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-6);
}

/* ============================
   Cards
   ============================ */
.card {
  background: white;
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-100);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-5);
}

.card-title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--gray-900);
}

.card-badge {
  font-size: var(--font-size-xs);
  font-weight: 500;
  padding: var(--space-1) var(--space-3);
  background: var(--gray-100);
  color: var(--gray-600);
  border-radius: var(--radius-full);
}

.card-link {
  display: block;
  text-align: center;
  padding-top: var(--space-4);
  margin-top: var(--space-4);
  border-top: 1px solid var(--gray-100);
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--purple-600);
  text-decoration: none;
}

.card-link:hover {
  color: var(--purple-700);
}

/* ============================
   Insights List
   ============================ */
.insights-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.insight-item {
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  border-left: 3px solid;
}

.insight-item.pain {
  background: var(--red-50);
  border-color: var(--red-500);
}

.insight-item.request {
  background: var(--blue-50);
  border-color: var(--blue-500);
}

.insight-item.praise {
  background: var(--green-50);
  border-color: var(--green-500);
}

.insight-item.objection {
  background: var(--orange-50);
  border-color: var(--orange-500);
}

.insight-type {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-2);
}

.type-badge {
  font-size: var(--font-size-xs);
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
}

.type-badge.pain {
  background: var(--red-100);
  color: var(--red-600);
}

.type-badge.request {
  background: var(--blue-100);
  color: var(--blue-600);
}

.type-badge.praise {
  background: var(--green-100);
  color: var(--green-600);
}

.type-badge.objection {
  background: var(--orange-100);
  color: var(--orange-600);
}

.insight-frequency {
  font-size: var(--font-size-xs);
  color: var(--gray-500);
}

.insight-text {
  font-size: var(--font-size-sm);
  color: var(--gray-800);
  font-style: italic;
  margin-bottom: var(--space-2);
}

.insight-meta {
  display: flex;
  gap: var(--space-4);
  font-size: var(--font-size-xs);
  color: var(--gray-500);
}

.insight-confidence {
  font-weight: 500;
}

/* ============================
   Interviews List
   ============================ */
.interviews-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.interview-item {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  background: var(--gray-50);
  transition: background var(--transition-fast);
}

.interview-item:hover {
  background: var(--gray-100);
}

.interview-item.processing {
  opacity: 0.8;
}

.interview-avatar {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  background: var(--purple-100);
  color: var(--purple-700);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-sm);
  font-weight: 600;
  flex-shrink: 0;
}

.interview-avatar.blue {
  background: var(--blue-100);
  color: var(--blue-700);
}

.interview-avatar.green {
  background: var(--green-100);
  color: var(--green-700);
}

.interview-avatar.orange {
  background: var(--orange-100);
  color: var(--orange-700);
}

.interview-content {
  flex: 1;
  min-width: 0;
}

.interview-name {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--gray-900);
}

.interview-role {
  font-size: var(--font-size-xs);
  color: var(--gray-500);
  margin-bottom: var(--space-2);
}

.interview-tags {
  display: flex;
  gap: var(--space-2);
}

.tag {
  font-size: var(--font-size-xs);
  padding: 2px 8px;
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  color: var(--gray-600);
}

.interview-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  font-size: var(--font-size-xs);
  color: var(--gray-500);
}

.interview-insights {
  font-weight: 600;
  color: var(--purple-600);
}

.processing-indicator {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-xs);
  color: var(--gray-500);
}

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--gray-200);
  border-top-color: var(--purple-500);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* ============================
   Themes Chart
   ============================ */
.themes-chart {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.theme-bar {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.theme-label {
  display: flex;
  justify-content: space-between;
  font-size: var(--font-size-sm);
}

.theme-name {
  font-weight: 500;
  color: var(--gray-800);
}

.theme-count {
  color: var(--gray-500);
  font-size: var(--font-size-xs);
}

.theme-progress {
  height: 8px;
  background: var(--gray-100);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.theme-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width var(--transition-slow);
}

/* ============================
   Actions Grid
   ============================ */
.actions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

.action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-5);
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.action-btn:hover {
  background: var(--purple-50);
  border-color: var(--purple-200);
}

.action-btn svg {
  width: 24px;
  height: 24px;
  color: var(--gray-500);
}

.action-btn:hover svg {
  color: var(--purple-600);
}

.action-btn span {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--gray-700);
}

.action-btn:hover span {
  color: var(--purple-700);
}

/* ============================
   Modal
   ============================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-base);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: white;
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow: auto;
  transform: scale(0.95);
  transition: transform var(--transition-base);
}

.modal-overlay.active .modal {
  transform: scale(1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-6);
  border-bottom: 1px solid var(--gray-100);
}

.modal-title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--gray-900);
}

.modal-close {
  background: none;
  border: none;
  padding: var(--space-2);
  cursor: pointer;
  color: var(--gray-400);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.modal-close:hover {
  background: var(--gray-100);
  color: var(--gray-600);
}

.modal-close svg {
  width: 20px;
  height: 20px;
}

.modal-body {
  padding: var(--space-6);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-6);
  border-top: 1px solid var(--gray-100);
}

/* ============================
   Upload Zone
   ============================ */
.upload-zone {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius-lg);
  padding: var(--space-10);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.upload-zone:hover {
  border-color: var(--purple-400);
  background: var(--purple-50);
}

.upload-icon {
  width: 48px;
  height: 48px;
  background: var(--gray-100);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--space-4);
}

.upload-zone:hover .upload-icon {
  background: var(--purple-100);
}

.upload-icon svg {
  width: 24px;
  height: 24px;
  color: var(--gray-500);
}

.upload-zone:hover .upload-icon svg {
  color: var(--purple-600);
}

.upload-text {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: var(--space-1);
}

.upload-subtext {
  font-size: var(--font-size-sm);
  color: var(--gray-500);
  margin-bottom: var(--space-3);
}

.upload-formats {
  font-size: var(--font-size-xs);
  color: var(--gray-400);
}

.upload-divider {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin: var(--space-6) 0;
  color: var(--gray-400);
  font-size: var(--font-size-sm);
}

.upload-divider::before,
.upload-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--gray-200);
}

/* ============================
   Form Elements
   ============================ */
.form-group {
  margin-bottom: var(--space-5);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

.form-label {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: var(--space-2);
}

.form-input {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font-size: var(--font-size-sm);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-lg);
  transition: all var(--transition-fast);
}

.form-input:focus {
  outline: none;
  border-color: var(--purple-500);
  box-shadow: 0 0 0 3px var(--purple-100);
}

.form-input::placeholder {
  color: var(--gray-400);
}

.form-hint {
  font-size: var(--font-size-xs);
  color: var(--gray-500);
  margin-top: var(--space-2);
}

/* ============================
   Responsive
   ============================ */
@media (max-width: 1200px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .content-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .sidebar {
    display: none;
  }
  
  .main {
    margin-left: 0;
    padding: var(--space-4);
  }
  
  .header {
    flex-direction: column;
    gap: var(--space-4);
  }
  
  .stats-grid {
    grid-template-columns: 1fr;
  }
  
  .form-row {
    grid-template-columns: 1fr;
  }
}

/* ============================
   Accessibility
   ============================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

.btn:focus-visible,
.nav-item:focus-visible,
.action-btn:focus-visible,
.form-input:focus-visible {
  outline: 2px solid var(--purple-500);
  outline-offset: 2px;
}
