/* ==========================================================================
   Design System & Master Theme: Vibrant Azure Blue
   ความทรงจำนวนิยายและมังงะของมนุษย์ผู้ชื่นชอบการอ่าน BL
   ========================================================================== */

:root {
  /* Color Palette */
  --bg-dark: #090d16;
  --bg-card: rgba(15, 23, 42, 0.75);
  --bg-card-hover: rgba(30, 41, 59, 0.85);
  --bg-glass: rgba(14, 165, 233, 0.05);
  --border-glass: rgba(56, 189, 248, 0.2);
  --border-glow: rgba(14, 165, 233, 0.5);

  /* Primary Blue Accents */
  --primary-azure: #0ea5e9;
  --primary-cyan: #06b6d4;
  --primary-blue: #2563eb;
  --primary-dark: #0284c7;
  --primary-glow: rgba(14, 165, 233, 0.4);

  /* UI Text Colors */
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-sub: #cbd5e1;
  --text-highlight: #38bdf8;

  /* Status & Accents */
  --star-gold: #fbbf24;
  --danger-red: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.15);
  --success-green: #10b981;
  --purple-accent: #a855f7;

  /* Category Colors */
  --cat-novel: #0284c7;
  --cat-manga: #06b6d4;
  --cat-cartoon: #3b82f6;

  /* Typography */
  --font-heading: 'Prompt', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'Sarabun', -apple-system, BlinkMacSystemFont, sans-serif;

  /* Border Radius & Shadows */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  
  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-glow: 0 0 20px rgba(14, 165, 233, 0.35);
}

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

body {
  font-family: var(--font-body);
  background-color: var(--bg-dark);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  background-image: 
    radial-gradient(circle at 15% 15%, rgba(14, 165, 233, 0.12) 0%, transparent 40%),
    radial-gradient(circle at 85% 65%, rgba(37, 99, 235, 0.1) 0%, transparent 45%);
  background-attachment: fixed;
}

/* Ambient Animated Orbs */
.ambient-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  z-index: -1;
  pointer-events: none;
  opacity: 0.4;
  animation: floatOrb 18s ease-in-out infinite alternate;
}
.orb-1 {
  width: 400px;
  height: 400px;
  background: var(--primary-azure);
  top: -100px;
  left: -100px;
}
.orb-2 {
  width: 500px;
  height: 500px;
  background: var(--primary-blue);
  bottom: -150px;
  right: -150px;
  animation-delay: -6s;
}
.orb-3 {
  width: 300px;
  height: 300px;
  background: var(--primary-cyan);
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation-delay: -12s;
}

@keyframes floatOrb {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(40px, -30px) scale(1.1); }
  100% { transform: translate(-30px, 50px) scale(0.95); }
}

/* Utility Classes */
.hidden { display: none !important; }
.mt-3 { margin-top: 1rem; }
.mt-5 { margin-top: 2rem; }
.text-center { text-align: center; }
.text-highlight { color: var(--text-highlight); }

/* ==========================================================================
   Header & Brand Title
   ========================================================================== */
.app-header {
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-glass);
  padding: 1.25rem 2rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.header-container {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

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

.logo-badge {
  width: 52px;
  height: 52px;
  background: linear-gradient(135deg, var(--primary-azure), var(--primary-blue));
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.5rem;
  color: #fff;
  box-shadow: var(--shadow-glow);
  letter-spacing: 1px;
}

.app-title {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 700;
  background: linear-gradient(90deg, #ffffff, var(--primary-azure));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.3;
}

.app-subtitle {
  font-size: 0.88rem;
  color: var(--text-muted);
}

/* Buttons */
.btn {
  font-family: var(--font-heading);
  font-weight: 500;
  font-size: 0.95rem;
  padding: 0.65rem 1.35rem;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.25s ease;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-azure), var(--primary-dark));
  color: #fff;
  box-shadow: 0 4px 14px rgba(14, 165, 233, 0.35);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(14, 165, 233, 0.5);
  background: linear-gradient(135deg, #38bdf8, var(--primary-azure));
}

.btn-glow {
  position: relative;
  overflow: hidden;
}
.btn-glow::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.3) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.3s ease;
}
.btn-glow:hover::after {
  opacity: 1;
}

.btn-secondary {
  background: rgba(30, 41, 59, 0.8);
  color: var(--text-sub);
  border: 1px solid var(--border-glass);
}
.btn-secondary:hover {
  background: rgba(51, 65, 85, 0.9);
  color: #fff;
  border-color: var(--primary-azure);
}

.btn-outline {
  background: transparent;
  color: var(--text-sub);
  border: 1px solid var(--border-glass);
}
.btn-outline:hover {
  border-color: var(--text-sub);
  color: var(--text-main);
}

.btn-text-danger {
  background: transparent;
  border: none;
  color: #f87171;
  font-size: 0.9rem;
  cursor: pointer;
  transition: color 0.2s ease;
}
.btn-text-danger:hover {
  color: var(--danger-red);
  text-decoration: underline;
}

.btn-text-link {
  background: transparent;
  border: none;
  color: var(--primary-azure);
  cursor: pointer;
  font-size: 0.9rem;
}
.btn-text-link:hover {
  text-decoration: underline;
}

/* ==========================================================================
   Navigation Bar & Quick Stats
   ========================================================================== */
.nav-bar {
  background: rgba(11, 17, 32, 0.9);
  border-bottom: 1px solid var(--border-glass);
  padding: 0.75rem 2rem;
}

.nav-container {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

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

.tab-btn {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 500;
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.25s ease;
}

.tab-btn:hover {
  color: var(--text-main);
  background: rgba(30, 41, 59, 0.5);
}

.tab-btn.active {
  background: rgba(14, 165, 233, 0.15);
  border-color: var(--border-glow);
  color: var(--primary-azure);
  font-weight: 600;
}

.count-badge {
  background: var(--primary-azure);
  color: #000;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.header-stats-summary {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.quick-stat {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

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

.quick-stat .stat-value {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-highlight);
}

/* ==========================================================================
   Main Container & Section Views
   ========================================================================== */
.main-container {
  max-width: 1400px;
  margin: 2rem auto;
  padding: 0 1.5rem;
}

.view-section {
  display: none;
  animation: fadeIn 0.3s ease;
}
.view-section.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   Controls Card: Search, Filter, Sort & View Switch
   ========================================================================== */
.controls-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-md);
}

.controls-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr auto auto;
  gap: 1rem;
  align-items: flex-end;
}

@media (max-width: 1024px) {
  .controls-row {
    grid-template-columns: 1fr 1fr;
  }
  .search-group {
    grid-column: span 2;
  }
}
@media (max-width: 640px) {
  .controls-row {
    grid-template-columns: 1fr;
  }
  .search-group {
    grid-column: span 1;
  }
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.control-label {
  font-family: var(--font-heading);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-sub);
}

/* Inputs & Selects */
.form-input, .form-select {
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: 0.6rem 0.9rem;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  color: var(--text-main);
  outline: none;
  transition: all 0.25s ease;
  width: 100%;
}

.form-input:focus, .form-select:focus {
  border-color: var(--primary-azure);
  box-shadow: 0 0 12px var(--primary-glow);
  background: rgba(30, 41, 59, 0.9);
}

.input-icon-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}
.input-icon-wrapper .input-icon {
  position: absolute;
  left: 0.75rem;
  pointer-events: none;
  font-size: 0.9rem;
}
.input-icon-wrapper .form-input {
  padding-left: 2.2rem;
}

/* Checkbox Toggle Switch */
.toggle-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  user-select: none;
}
.toggle-switch input {
  display: none;
}
.toggle-slider {
  width: 44px;
  height: 24px;
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  position: relative;
  transition: all 0.3s ease;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #cbd5e1;
  top: 2px;
  left: 2px;
  transition: all 0.3s ease;
}
.toggle-switch input:checked + .toggle-slider {
  background: var(--primary-azure);
  border-color: var(--primary-azure);
}
.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
  background: #fff;
}
.toggle-label {
  font-family: var(--font-heading);
  font-size: 0.9rem;
  color: var(--text-main);
}

/* View Mode Buttons */
.btn-group-toggle {
  display: flex;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 2px;
}
.btn-toggle {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.55rem 0.9rem;
  font-family: var(--font-heading);
  font-size: 0.88rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}
.btn-toggle.active {
  background: var(--primary-azure);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 8px var(--primary-glow);
}

/* Dynamic Tag Filter Chips Bar */
.tag-filter-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px dashed rgba(56, 189, 248, 0.15);
  flex-wrap: wrap;
}
.tag-filter-title {
  font-family: var(--font-heading);
  font-size: 0.82rem;
  color: var(--text-muted);
}
.tag-chips-wrapper {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.tag-chip {
  font-size: 0.8rem;
  padding: 0.25rem 0.7rem;
  border-radius: var(--radius-full);
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid var(--border-glass);
  color: var(--text-sub);
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}
.tag-chip:hover {
  border-color: var(--primary-azure);
  color: var(--text-main);
}
.tag-chip.active {
  background: rgba(14, 165, 233, 0.25);
  border-color: var(--primary-azure);
  color: var(--primary-azure);
  font-weight: 600;
}

/* Results Info Bar */
.results-info-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  padding: 0 0.25rem;
}
.results-count {
  font-family: var(--font-heading);
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* ==========================================================================
   BOOK LIST: CARD VIEW
   ========================================================================== */
.books-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
}

.book-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}

.book-card:hover {
  transform: translateY(-6px);
  border-color: var(--border-glow);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5), var(--shadow-glow);
  background: var(--bg-card-hover);
}

/* Cover Image Container */
.book-cover-container {
  height: 320px;
  position: relative;
  overflow: hidden;
  background: #020617;
  cursor: pointer;
}

.book-cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.book-card:hover .book-cover-img {
  transform: scale(1.06);
}

/* Category Badge overlay */
.book-badge-category {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-family: var(--font-heading);
  font-size: 0.75rem;
  font-weight: 600;
  color: #fff;
  backdrop-filter: blur(8px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}
.badge-novel { background: rgba(2, 132, 199, 0.9); }
.badge-manga { background: rgba(6, 182, 212, 0.9); }
.badge-cartoon { background: rgba(59, 130, 246, 0.9); }

/* Favorite Toggle Icon on Cover */
.book-fav-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-glass);
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}
.book-fav-btn:hover, .book-fav-btn.active {
  color: var(--star-gold);
  background: rgba(15, 23, 42, 0.95);
  border-color: var(--star-gold);
  transform: scale(1.1);
}

/* Volume Badge overlay */
.book-badge-volume {
  position: absolute;
  bottom: 12px;
  right: 12px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-glass);
  padding: 4px 10px;
  border-radius: var(--radius-md);
  font-family: var(--font-heading);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--primary-azure);
}

/* Card Content Body */
.book-card-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  gap: 0.75rem;
}

.book-card-title {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.35;
  cursor: pointer;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  transition: color 0.2s ease;
}
.book-card-title:hover {
  color: var(--primary-azure);
}

.book-card-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.book-card-meta .meta-row {
  display: flex;
  justify-content: space-between;
}

/* Rating Stars */
.star-rating {
  color: var(--star-gold);
  font-size: 0.9rem;
  letter-spacing: 2px;
}

/* Character Pairs List */
.book-characters-preview {
  background: rgba(14, 165, 233, 0.06);
  border-left: 3px solid var(--primary-azure);
  padding: 0.5rem 0.75rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.82rem;
}
.character-pair-tag {
  color: var(--text-sub);
  display: block;
}
.character-pair-tag strong {
  color: var(--primary-azure);
}

/* Card Tag Chips */
.book-card-tags {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-top: auto;
}
.mini-tag {
  font-size: 0.75rem;
  padding: 2px 8px;
  background: rgba(30, 41, 59, 0.8);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
}

/* Card Action Footer Buttons */
.book-card-actions {
  display: flex;
  gap: 0.5rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(56, 189, 248, 0.1);
  background: rgba(11, 17, 32, 0.5);
}
.btn-card-action {
  flex: 1;
  font-family: var(--font-heading);
  font-size: 0.82rem;
  padding: 0.45rem 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-glass);
  background: rgba(30, 41, 59, 0.6);
  color: var(--text-sub);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  transition: all 0.2s ease;
}
.btn-card-action:hover {
  background: rgba(51, 65, 85, 0.9);
  color: var(--text-main);
  border-color: var(--primary-azure);
}
.btn-add-vol-quick {
  background: rgba(14, 165, 233, 0.15);
  border-color: var(--primary-azure);
  color: var(--primary-azure);
  font-weight: 600;
}
.btn-add-vol-quick:hover {
  background: var(--primary-azure);
  color: #fff;
}

.btn-card-delete {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.3);
  color: #f87171;
}
.btn-card-delete:hover {
  background: var(--danger-red);
  color: #fff;
  border-color: var(--danger-red);
}

.btn-danger-icon {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #f87171;
  padding: 0.35rem 0.55rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.8rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-danger-icon:hover {
  background: var(--danger-red);
  color: #fff;
  border-color: var(--danger-red);
}


/* ==========================================================================
   BOOK LIST: TABLE VIEW
   ========================================================================== */
.books-table-wrapper {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  overflow-x: auto;
  box-shadow: var(--shadow-md);
}

.books-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.books-table th {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-sub);
  background: rgba(15, 23, 42, 0.95);
  padding: 1rem;
  border-bottom: 1px solid var(--border-glass);
  white-space: nowrap;
}

.books-table td {
  padding: 0.9rem 1rem;
  border-bottom: 1px solid rgba(56, 189, 248, 0.08);
  font-size: 0.9rem;
  color: var(--text-main);
  vertical-align: middle;
}

.books-table tbody tr {
  transition: background 0.2s ease;
}

.books-table tbody tr:hover {
  background: rgba(30, 41, 59, 0.6);
}

.table-thumb {
  width: 48px;
  height: 64px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-glass);
  cursor: pointer;
}

.table-title {
  font-family: var(--font-heading);
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
}
.table-title:hover {
  color: var(--primary-azure);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  background: var(--bg-card);
  border: 1px dashed var(--border-glass);
  border-radius: var(--radius-lg);
  margin-top: 1rem;
}
.empty-icon {
  font-size: 3.5rem;
  margin-bottom: 1rem;
  opacity: 0.8;
}
.empty-state h3 {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  color: var(--text-main);
  margin-bottom: 0.5rem;
}
.empty-state p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* ==========================================================================
   ANALYTICS DASHBOARD STYLES
   ========================================================================== */
.analytics-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: transform 0.25s ease;
}

.stat-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-glow);
}

.stat-card-icon {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  background: rgba(14, 165, 233, 0.15);
  border: 1px solid var(--border-glass);
}

.blue-card .stat-card-icon { background: rgba(14, 165, 233, 0.2); color: var(--primary-azure); }
.cyan-card .stat-card-icon { background: rgba(6, 182, 212, 0.2); color: var(--primary-cyan); }
.indigo-card .stat-card-icon { background: rgba(99, 102, 241, 0.2); color: #818cf8; }
.star-card .stat-card-icon { background: rgba(251, 191, 36, 0.2); color: var(--star-gold); }

.stat-card-info {
  display: flex;
  flex-direction: column;
}

.stat-card-title {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  color: var(--text-muted);
}

.stat-card-value {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-main);
}

/* Section Header */
.section-header {
  margin-bottom: 1.25rem;
}
.section-title {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-main);
}
.section-desc {
  font-size: 0.88rem;
  color: var(--text-muted);
}

/* Charts Grid */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 2.5rem;
}
@media (max-width: 900px) {
  .charts-grid {
    grid-template-columns: 1fr;
  }
}

.chart-box {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-md);
}

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

.chart-box-title {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 1.25rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-glass);
}

.chart-container {
  position: relative;
  height: 320px;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Analytics Detailed Summary Tables */
.analytics-tables-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}
@media (max-width: 900px) {
  .analytics-tables-grid {
    grid-template-columns: 1fr;
  }
}

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

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

.analytics-table-title {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--primary-azure);
  margin-bottom: 1rem;
}

.table-responsive {
  overflow-x: auto;
}

.analytics-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.analytics-table th {
  font-family: var(--font-heading);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-sub);
  background: rgba(15, 23, 42, 0.95);
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border-glass);
}

.analytics-table td {
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid rgba(56, 189, 248, 0.08);
  font-size: 0.85rem;
  color: var(--text-main);
}

.analytics-table tbody tr:hover {
  background: rgba(30, 41, 59, 0.5);
}

/* Footer */
.app-footer {
  margin-top: 4rem;
  background: rgba(11, 17, 32, 0.95);
  border-top: 1px solid var(--border-glass);
  padding: 1.5rem 2rem;
  text-align: center;
}

.footer-container {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ==========================================================================
   MODAL DIALOG STYLES
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(2, 6, 23, 0.85);
  backdrop-filter: blur(12px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  overflow-y: auto;
  animation: modalFade 0.25s ease;
}

@keyframes modalFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-dialog {
  background: #0f172a;
  border: 1px solid var(--border-glow);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7), var(--shadow-glow);
  animation: modalScale 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

@keyframes modalScale {
  from { transform: scale(0.95); }
  to { transform: scale(1); }
}

.modal-small { max-width: 440px; }
.modal-large { max-width: 900px; }

.modal-header {
  padding: 1.25rem 1.5rem;
  background: rgba(15, 23, 42, 0.95);
  border-bottom: 1px solid var(--border-glass);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-main);
}

.btn-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  transition: color 0.2s ease;
}
.btn-close:hover {
  color: var(--danger-red);
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  background: rgba(11, 17, 32, 0.95);
  border-top: 1px solid var(--border-glass);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* Modal Form Fields */
.form-row {
  display: flex;
  gap: 1rem;
}
.form-row.align-center {
  align-items: center;
}
.col-6 { flex: 1; }
.col-7 { flex: 7; }
.col-5 { flex: 5; }

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-label {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-sub);
}
.form-label.required::after {
  content: ' *';
  color: var(--danger-red);
}

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

.field-card {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 1rem;
}

.field-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.25rem;
}

.btn-small {
  font-family: var(--font-heading);
  font-size: 0.78rem;
  padding: 0.35rem 0.7rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.dynamic-inputs-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.6rem;
}

.dynamic-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.btn-remove-row {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #f87171;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
}
.btn-remove-row:hover {
  background: var(--danger-red);
  color: #fff;
}

/* Star Rating Picker */
.star-rating-picker {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 1.5rem;
  color: var(--text-muted);
}
.star-btn {
  cursor: pointer;
  transition: transform 0.15s ease, color 0.15s ease;
  user-select: none;
}
.star-btn:hover, .star-btn.active {
  color: var(--star-gold);
  transform: scale(1.15);
}
.rating-text-label {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  color: var(--star-gold);
  margin-left: 0.5rem;
}

/* Form Tag Chips Select */
.form-tag-chips-wrapper {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  max-height: 120px;
  overflow-y: auto;
  padding: 0.5rem;
  background: rgba(15, 23, 42, 0.8);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-glass);
}

.form-tag-chip {
  font-size: 0.8rem;
  padding: 0.3rem 0.7rem;
  border-radius: var(--radius-full);
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid var(--border-glass);
  color: var(--text-sub);
  cursor: pointer;
  transition: all 0.2s ease;
}
.form-tag-chip.selected {
  background: var(--primary-azure);
  border-color: var(--primary-azure);
  color: #fff;
  font-weight: 500;
}

.custom-tag-row {
  display: flex;
  gap: 0.5rem;
}

/* Volume Modal Details */
.vol-target-title {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--primary-azure);
  margin-bottom: 0.5rem;
}

.vol-status-info {
  background: rgba(14, 165, 233, 0.1);
  border-left: 3px solid var(--primary-azure);
  padding: 0.6rem 0.9rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.9rem;
}

.counter-input-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-counter {
  width: 42px;
  height: 42px;
  background: rgba(30, 41, 59, 0.9);
  border: 1px solid var(--border-glass);
  color: var(--text-main);
  border-radius: var(--radius-md);
  font-size: 1.2rem;
  font-weight: bold;
  cursor: pointer;
}
.btn-counter:hover {
  background: var(--primary-azure);
  border-color: var(--primary-azure);
}

.quick-add-buttons {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

.btn-chip-add {
  flex: 1;
  padding: 0.45rem;
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid var(--border-glass);
  color: var(--primary-azure);
  border-radius: var(--radius-md);
  font-family: var(--font-heading);
  font-size: 0.85rem;
  cursor: pointer;
}
.btn-chip-add:hover {
  background: rgba(14, 165, 233, 0.2);
  border-color: var(--primary-azure);
}

/* Detail Modal Styles */
.detail-modal-body {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 2rem;
}
@media (max-width: 768px) {
  .detail-modal-body {
    grid-template-columns: 1fr;
  }
}

.detail-gallery-col {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.main-cover-frame {
  height: 420px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  position: relative;
  background: #020617;
  border: 1px solid var(--border-glass);
}

.detail-main-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.detail-fav-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--border-glass);
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
}
.detail-fav-btn.active {
  color: var(--star-gold);
  border-color: var(--star-gold);
}

.thumbnails-bar {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
}

.thumb-img {
  width: 60px;
  height: 80px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  cursor: pointer;
  opacity: 0.7;
}
.thumb-img.active, .thumb-img:hover {
  opacity: 1;
  border-color: var(--primary-azure);
}

.detail-info-col {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.detail-header-info {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.detail-title {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-main);
}
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 600;
  color: #fff;
  width: fit-content;
}

.detail-rating-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.detail-stars {
  color: var(--star-gold);
  font-size: 1.2rem;
  letter-spacing: 2px;
}
.detail-rating-score {
  font-family: var(--font-heading);
  font-size: 0.9rem;
  color: var(--text-muted);
}

.detail-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border-glass);
  padding: 1rem;
  border-radius: var(--radius-md);
}

.detail-meta-item {
  display: flex;
  flex-direction: column;
}
.detail-meta-label {
  font-size: 0.78rem;
  color: var(--text-muted);
}
.detail-meta-value {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-main);
}
.detail-meta-value.highlight-blue {
  color: var(--primary-azure);
}

.detail-vol-action {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.detail-section-box {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.detail-box-title {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-sub);
}

.character-pairs-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.character-pairs-list li {
  background: rgba(14, 165, 233, 0.08);
  border-left: 3px solid var(--primary-azure);
  padding: 0.45rem 0.8rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.9rem;
}

.detail-actions-row {
  display: flex;
  gap: 1rem;
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--border-glass);
}
