/* Modern Professional UI for JFP Tech Support Bot */
/* H3 FIX: Removed duplicate CSS custom properties that were already defined
   in base.css's [data-theme] selectors. Those theme-aware vars (--bg-card,
   --border, --text-primary, --text-secondary) were being overridden here
   with hardcoded dark-mode values, preventing theme switching.
   Kept: --primary/--success/--warning (design-tokens.css is dead/not loaded,
   so modern-ui.css is the only provider for files that reference them). */

:root {
  /* JFP Brand Colors - kept because design-tokens.css is not loaded */
  --primary: #00AFD2;
  --primary-dark: #0090B0;
  --primary-light: #E6F7FB;
  --secondary: #FF6900;
  --secondary-dark: #E05E00;

  /* Dark background base - used by .header gradient */
  --bg-dark: #0E143E;

  /* Hover background (not in base.css) */
  --bg-hover: #1E2A4A;

  /* REMOVED (defined in base.css [data-theme] selectors, which are theme-aware):
     --bg-card, --border, --text-primary, --text-secondary
     Having them here in :root with static dark-mode values overrode the
     theme-specific values in base.css, breaking light mode. */

  /* Muted text (base.css uses --text-tertiary instead) */
  --text-muted: #8B99B5;

  /* Functional Colors - kept because design-tokens.css is not loaded */
  --success: #34C759;
  --warning: #FF9500;
  --error: #FF3B30;

  /* Spacing (unique to modern-ui) */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 12px;
  --spacing-lg: 16px;
  --spacing-xl: 24px;
  --spacing-2xl: 32px;

  /* Border Radius (sm and xl are unique; md and lg come from base.css) */
  --radius-sm: 6px;
  --radius-xl: 16px;

  /* Shadows (unique names, not in base.css) */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* ===== HEADER & NAVIGATION ===== */

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-lg);
  background: linear-gradient(135deg, var(--bg-dark) 0%, var(--bg-card) 100%);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 501;
  gap: var(--spacing-lg);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  text-decoration: none;
}

.header-brand span {
  font-size: 24px;
}

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

/* Hamburger Menu Button */
.hamburger-btn {
  background: transparent;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: var(--spacing-md);
  border-radius: var(--radius-md);
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  gap: 5px;
  z-index: 502;
}

.hamburger-btn:hover {
  background: var(--bg-hover);
}

.hamburger-btn span {
  width: 24px;
  height: 2px;
  background: var(--text-primary);
  transition: all 0.3s ease;
  border-radius: 1px;
}

.hamburger-btn.active span:nth-child(1) {
  transform: rotate(45deg) translate(10px, 10px);
}

.hamburger-btn.active span:nth-child(2) {
  opacity: 0;
}

.hamburger-btn.active span:nth-child(3) {
  transform: rotate(-45deg) translate(7px, -7px);
}

/* Mobile Menu */
.mobile-menu {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-dark);
  z-index: 1001;
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.mobile-menu.active {
  opacity: 1;
  visibility: visible;
}

.mobile-menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-lg);
  border-bottom: 1px solid var(--border);
}

.mobile-menu-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--spacing-lg);
}

.mobile-menu-section {
  margin-bottom: var(--spacing-2xl);
}

.mobile-menu-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--spacing-md);
  letter-spacing: 1px;
}

.mobile-menu-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  padding: var(--spacing-md) var(--spacing-lg);
  margin-bottom: var(--spacing-sm);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  text-decoration: none;
  cursor: pointer;
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
  font-size: 14px;
  transition: all 0.2s ease;
}

.mobile-menu-item:hover {
  background: var(--bg-hover);
  color: var(--primary);
}

.mobile-menu-item span {
  font-size: 18px;
}

/* ===== ENHANCED ANIMATIONS ===== */

@keyframes pulse-glow {
  0%, 100% {
    box-shadow: 0 0 20px rgba(0, 180, 255, 0.5), 0 0 40px rgba(0, 180, 255, 0.3);
  }
  50% {
    box-shadow: 0 0 30px rgba(0, 180, 255, 0.8), 0 0 60px rgba(0, 180, 255, 0.5);
  }
}

@keyframes glow-bright {
  0%, 100% {
    filter: drop-shadow(0 0 8px rgba(0, 180, 255, 0.4));
  }
  50% {
    filter: drop-shadow(0 0 16px rgba(0, 180, 255, 0.8));
  }
}

@keyframes ripple {
  to {
    transform: scale(4);
    opacity: 0;
  }
}

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

@keyframes slideInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

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

@keyframes bounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}

/* Loading Spinner */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(0, 180, 255, 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner-small {
  width: 16px;
  height: 16px;
  border-width: 2px;
}

.spinner-large {
  width: 40px;
  height: 40px;
  border-width: 4px;
}

/* ===== BUTTONS ===== */

button, a.btn {
  font-family: 'Open Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-md);
  padding: var(--spacing-sm) var(--spacing-lg);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-sm);
  text-decoration: none;
  position: relative;
}

button:focus, a.btn:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* Primary Button */
.btn-primary, button.primary, .btn.primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: white;
  box-shadow: 0 4px 16px rgba(0, 180, 255, 0.4), 0 0 0 1px rgba(0, 180, 255, 0.2) inset;
  position: relative;
  overflow: hidden;
}

/* Ripple effect for button clicks */
.btn-ripple::after {
  content: '';
  position: absolute;
  top: var(--ripple-y);
  left: var(--ripple-x);
  width: 20px;
  height: 20px;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 50%;
  transform: scale(0);
  animation: ripple 0.6s ease-out;
  pointer-events: none;
}

.btn-primary:hover, button.primary:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0, 180, 255, 0.6), 0 0 0 1px rgba(0, 180, 255, 0.3) inset;
  background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 100%);
}

.btn-primary:focus, button.primary:focus {
  animation: pulse-glow 1.5s ease-in-out;
  outline: none;
}

.btn-primary:active, button.primary:active {
  transform: scale(0.97) translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 180, 255, 0.4), 0 0 0 1px rgba(0, 180, 255, 0.2) inset;
}

/* Secondary Button */
.btn-secondary {
  background: var(--bg-hover);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

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

/* Ghost Button */
.btn-ghost {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border);
}

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

/* Icon Button */
.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: var(--spacing-md);
  border-radius: var(--radius-md);
}

.btn-icon:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* Small Button */
.btn-sm {
  padding: var(--spacing-xs) var(--spacing-md);
  font-size: 12px;
}

/* ===== MODE TABS ===== */

.mode-tabs {
  display: flex;
  gap: var(--spacing-sm);
  background: var(--bg-card);
  padding: var(--spacing-md);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

.mode-tab {
  flex: 1;
  padding: var(--spacing-md) var(--spacing-lg);
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mode-tab.active {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: white;
}

.mode-tab:hover:not(.active) {
  color: var(--text-primary);
  background: var(--bg-hover);
}

/* ===== INPUT FIELDS ===== */

.input-field {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--spacing-md) var(--spacing-lg);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.input-field:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 180, 255, 0.15), inset 0 0 0 1px rgba(0, 180, 255, 0.3);
}

.input-field::placeholder {
  color: var(--text-muted);
}

/* ===== SEARCH BOX ===== */

.search-container {
  position: relative;
  display: flex;
  gap: var(--spacing-sm);
}

.search-input {
  flex: 1;
  padding: var(--spacing-md) var(--spacing-lg);
  font-size: 16px;
}

.search-actions {
  display: flex;
  gap: var(--spacing-sm);
}

.search-action-btn {
  background: var(--bg-hover);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: var(--spacing-md);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 16px;
}

.search-action-btn:hover {
  color: var(--text-primary);
  border-color: var(--primary);
}

/* ===== ENHANCED TYPOGRAPHY ===== */

body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

.hero-title,
h2.hero-title {
  font-family: 'Oswald', sans-serif;
  font-size: clamp(24px, 5vw, 36px);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.5px;
  line-height: 1.2;
  margin: 0;
}

.hero-subtitle,
p.hero-subtitle {
  font-family: 'Open Sans', sans-serif;
  font-size: clamp(14px, 3vw, 18px);
  color: var(--text-secondary);
  line-height: 1.6;
  margin: 0;
}

/* ===== CARDS ===== */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  transition: all 0.2s ease;
}

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

.card.hero-card,
.hero-card {
  background: linear-gradient(135deg, rgba(21, 29, 58, 0.9) 0%, rgba(10, 14, 39, 0.95) 100%);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(0, 180, 255, 0.5);
  border-radius: var(--radius-xl);
  padding: var(--spacing-2xl);
  box-shadow: 0 0 30px rgba(0, 180, 255, 0.2), 0 8px 32px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  animation: slideInUp 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.card.hero-card:hover,
.hero-card:hover {
  border-color: rgba(0, 180, 255, 0.8);
  box-shadow: 0 0 40px rgba(0, 180, 255, 0.4), 0 12px 48px rgba(0, 180, 255, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.15);
  transform: translateY(-6px);
}

.card-header {
  margin-bottom: var(--spacing-md);
  padding-bottom: var(--spacing-md);
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.card-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: var(--spacing-sm);
}

/* ===== CATEGORY CARDS ===== */

.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--spacing-lg);
  margin-bottom: var(--spacing-2xl);
}

.category-btn,
.category-card {
  background: linear-gradient(135deg, rgba(30, 42, 75, 0.7) 0%, rgba(21, 29, 58, 0.8) 100%);
  border: 1px solid rgba(0, 180, 255, 0.3);
  border-radius: var(--radius-lg);
  padding: var(--spacing-xl);
  text-align: center;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
  align-items: center;
  font-family: inherit;
  font-size: inherit;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: slideInUp 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  animation-fill-mode: both;
}

.category-card:nth-child(1) { animation-delay: 0.1s; }
.category-card:nth-child(2) { animation-delay: 0.2s; }
.category-card:nth-child(3) { animation-delay: 0.3s; }
.category-card:nth-child(4) { animation-delay: 0.4s; }
.category-card:nth-child(5) { animation-delay: 0.5s; }
.category-card:nth-child(6) { animation-delay: 0.6s; }

.category-btn:hover,
.category-card:hover {
  border-color: var(--primary);
  transform: translateY(-8px) scale(1.03);
  box-shadow: 0 8px 32px rgba(0, 180, 255, 0.5), 0 0 20px rgba(0, 180, 255, 0.3);
  background: linear-gradient(135deg, rgba(0, 180, 255, 0.15) 0%, rgba(0, 180, 255, 0.08) 100%);
}

.category-btn:active,
.category-card:active {
  transform: translateY(-2px) scale(0.97);
  box-shadow: 0 4px 12px rgba(0, 180, 255, 0.3);
}

.category-btn.primary {
  border-color: var(--primary);
  background: linear-gradient(135deg, rgba(0, 180, 255, 0.2) 0%, rgba(0, 180, 255, 0.1) 100%);
}

.category-icon {
  font-size: 32px;
  transition: transform 0.3s ease;
}

.category-btn:hover .category-icon,
.category-card:hover .category-icon {
  transform: scale(1.2) rotate(5deg);
}

.category-label {
  font-weight: 600;
  font-size: 14px;
}

.category-desc {
  font-size: 12px;
  color: var(--text-secondary);
}

/* ===== RESPONSIVE ===== */

@media (max-width: 768px) {
  .header {
    padding: var(--spacing-md);
  }

  .mode-tabs {
    width: 100%;
  }

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

@media (max-width: 480px) {
  .header-brand {
    font-size: 16px;
  }

  button, a.btn {
    font-size: 13px;
    padding: var(--spacing-xs) var(--spacing-md);
  }

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

/* ===== UTILITIES ===== */

.text-center {
  text-align: center;
}

.mt-sm { margin-top: var(--spacing-sm); }
.mt-md { margin-top: var(--spacing-md); }
.mt-lg { margin-top: var(--spacing-lg); }
.mt-xl { margin-top: var(--spacing-xl); }

.mb-sm { margin-bottom: var(--spacing-sm); }
.mb-md { margin-bottom: var(--spacing-md); }
.mb-lg { margin-bottom: var(--spacing-lg); }
.mb-xl { margin-bottom: var(--spacing-xl); }

.hidden {
  display: none !important;
}

.opacity-50 {
  opacity: 0.5;
}

.opacity-75 {
  opacity: 0.75;
}

/* ===== FLOATING BUTTON ===== */

.floating-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  border: none;
  cursor: pointer;
  font-size: 28px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  transition: all 0.3s ease;
}

.floating-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(30, 144, 255, 0.5);
}

.floating-btn:active {
  transform: scale(0.95);
}

/* ===== BACK LINK BUTTON ===== */

.back-link {
  background: transparent;
  border: none;
  color: var(--primary);
  cursor: pointer;
  padding: var(--spacing-md) var(--spacing-lg);
  font-weight: 600;
  font-size: 14px;
  transition: all 0.2s ease;
  text-decoration: none;
}

.back-link:hover {
  color: var(--primary-light);
  text-decoration: underline;
}

/* ===== WIRING DIAGRAM DISPLAY ===== */

/* Ensure wiring diagram containers have light background for visibility */
.card img[alt="Wiring Diagram"],
.card img[alt="Diagram"],
.diagram-image {
  background: white !important;
  filter: contrast(1.1);
}

/* Override dark card styling for diagram containers */
.card > div[style*="background: white"],
.diagram-container {
  background: white !important;
  color: #333 !important;
}

/* Ensure all images in diagram sections are visible */
.diagram-image-wrapper,
[style*="diagram"] img {
  background: white !important;
  display: block;
  max-width: 100%;
}

/* ===== ANSWER CARD COMPONENTS ===== */
/* Extracted from search.js inline styles for maintainability */

/* COP Reference Banner */
.cop-banner {
  background: linear-gradient(135deg, rgba(10, 132, 255, 0.15), rgba(90, 200, 250, 0.1));
  border: 1px solid rgba(10, 132, 255, 0.3);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.cop-banner-icon { font-size: 20px; }
.cop-banner-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.cop-banner-id { font-size: 14px; font-weight: 500; }

/* Safety Warning Banner */
.safety-banner {
  background: rgba(255, 59, 48, 0.1);
  border: 1px solid rgba(255, 59, 48, 0.3);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 16px;
  display: block;
  transition: padding 0.2s ease;
}
.safety-banner-header {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}
.safety-banner-header:hover { opacity: 0.85; }
.safety-banner-header-text { flex: 1; }
.safety-banner-chevron {
  font-size: 12px;
  color: var(--text-secondary);
  margin-left: auto;
  transition: transform 0.2s ease;
}
.safety-banner-collapsed { padding: 8px 16px; }
.safety-banner-collapsed .safety-banner-chevron { transform: rotate(180deg); }

.safety-banner-icon { font-size: 20px; }
.safety-banner-label {
  font-size: 14px;
  font-weight: 700;
  color: #ff3b30;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.safety-toggle {
  font-size: 11px;
  color: var(--text-secondary);
  display: inline-block;
  margin-top: 2px;
}
.safety-details {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 59, 48, 0.15);
}
.safety-banner-text {
  font-size: 14px;
  color: var(--text-primary);
  padding: 2px 0;
}
.safety-banner-text + .safety-banner-text {
  border-top: 1px solid rgba(255, 59, 48, 0.15);
  margin-top: 4px;
  padding-top: 6px;
}

/* Answer Content Formatting */
.answer-content {
  line-height: 1.6;
  font-size: 14px;
}

.answer-content h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 16px 0 8px;
  color: var(--text-primary);
}

.answer-content h4 {
  font-size: 15px;
  font-weight: 600;
  margin: 16px 0 8px;
  color: var(--text-primary);
}

.answer-content pre {
  background: var(--code-bg, rgba(0,0,0,0.05));
  padding: 12px;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 13px;
  margin: 8px 0;
}

.answer-content code {
  background: var(--code-bg, rgba(0,0,0,0.05));
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
}

.answer-content pre code {
  background: none;
  padding: 0;
}

.answer-list-item {
  display: flex;
  gap: 8px;
  padding: 2px 0;
}

.answer-list-number {
  color: var(--accent);
  font-weight: 600;
  min-width: 20px;
}

.answer-list-bullet {
  color: var(--accent);
}

.answer-blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 12px;
  margin: 8px 0;
  color: var(--text-secondary);
  font-style: italic;
}

.answer-hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

/* Sources Section - H6 FIX: collapsible, visually separated from answer body */
.sources-section {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.sources-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
  padding: 4px 0;
}

.sources-toggle:hover {
  color: var(--accent, #3aa8ff);
}

.sources-toggle-chevron {
  font-size: 10px;
  transition: transform 0.2s ease;
  color: var(--text-tertiary);
}

.sources-toggle.collapsed .sources-toggle-chevron {
  transform: rotate(-90deg);
}

.sources-list {
  overflow: hidden;
  max-height: 1000px;
  transition: max-height 0.3s ease, opacity 0.2s ease;
}

.sources-list.collapsed {
  max-height: 0;
  opacity: 0;
}

.sources-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  margin-bottom: 0;
}

.source-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  padding: 6px 8px;
}

.source-link {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  padding: 6px 8px;
  margin: 2px -8px;
  border-radius: 8px;
  text-decoration: none;
  transition: background 0.15s;
}

.source-link:hover {
  background: var(--hover-bg, rgba(0,175,210,0.08));
}

.source-icon { font-size: 16px; }
.source-vendor { color: var(--accent); font-size: 14px; font-weight: 600; }
.source-page { color: var(--text-tertiary); font-size: 11px; }
.source-view { font-size: 11px; color: var(--accent); margin-left: auto; }

/* ===== H1 FIX: CSS classes extracted from inline styles in search.js answer area ===== */
/* Source system tag (e.g. [ServiceMax], [Mobile Tech]) */
.source-system {
  font-size: 11px;
  color: var(--accent, #4a90d9);
  font-weight: 500;
}

/* Intelligence badges container (parts intel, fleet alert, lifecycle, etc.) */
.intelligence-badges {
  margin: 12px 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Individual intelligence badge pill */
.intel-badge {
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}

/* Synthesis / Field Intelligence collapsible panels */
.synthesis-section,
.field-intel-section {
  margin: 12px 0;
  border-radius: 8px;
  overflow: hidden;
}

.synthesis-header,
.field-intel-header {
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.intel-risk-badge,
.intel-grade-badge {
  color: #fff;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.intel-section-title {
  font-size: 13px;
  font-weight: 600;
}

.intel-section-score {
  font-size: 12px;
  color: #666;
  margin-left: auto;
}

.intel-section-chevron {
  font-size: 11px;
  color: #999;
  margin-left: 4px;
}

.synthesis-body,
.fi-body {
  padding: 10px 12px;
  font-size: 13px;
  white-space: pre-wrap;
  line-height: 1.5;
  max-height: 300px;
  overflow-y: auto;
}

/* Diagnostic script download button */
.diag-script-btn {
  background: linear-gradient(135deg, #FF6900, #FF8C33);
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 8px;
  width: 100%;
  font-size: 14px;
}

.diag-script-btn:hover {
  filter: brightness(1.08);
}

/* Step progress (hidden by default, shown by JS when steps exist) */
#step-progress {
  display: none;
}

/* H6 FIX: Clear visual dividers between answer card sections. Each major
   section (sources, WYH, synthesis, feedback, notes) gets a top border
   and spacing so they read as distinct blocks, not one run-on card. */
.answer-actions {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* Feedback Row */
.feedback-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.feedback-label {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-right: 4px;
}

.feedback-btn {
  padding: 6px 12px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

.feedback-btn:hover { border-color: var(--accent); color: var(--accent); }
.feedback-btn.thumbs-up:hover { border-color: #34C759; color: #34C759; }
.feedback-btn.thumbs-down:hover { border-color: #FF3B30; color: #FF3B30; }
.feedback-btn.selected.thumbs-up {
  border-color: #34C759;
  color: #34C759;
  background: rgba(52, 199, 89, 0.1);
}
.feedback-btn.selected.thumbs-down {
  border-color: #FF3B30;
  color: #FF3B30;
  background: rgba(255, 59, 48, 0.1);
}

.copy-btn {
  margin-left: auto;
  padding: 6px 12px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

.copy-btn:hover { border-color: var(--accent); color: var(--accent); }

/* Generate Notes Button */
.notes-btn {
  width: 100%;
  padding: 14px 20px;
  background: linear-gradient(135deg, #34C759, #30B350);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s;
}

.notes-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(52, 199, 89, 0.3);
}

.notes-btn-icon { font-size: 18px; }

/* Vendor Clarification UI */
.clarification-header {
  text-align: center;
  padding: 8px 0 16px;
}

.clarification-icon { font-size: 24px; margin-bottom: 8px; }

.clarification-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.clarification-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.clarification-options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.clarification-btn {
  padding: 12px 24px;
  background: linear-gradient(135deg, rgba(0,175,210,0.15), rgba(0,175,210,0.08));
  border: 1px solid rgba(0,175,210,0.3);
  border-radius: 12px;
  color: var(--accent);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.clarification-btn:hover {
  background: linear-gradient(135deg, rgba(0,175,210,0.25), rgba(0,175,210,0.15));
}

/* Toast Notification */
.toast-notification {
  position: fixed;
  bottom: 60px; /* Clear the fixed confidentiality footer */
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card, #1a1a2e);
  color: var(--text-primary, #fff);
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 14px;
  z-index: 9999;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  transition: opacity 0.3s;
}
.toast-warning { background: #b45309; color: #fff; }
.toast-error { background: #dc2626; color: #fff; }
.toast-info { background: #0369a1; color: #fff; }

/* Voice recording indicator */
.voice-recording {
  animation: voice-pulse 1s ease-in-out infinite;
  background: rgba(220, 38, 38, 0.15) !important;
  color: #dc2626 !important;
}
@keyframes voice-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(220, 38, 38, 0); }
}

/* Loading Progress */
.loading-card { text-align: center; padding: 40px; }

.loading-spinner {
  display: inline-block;
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-step-text {
  color: var(--text-secondary);
  margin-top: 16px;
  font-size: 14px;
}

.loading-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
}

.loading-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  transition: background 0.3s;
}

.loading-dot.active { background: var(--accent); }

/* No results / Error states */
.no-results {
  text-align: center;
  color: var(--text-secondary);
}

.search-error {
  text-align: center;
  color: #ff3b30;
}

/* Search History Dropdown */
/* Search history dropdown - uses CSS vars for light/dark mode parity */
.search-history-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  max-height: 300px;
  overflow-y: auto;
  margin-top: 4px;
}

.search-history-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-primary);
  transition: background 0.15s;
  border-bottom: 1px solid var(--border);
}
.search-history-item:last-child { border-bottom: none; }

.search-history-item:hover { background: rgba(0, 175, 210, 0.12); }
.search-history-icon { font-size: 14px; color: var(--text-tertiary); }

/* ===== Insights / Analytics Charts ===== */

.insight-chart-card {
  background: var(--bg-card, #151D3A);
  border: 1px solid var(--border, #2D3F5F);
  border-radius: 16px;
  overflow: hidden;
  max-width: 100%;
}

.insight-chart-header {
  padding: 16px 20px 8px;
}

.insight-chart-title {
  font-family: var(--font-heading, 'Oswald', sans-serif);
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary, #fff);
  letter-spacing: 0.3px;
}

.insight-chart-subtitle {
  font-size: 12px;
  color: var(--text-tertiary, #8B99B5);
  margin-top: 2px;
}

.insight-chart-container {
  width: 100%;
  min-height: 280px;
  padding: 0 8px;
}

.insight-chart-summary {
  padding: 10px 20px;
  font-size: 13px;
  color: var(--text-secondary, #C5D4E8);
  border-top: 1px solid var(--border, rgba(45, 63, 95, 0.5));
  background: rgba(0, 175, 210, 0.04);
}

.insight-chart-actions {
  display: flex;
  gap: 6px;
  padding: 10px 20px 14px;
  flex-wrap: wrap;
  align-items: center;
}

.insight-action-btn {
  padding: 5px 14px;
  border-radius: 20px;
  border: 1px solid var(--border, #2D3F5F);
  background: transparent;
  color: var(--text-secondary, #C5D4E8);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.insight-action-btn:hover {
  background: rgba(0, 175, 210, 0.12);
  border-color: var(--primary, #00AFD2);
  color: var(--primary, #00AFD2);
}

.insight-action-btn.active {
  background: var(--primary, #00AFD2);
  color: #fff;
  border-color: var(--primary, #00AFD2);
}

.insight-action-fullscreen {
  margin-left: auto;
  font-size: 16px;
  padding: 4px 10px;
}

.insight-chart-error {
  padding: 20px;
  text-align: center;
  color: var(--error, #FF3B30);
  font-size: 13px;
}

/* Preset chips grid */
.insight-presets-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 0;
}

.insight-preset-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 24px;
  border: 1px solid var(--border, #2D3F5F);
  background: rgba(0, 175, 210, 0.06);
  color: var(--text-secondary, #C5D4E8);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.insight-preset-chip:hover {
  background: rgba(0, 175, 210, 0.15);
  border-color: var(--primary, #00AFD2);
  color: var(--primary, #00AFD2);
  transform: translateY(-1px);
}

.insight-preset-icon {
  font-size: 14px;
}

/* Fullscreen overlay */
.insight-fullscreen-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.insight-fullscreen-container {
  width: 90vw;
  height: 80vh;
  background: var(--bg-card, #151D3A);
  border-radius: 16px;
  padding: 20px;
  position: relative;
}

.insight-fullscreen-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  color: var(--text-secondary, #C5D4E8);
  font-size: 28px;
  cursor: pointer;
  z-index: 10;
  padding: 4px 8px;
  line-height: 1;
}

.insight-fullscreen-close:hover {
  color: var(--text-primary, #fff);
}

/* ===== Nearby Site Selector Chips ===== */

.nearby-sites-container {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.nearby-sites-container::-webkit-scrollbar {
  display: none;
}

.nearby-site-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-secondary);
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.nearby-site-chip:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(0, 175, 210, 0.08);
}

.nearby-site-chip.active {
  border-color: var(--primary);
  background: rgba(0, 175, 210, 0.15);
  color: var(--primary);
  font-weight: 600;
}

.nearby-site-chip .chip-distance {
  color: var(--text-muted);
  font-size: 11px;
}

.nearby-site-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: rgba(0, 175, 210, 0.12);
  border: 1px solid var(--primary);
  border-radius: 16px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 500;
}

.nearby-site-badge .badge-clear {
  cursor: pointer;
  opacity: 0.7;
  font-size: 14px;
}

.nearby-site-badge .badge-clear:hover {
  opacity: 1;
}

/* ===== MICRO-INTERACTIONS & POLISH ===== */

/* Search button send animation */
.search-btn.sending {
  animation: sendPulse 0.4s ease;
}
@keyframes sendPulse {
  0% { transform: scale(1); }
  30% { transform: scale(0.92); }
  60% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

/* Copy button success checkmark */
.copy-btn.copied {
  color: #34C759 !important;
  border-color: #34C759 !important;
  background: rgba(52, 199, 89, 0.1) !important;
}

/* Filter chip spring select */
.filter-chip.active {
  animation: chipSelect 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes chipSelect {
  0% { transform: scale(1); }
  40% { transform: scale(0.9); }
  100% { transform: scale(1); }
}

/* Quick card press feedback */
.quick-card:active {
  transform: scale(0.96) !important;
  transition: transform 0.1s ease;
}

/* Smooth theme transition */
body, .header, .search-box, .quick-card, .insight-panel,
.chat-bubble-bot, .side-menu, .settings-popout {
  transition: background 0.35s ease, color 0.35s ease, border-color 0.35s ease,
              box-shadow 0.35s ease;
}

/* Answer content readability boost */
.answer-content {
  font-size: 15px;
  line-height: 1.7;
}

/* Code blocks - monospace */
.answer-content pre,
.answer-content code {
  font-family: 'SF Mono', 'Menlo', 'Monaco', 'Cascadia Code', monospace;
}

/* Safety keyword pulse */
.safety-keyword-danger {
  animation: safetyPulse 2s ease-in-out infinite;
}
@keyframes safetyPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Staggered card entrance */
.quick-card:nth-child(1) { animation-delay: 0.05s; }
.quick-card:nth-child(2) { animation-delay: 0.1s; }
.quick-card:nth-child(3) { animation-delay: 0.15s; }
.quick-card:nth-child(4) { animation-delay: 0.2s; }

/* Insight panel hover lift */
.insight-panel {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.insight-panel:hover {
  transform: translateY(-2px);
}

/* Settings popout spring entrance */
.settings-popout.active {
  animation: settingsSlideIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes settingsSlideIn {
  from { opacity: 0; transform: translateY(-12px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Follow-up chip hover glow */
[data-theme="dark"] .follow-up-chip:hover {
  box-shadow: 0 0 12px rgba(0, 175, 210, 0.25);
}

/* Nearby site chip select ring */
.nearby-site-chip.active {
  animation: chipRing 0.5s ease;
}
@keyframes chipRing {
  0% { box-shadow: 0 0 0 0 rgba(0, 175, 210, 0.4); }
  70% { box-shadow: 0 0 0 6px rgba(0, 175, 210, 0); }
  100% { box-shadow: 0 0 0 0 rgba(0, 175, 210, 0); }
}

/* Dispatch briefing card */
.briefing-card {
  font-size: 13px;
  line-height: 1.5;
}
.briefing-card h3 {
  font-size: 15px;
  font-weight: 700;
}
.briefing-section {
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
}
.briefing-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
}
.briefing-section strong {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--primary, #00AFD2);
}
.briefing-followup-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.briefing-chip {
  background: var(--bg-secondary, rgba(0, 175, 210, 0.1));
  border: 1px solid var(--primary, #00AFD2);
  color: var(--primary, #00AFD2);
  padding: 6px 14px;
  border-radius: 18px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.briefing-chip:hover {
  background: var(--primary, #00AFD2);
  color: #fff;
}

/* Toast notification slide-up entrance */
.toast-notification {
  animation: toastSlide 0.3s ease;
}
@keyframes toastSlide {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Feedback button press */
.feedback-btn:active {
  transform: scale(0.92);
}

/* Hero title enhanced depth */
.hero-title {
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
[data-theme="dark"] .hero-title {
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Notes button glow */
.notes-btn:hover {
  box-shadow: 0 4px 16px rgba(52, 199, 89, 0.4);
}

/* Diagnostic tile bounce on hover */
.diag-tile:hover .diag-tile-icon {
  animation: iconBounce 0.4s ease;
}
@keyframes iconBounce {
  0% { transform: scale(1); }
  40% { transform: scale(1.2); }
  100% { transform: scale(1.1); }
}

/* ===== TROUBLESHOOTING STEP CHECKBOXES ===== */

.answer-step-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 12px;
  margin: 2px 0;
  border-radius: 8px;
  transition: all 0.2s ease;
  border-left: 3px solid transparent;
}

.answer-step-item:hover {
  background: rgba(0, 175, 210, 0.04);
}

.answer-step-item.step-completed {
  border-left-color: #34C759;
  background: rgba(52, 199, 89, 0.06);
}

.answer-step-item.step-completed .step-content {
  color: var(--text-tertiary, #8892a8);
}

.answer-step-item.step-completed .answer-list-number {
  color: #34C759;
}

/* Custom checkbox - iOS style */
.step-checkbox-label {
  display: flex;
  align-items: center;
  cursor: pointer;
  flex-shrink: 0;
  margin-top: 2px;
}

.step-checkbox {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.step-check-icon {
  width: 22px;
  height: 22px;
  border: 2px solid var(--border, rgba(255,255,255,0.2));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  flex-shrink: 0;
}

.step-checkbox:checked + .step-check-icon {
  background: #34C759;
  border-color: #34C759;
  animation: checkBounce 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.step-checkbox:checked + .step-check-icon::after {
  content: '\2713';
  color: white;
  font-size: 14px;
  font-weight: 700;
}

@keyframes checkBounce {
  0% { transform: scale(0.8); }
  50% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

.step-content {
  flex: 1;
  transition: color 0.2s ease;
}

/* Step progress indicator */
#step-progress {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 6px 12px;
  margin-top: 8px;
}

/* ===== COLLAPSIBLE ANSWER SECTIONS ===== */

.answer-section-header {
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  transition: color 0.15s ease;
}

.answer-section-header:hover {
  color: var(--primary, #00AFD2);
}

.answer-section-header .section-toggle {
  font-size: 10px;
  transition: transform 0.2s ease;
  margin-left: auto;
  opacity: 0.5;
}

.answer-section-header.collapsed .section-toggle {
  transform: rotate(-90deg);
}

.answer-section-body {
  overflow: hidden;
  max-height: 2000px;
  transition: max-height 0.3s ease, opacity 0.2s ease;
}

.answer-section-body.collapsed {
  max-height: 0;
  opacity: 0;
  margin: 0;
  padding: 0;
}
