/* TalePal Dashboard v2 - Modern Elegant Style
 * Aligned with homepage, feedback board, and inline dashboard aesthetics
 * Theme-ready with CSS variables for future theme support (ember, spirit, dark, light)
 */

/* ============================================
   CSS Variables - Theme Ready
   ============================================ */
:root {
  /* Primary Colors - Purple theme (default) */
  --primary: #8B5CF6;
  --primary-hover: #7C3AED;
  --primary-light: #A78BFA;
  --primary-dark: #6D28D9;

  /* Gradient - Homepage style */
  --gradient-primary: linear-gradient(135deg, #8B5CF6 0%, #D946EF 100%);
  --gradient-header: linear-gradient(135deg, #7C3AED 0%, #8B5CF6 50%, #A78BFA 100%);

  /* Backgrounds - Dark mode default (matches screenshots) */
  --bg-body: #0F172A;
  --bg-card: #1E293B;
  --bg-card-hover: #273548;
  --bg-elevated: #334155;
  --bg-input: #1E293B;

  /* Text */
  --text-primary: #F1F5F9;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;
  --text-on-primary: #FFFFFF;

  /* Borders & Shadows */
  --border-subtle: rgba(71, 85, 105, 0.5);
  --border-card: rgba(71, 85, 105, 0.3);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
  --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);

  /* Accent Colors */
  --accent-green: #10B981;
  --accent-blue: #3B82F6;
  --accent-yellow: #F59E0B;
  --accent-red: #EF4444;
  --accent-pink: #EC4899;

  /* Badge Colors */
  --badge-protagonist: #10B981;
  --badge-main: #8B5CF6;
  --badge-supporting: #6366F1;
  --badge-mentioned: #64748B;

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;

  /* Border Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-full: 9999px;

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'SF Mono', Monaco, 'Cascadia Code', monospace;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 200ms ease;
  --transition-slow: 300ms ease;
}

/* Light Mode Override - Amber/Warm Theme */
[data-theme="light"] {
  /* Warm cream/paper backgrounds */
  --bg-body: #F9F4ED;
  --bg-card: #FFFCF7;
  --bg-card-hover: #F5EEE5;
  --bg-elevated: #EFE8DD;
  --bg-input: #FFFCF7;

  /* Warm text colors */
  --text-primary: #3D3229;
  --text-secondary: #5C5347;
  --text-muted: #7A7168;

  /* Warmer, more visible borders */
  --border-subtle: rgba(160, 140, 110, 0.6);
  --border-card: rgba(180, 155, 120, 0.5);

  /* Warm shadows */
  --shadow-card: 0 1px 3px rgba(120, 100, 80, 0.12), 0 1px 2px rgba(120, 100, 80, 0.08);

  /* Warmer accent overrides for badges */
  --accent-green: #2D9B6A;
  --accent-blue: #4A7FC7;
  --accent-red: #D64545;
  --accent-pink: #C74B8A;
}

/* ============================================
   Base Styles
   ============================================ */
*, *::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);
  background: var(--bg-body);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

/* ============================================
   Layout
   ============================================ */
.dashboard-container {
  max-width: 1280px;
  margin: 0 auto;
  padding: var(--space-lg) var(--space-xl);
}

/* ============================================
   Header - Clean, Minimal (Homepage style)
   ============================================ */
.header-v2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-lg) 0;
  margin-bottom: var(--space-xl);
  border-bottom: 1px solid var(--border-subtle);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.header-logo {
  width: 48px;
  height: 48px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.header-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.header-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
}

.header-subtitle {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.header-nav {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.nav-link {
  padding: var(--space-sm) var(--space-md);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.nav-link:hover {
  color: var(--text-primary);
  background: var(--bg-elevated);
}

.nav-link.active {
  color: var(--primary);
  background: rgba(139, 92, 246, 0.1);
}

/* ============================================
   Book Title Section (Clean, Gradient Text)
   ============================================ */
.book-title-section {
  margin-bottom: var(--space-xl);
  padding: var(--space-lg) 0;
}

.book-title-gradient {
  font-size: 2.5rem;
  font-weight: 700;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: var(--space-md);
}

.book-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-md);
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.book-meta-item {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.book-meta-badge {
  background: var(--gradient-primary);
  color: var(--text-on-primary);
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 500;
}

.progress-bar {
  width: 120px;
  height: 6px;
  background: var(--bg-elevated);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--gradient-primary);
  border-radius: var(--radius-full);
  transition: width var(--transition-slow);
}

/* Legacy hero classes (for backwards compatibility) */
.hero-section {
  margin-bottom: var(--space-xl);
  padding: var(--space-lg) 0;
}

.hero-title {
  font-size: 2.5rem;
  font-weight: 700;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: var(--space-md);
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-md);
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.hero-stat {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.hero-badge {
  background: var(--gradient-primary);
  color: var(--text-on-primary);
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 500;
}

/* SVG Icon Styling */
.hero-stat-icon {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}

.layer-heading {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.layer-heading-icon {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}

.detail-icon,
.event-icon {
  display: inline-block;
  vertical-align: middle;
  margin-right: 2px;
  flex-shrink: 0;
}

.meta-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(139, 92, 246, 0.1);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* ============================================
   Cards - Modern, Subtle Shadows
   ============================================ */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border-card);
  transition: all var(--transition-normal);
}

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

.card-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

.card-icon {
  font-size: 1.25rem;
}

/* Section Badge Icons - Consistent badge style */
.section-badge {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.section-badge.purple {
  background: rgba(139, 92, 246, 0.15);
  color: var(--primary-light);
}

.section-badge.orange {
  background: rgba(251, 146, 60, 0.15);
  color: #fb923c;
}

.section-badge.amber {
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
}

.section-badge.teal {
  background: rgba(45, 212, 191, 0.15);
  color: #2dd4bf;
}

.section-badge.indigo {
  background: rgba(129, 140, 248, 0.15);
  color: #818cf8;
}

.section-badge.green {
  background: rgba(74, 222, 128, 0.15);
  color: #4ade80;
}

.section-badge.pink {
  background: rgba(244, 114, 182, 0.15);
  color: #f472b6;
}

.section-badge.slate {
  background: rgba(148, 163, 184, 0.15);
  color: #94a3b8;
}

.section-badge.blue {
  background: rgba(96, 165, 250, 0.15);
  color: #60a5fa;
}

.card-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
}

.card-content {
  color: var(--text-secondary);
  line-height: 1.7;
}

/* ============================================
   Navigation Cards (Grid)
   ============================================ */
.nav-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-lg);
  margin: var(--space-xl) 0;
}

.nav-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  text-align: center;
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--border-card);
  transition: all var(--transition-normal);
  cursor: pointer;
}

.nav-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.nav-card-icon {
  width: 60px;
  height: 60px;
  margin: 0 auto var(--space-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.15), rgba(59, 130, 246, 0.1));
  border: 1px solid rgba(139, 92, 246, 0.2);
  border-radius: var(--radius-lg);
  color: #A78BFA;
  transition: all var(--transition-normal);
}

.nav-card:hover .nav-card-icon {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.25), rgba(59, 130, 246, 0.15));
  border-color: rgba(139, 92, 246, 0.4);
  transform: scale(1.05);
}

/* Different colors for each card */
.nav-card:nth-child(1) .nav-card-icon {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.15), rgba(124, 58, 237, 0.1));
  color: #A78BFA;
}
.nav-card:nth-child(2) .nav-card-icon {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(37, 99, 235, 0.1));
  color: #60A5FA;
}
.nav-card:nth-child(3) .nav-card-icon {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(5, 150, 105, 0.1));
  color: #34D399;
}
.nav-card:nth-child(4) .nav-card-icon {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.15), rgba(217, 119, 6, 0.1));
  color: #FBBF24;
}

.nav-card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-xs);
}

.nav-card-desc {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* ============================================
   Theme Tags
   ============================================ */
.themes-container {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.theme-tag {
  background: var(--gradient-primary);
  color: var(--text-on-primary);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-full);
  font-size: 0.875rem;
  font-weight: 500;
}

/* ============================================
   Character Cards - Elegant Design
   ============================================ */
.characters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--space-lg);
}

.character-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  border: 1px solid var(--border-card);
  transition: all var(--transition-normal);
  position: relative;
  overflow: hidden;
}

.character-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}

.character-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--gradient-primary);
  opacity: 0;
  transition: opacity var(--transition-normal);
}

.character-card:hover::before {
  opacity: 1;
}

.character-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--space-md);
}

.character-name {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
}

.character-badges {
  display: flex;
  gap: var(--space-xs);
  flex-wrap: wrap;
}

.badge {
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-protagonist {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-green);
}

.badge-main {
  background: rgba(139, 92, 246, 0.15);
  color: var(--primary);
}

.badge-supporting {
  background: rgba(99, 102, 241, 0.15);
  color: #818CF8;
}

.badge-mentioned {
  background: rgba(100, 116, 139, 0.15);
  color: var(--text-muted);
}

.character-description {
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-style: italic;
  margin-bottom: var(--space-lg);
  line-height: 1.6;
}

.character-stats {
  display: flex;
  gap: var(--space-lg);
  padding: var(--space-md);
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-lg);
}

.stat-item {
  text-align: center;
  flex: 1;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.character-variants {
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin-bottom: var(--space-lg);
}

.variants-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
}

.variant-item {
  color: var(--text-secondary);
  font-size: 0.875rem;
  padding: var(--space-xs) 0;
  border-bottom: 1px solid var(--border-subtle);
}

.variant-item:last-child {
  border-bottom: none;
}

.variants-note {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: var(--space-sm);
}

/* ============================================
   Buttons - Gradient Style
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: all var(--transition-fast);
}

.btn-primary {
  background: var(--gradient-primary);
  color: var(--text-on-primary);
  box-shadow: 0 4px 14px rgba(139, 92, 246, 0.4);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(139, 92, 246, 0.5);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--primary);
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
}

.btn-outline:hover {
  background: rgba(139, 92, 246, 0.1);
}

/* ============================================
   Section Headers
   ============================================ */
.section {
  margin-bottom: var(--space-2xl);
}

.section-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

.section-icon {
  font-size: 1.5rem;
}

.section-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
}

.section-count {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-full);
  font-size: 0.875rem;
  font-weight: 500;
}

.section-description {
  color: var(--text-secondary);
  font-style: italic;
  margin-bottom: var(--space-lg);
}

/* ============================================
   Chart Section
   ============================================ */
.chart-container {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  padding-bottom: var(--space-3xl, 3rem);
  border: 1px solid var(--border-card);
  min-height: 320px;
}

.chart-container canvas {
  max-height: 250px !important;
}

.chart-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  text-align: center;
  margin-bottom: var(--space-lg);
}

/* ============================================
   Footer
   ============================================ */
.footer {
  text-align: center;
  padding: var(--space-xl) 0;
  margin-top: var(--space-2xl);
  border-top: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* ============================================
   Theme Toggle Button
   ============================================ */
.theme-toggle {
  position: fixed;
  bottom: var(--space-xl);
  right: var(--space-xl);
  z-index: 1000;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-size: 1.25rem;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  transition: all var(--transition-normal);
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-toggle:hover {
  background: var(--primary);
  color: var(--text-on-primary);
  border-color: var(--primary);
  transform: scale(1.05);
}

/* ============================================
   Utility Classes
   ============================================ */
.text-center { text-align: center; }
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }

.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }

.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }

/* ============================================
   Responsive Design
   ============================================ */
@media (max-width: 768px) {
  .dashboard-container {
    padding: var(--space-md);
  }

  .header-v2 {
    flex-direction: column;
    gap: var(--space-md);
    text-align: center;
  }

  .hero-section {
    padding: var(--space-xl);
  }

  .hero-title {
    font-size: 1.5rem;
  }

  .hero-meta {
    flex-direction: column;
    align-items: flex-start;
  }

  .characters-grid {
    grid-template-columns: 1fr;
  }

  .nav-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .theme-toggle {
    bottom: var(--space-md);
    right: var(--space-md);
    width: 40px;
    height: 40px;
  }
}
