/**
 * Enhanced AI Response Styles
 * Provides beautiful, professional styling for AI responses with calculations and safety info
 */

/* Phase C: source label (material table vs guidance) */
.ai-response-source {
  font-size: 0.8125rem;
  line-height: 1.4;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.75rem;
}

.ai-response-source-label {
  display: block;
}

.enhanced-ai-response {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  margin: 1rem 0;
  overflow: hidden;
  transition: all 0.3s ease;
}

.enhanced-ai-response:hover {
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
  transform: translateY(-2px);
}

.response-header {
  background: linear-gradient(135deg, var(--accent-color), var(--accent-color-dark));
  color: white;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  position: relative;
}

.response-header h3 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  flex: 1;
}

.response-icon {
  font-size: 1.5rem;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.confidence-badge {
  background: rgba(255, 255, 255, 0.2);
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.875rem;
  font-weight: 500;
  backdrop-filter: blur(10px);
}

.response-content {
  padding: 1.5rem;
}

/* SFM-by-tool-material table (AI lists HSS / Cobalt / Carbide) */
.ai-sfm-tool-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.75rem 0 1rem;
  font-size: 0.9375rem;
}

.ai-sfm-tool-table th,
.ai-sfm-tool-table td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.75rem;
  text-align: left;
}

.ai-sfm-tool-table thead th {
  background: var(--bg-secondary);
  font-weight: 600;
}

.ai-sfm-tool-table tbody tr:nth-child(even) {
  background: var(--bg-secondary);
}

.response-content .note {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-top: 0.5rem;
}

/* Cobalt + stainless rigidity disclaimer (AI, tap material help) */
.ai-disclaimer {
  font-size: 0.875rem;
  line-height: 1.45;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent-color);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin: 0.75rem 0 0;
}

.ai-disclaimer strong {
  color: var(--text-primary);
  font-weight: 600;
}

.query-section {
  background: var(--bg-secondary);
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 1.5rem;
  border-left: 4px solid var(--accent-color);
}

.query-section strong {
  color: var(--accent-color);
  font-weight: 600;
}

.parameters-section {
  margin-bottom: 1.5rem;
}

.parameters-section h4 {
  color: var(--text-primary);
  margin-bottom: 1rem;
  font-size: 1.1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.parameter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

/* AI Voice Assistant Styles */
#nlqVoiceBtn {
  font-size: 1.25rem;
  transition: all 0.3s ease;
  padding: 0 1rem;
}

#nlqVoiceBtn.recording {
  background-color: #ef4444;
  color: white;
  animation: pulse-red 1.5s infinite;
  border-color: #dc2626;
}

@keyframes pulse-red {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
  }

  70% {
    transform: scale(1.05);
    box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
  }

  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
  }
}

.parameter-item {
  background: var(--bg-secondary);
  padding: 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.2s ease;
}

.parameter-item:hover {
  background: var(--bg-tertiary);
  border-color: var(--accent-color);
}

.param-label {
  font-weight: 500;
  color: var(--text-secondary);
}

.param-value {
  font-weight: 600;
  color: var(--accent-color);
  font-size: 1.1rem;
}

.calculations-section {
  margin-bottom: 1.5rem;
}

.calculations-section h4 {
  color: var(--text-primary);
  margin-bottom: 1rem;
  font-size: 1.1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.calculation-steps {
  background: var(--bg-secondary);
  border-radius: 8px;
  padding: 1rem;
  border: 1px solid var(--border);
}

.calculation-step {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.calculation-step:last-child {
  border-bottom: none;
}

.step-number {
  background: var(--accent-color);
  color: white;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.875rem;
  flex-shrink: 0;
}

.step-text {
  flex: 1;
  color: var(--text-primary);
  font-weight: 500;
}

.step-result {
  background: var(--bg-tertiary);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-family: 'Courier New', monospace;
  font-weight: 600;
  color: var(--accent-color);
  border: 1px solid var(--border);
}

.tool-recommendations,
.safety-section,
.tips-section {
  margin-bottom: 1.5rem;
}

.tool-recommendations h4,
.safety-section h4,
.tips-section h4 {
  color: var(--text-primary);
  margin-bottom: 1rem;
  font-size: 1.1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.tool-recommendations ul,
.safety-section ul,
.tips-section ul {
  background: var(--bg-secondary);
  border-radius: 8px;
  padding: 1rem;
  border: 1px solid var(--border);
  margin: 0;
}

.tool-recommendations li,
.safety-section li,
.tips-section li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}

.tool-recommendations li:last-child,
.safety-section li:last-child,
.tips-section li:last-child {
  border-bottom: none;
}

.tool-recommendations strong,
.safety-section strong,
.tips-section strong {
  color: var(--accent-color);
  font-weight: 600;
}

/* Contextual mode hints */
.ai-context {
  margin-top: 1rem;
}

.mode-hints {
  background: var(--bg-secondary);
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.mode-hints h4 {
  margin: 0 0 0.75rem;
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 600;
}

.mode-hints ul {
  margin: 0;
  padding-left: 1.25rem;
}

.mode-hints li {
  margin-bottom: 0.75rem;
  color: var(--text-primary);
}

.mode-hints li:last-child {
  margin-bottom: 0;
}

.ai-mode-link {
  margin-left: 0.75rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--accent-color);
  background: transparent;
  color: var(--accent-color);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.ai-mode-link:hover {
  background: var(--accent-color);
  color: #fff;
}

.ai-mode-link:focus-visible {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}

.general-guidance {
  background: var(--bg-secondary);
  border-radius: 8px;
  padding: 1.5rem;
  border: 1px solid var(--border);
}

.general-guidance p {
  margin-bottom: 1rem;
  color: var(--text-primary);
}

.general-guidance ul {
  margin: 1rem 0;
  padding-left: 1.5rem;
}

.general-guidance li {
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.general-guidance strong {
  color: var(--accent-color);
  font-weight: 600;
}

/* Dark theme adjustments */
[data-theme="dark"] .enhanced-ai-response {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .enhanced-ai-response:hover {
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .parameter-item:hover {
  background: var(--bg-tertiary);
  border-color: var(--accent-color);
}

[data-theme="dark"] .step-result {
  background: var(--bg-primary);
  border-color: var(--accent-color);
}

[data-theme="dark"] .mode-hints {
  background: var(--bg-tertiary);
  border-color: var(--accent-color);
}

[data-theme="dark"] .ai-mode-link {
  border-color: var(--accent-color);
}

/* Light theme adjustments */
[data-theme="light"] .enhanced-ai-response {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .enhanced-ai-response:hover {
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .parameter-item {
  background: #f8f9fa;
}

[data-theme="light"] .parameter-item:hover {
  background: #e9ecef;
  border-color: var(--accent-color);
}

[data-theme="light"] .calculation-steps {
  background: #f8f9fa;
}

[data-theme="light"] .tool-recommendations ul,
[data-theme="light"] .safety-section ul,
[data-theme="light"] .tips-section ul {
  background: #f8f9fa;
}

[data-theme="light"] .general-guidance {
  background: #f8f9fa;
}

[data-theme="light"] .mode-hints {
  background: #f8f9fa;
}

/* Responsive design */
@media (max-width: 768px) {
  .parameter-grid {
    grid-template-columns: 1fr;
  }

  .calculation-step {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .step-result {
    width: 100%;
    text-align: center;
  }

  .response-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .confidence-badge {
    align-self: flex-end;
  }
}

/* Animation for loading states */
.enhanced-ai-response.loading {
  opacity: 0.7;
  pointer-events: none;
}

.enhanced-ai-response.loading::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  animation: loading-shimmer 1.5s infinite;
}

@keyframes loading-shimmer {
  0% {
    transform: translateX(-100%);
  }

  100% {
    transform: translateX(100%);
  }
}

.active-job-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--accent-light);
  color: var(--accent-color);
  padding: 0.25rem 0.75rem;
  border-radius: 99px;
  font-size: 0.875rem;
  font-weight: 600;
  margin-left: 1rem;
  border: 1px solid var(--accent-color);
}

.active-job-badge.hidden {
  display: none;
}

#changeJobBtn {
  font-size: 0.75rem;
  text-decoration: underline;
  cursor: pointer;
  background: none;
  border: none;
  color: var(--accent-color);
  padding: 0;
  margin-left: 0.5rem;
}

.ai-insight-warning {
  background: #fff7ed;
  border: 1px solid #fbbf24;
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1.5rem;
  color: #92400e;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9375rem;
  animation: slide-in 0.3s ease-out;
}

.insight-icon {
  font-size: 1.5rem;
}

@keyframes slide-in {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Craig Easter egg image */
.craig-easter-egg .craig-easter-egg-image {
  margin-bottom: 1.5rem;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border, #e2e8f0);
}

.craig-easter-egg .craig-easter-egg-image img {
  display: block;
  max-width: 100%;
  width: 100%;
  height: auto;
  vertical-align: middle;
}
