/**
 * Agent Mode Styles
 * Visual styling for agent mode UI components
 */

/* Agent Mode Indicator */
.agent-mode-indicator {
  position: absolute;
  right: 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #4285f4, #34a853);
  padding: 8px 16px;
  border-radius: 20px;
  box-shadow: 0 2px 8px rgba(66, 133, 244, 0.3);
  animation: slideInRight 0.3s ease-out;
}

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

.agent-indicator-content {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
}

.agent-indicator-content .material-icons {
  font-size: 20px;
  color: white;
}

.agent-indicator-text {
  color: white;
  font-size: 14px;
  font-weight: 600;
}

.agent-indicator-pulse {
  position: absolute;
  right: -4px;
  top: -4px;
  width: 10px;
  height: 10px;
  background: #34a853;
  border-radius: 50%;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.3);
    opacity: 0.7;
  }
}

/* Agent Thinking Indicator */
.agent-thinking {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  margin: 16px auto;
  max-width: 900px;
}

.agent-thinking-content {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--bg-tertiary);
  padding: 16px 24px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
}

.thinking-dots {
  display: flex;
  gap: 6px;
}

.thinking-dot {
  width: 8px;
  height: 8px;
  background: #4285f4;
  border-radius: 50%;
  animation: thinking 1.4s ease-in-out infinite;
}

.thinking-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.thinking-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes thinking {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-10px);
    opacity: 1;
  }
}

.thinking-text {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Agent Response Container */
.agent-response {
  background: transparent;
  border: none;
  padding: 0;
  margin: 24px auto;
  max-width: 900px;
  width: 100%;
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
}

.agent-response .message-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
  display: block;
  min-height: 100px;
}

.agent-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 2px solid #4285f4;
}

.agent-header .material-icons {
  font-size: 28px;
  color: #4285f4;
}

.agent-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

/* Agent Status Updates */
.agent-status {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-primary);
  border-left: 3px solid #4285f4;
  border-radius: 6px;
  margin-bottom: 12px;
}

.agent-status .status-icon {
  font-size: 20px;
  color: #4285f4;
}

.status-text {
  font-size: 14px;
  color: var(--text-primary);
}

/* Main Execution Toggle */
.agent-execution-toggle {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  margin-bottom: 16px;
  overflow: hidden;
}

.execution-toggle-header {
  padding: 14px 16px;
  background: var(--bg-tertiary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  user-select: none;
  transition: background 0.2s;
  border-bottom: 1px solid transparent;
}

.agent-execution-toggle.expanded .execution-toggle-header {
  border-bottom-color: var(--border-color);
}

.execution-toggle-header:hover {
  background: var(--bg-hover);
}

.execution-status {
  margin-left: auto;
  font-size: 12px;
  font-weight: 500;
  color: #4285f4;
  padding: 4px 12px;
  background: rgba(66, 133, 244, 0.1);
  border-radius: 12px;
}

.execution-toggle-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.agent-execution-toggle.expanded .execution-toggle-content {
  max-height: 3000px;
  padding: 16px;
}

.agent-execution-toggle.expanded .toggle-arrow {
  transform: rotate(90deg);
}

/* Collapsible Context */
.agent-context-toggle {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  margin-bottom: 12px;
  overflow: hidden;
}

.context-toggle-header,
.plan-toggle-header {
  padding: 12px 16px;
  background: var(--bg-tertiary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  user-select: none;
  transition: background 0.2s;
}

.context-toggle-header:hover,
.plan-toggle-header:hover {
  background: var(--bg-hover);
}

.toggle-arrow {
  font-size: 12px;
  transition: transform 0.2s;
  color: var(--text-secondary);
}

.agent-context-toggle.expanded .toggle-arrow,
.agent-plan-toggle.expanded .toggle-arrow {
  transform: rotate(90deg);
}

.toggle-title {
  flex: 1;
}

.context-toggle-content,
.plan-toggle-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.agent-context-toggle.expanded .context-toggle-content,
.agent-plan-toggle.expanded .plan-toggle-content {
  max-height: 1000px;
  padding: 16px;
}

.context-item {
  font-size: 13px;
  color: var(--text-primary);
  margin-bottom: 8px;
  line-height: 1.6;
}

.context-item strong {
  color: var(--text-primary);
  font-weight: 600;
}

.context-item-list {
  margin-top: 8px;
  padding-left: 12px;
  font-size: 12px;
  color: var(--text-secondary);
}

.context-item-list div {
  margin-bottom: 4px;
}

/* Collapsible Plan */
.agent-plan-toggle {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  margin-bottom: 12px;
  overflow: hidden;
}

.plan-reasoning {
  font-size: 13px;
  color: var(--text-primary);
  padding: 12px;
  background: var(--bg-tertiary);
  border-radius: 6px;
  margin-bottom: 12px;
  line-height: 1.6;
}

.plan-reasoning strong {
  font-weight: 600;
}

.plan-steps {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.plan-step-item {
  display: flex;
  gap: 12px;
  padding: 12px;
  background: var(--bg-tertiary);
  border-radius: 6px;
}

.plan-step-item .step-number {
  width: 28px;
  height: 28px;
  background: #4285f4;
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}

.step-details {
  flex: 1;
}

.step-description {
  font-size: 13px;
  color: var(--text-primary);
  margin-bottom: 6px;
  font-weight: 500;
}

.step-expected {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Agent Steps */
#agentSteps {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

/* Agent Result Container */
#agentResult {
  display: block;
  min-height: 50px;
  margin-top: 16px;
}

/* Generated Content */
.generated-content {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
  animation: fadeInUp 0.3s ease-out;
}

.content-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  font-weight: 600;
  color: var(--text-primary);
  padding-bottom: 12px;
  border-bottom: 2px solid #4285f4;
}

.content-header .material-icons {
  font-size: 20px;
  color: #4285f4;
}

.content-body {
  font-size: 14px;
  line-height: 1.8;
  color: var(--text-primary);
}

.content-body p {
  margin-bottom: 16px;
}

.content-body p:last-child {
  margin-bottom: 0;
}

.content-body strong {
  font-weight: 600;
  color: var(--text-primary);
}

.content-body em {
  font-style: italic;
}

.content-body code.inline-code {
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  color: #4285f4;
}

.content-body pre {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 12px;
  overflow-x: auto;
  margin: 12px 0;
}

.content-body pre code {
  font-family: 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-primary);
}

/* Compact Step Display */
.agent-step-compact {
  padding: 8px 12px;
  border-radius: 6px;
  margin-bottom: 6px;
  transition: all 0.2s;
}

.agent-step-compact.executing {
  background: var(--bg-tertiary);
  border-left: 3px solid #4285f4;
}

.agent-step-compact.completed {
  background: rgba(52, 168, 83, 0.05);
  border-left: 3px solid #34a853;
}

.agent-step-compact.error {
  background: rgba(234, 67, 53, 0.05);
  border-left: 3px solid #ea4335;
}

.step-compact-content {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.step-status {
  font-size: 16px;
  flex-shrink: 0;
}

.agent-step-compact.executing .step-status {
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.agent-step-compact.completed .step-status {
  color: #34a853;
}

.agent-step-compact.error .step-status {
  color: #ea4335;
}

.step-label {
  font-weight: 600;
  color: var(--text-primary);
}

.step-text {
  color: var(--text-secondary);
  flex: 1;
}

.inline-error {
  color: #ea4335;
  font-size: 12px;
  margin-top: 4px;
}

/* Task Complete/Error */
.task-complete,
.task-error {
  display: flex !important;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  margin-top: 12px;
  visibility: visible !important;
  opacity: 1 !important;
}

.task-complete {
  background: rgba(52, 168, 83, 0.08);
  color: #34a853;
  border-left: 3px solid #34a853;
  animation: fadeInScale 0.3s ease-out;
}

.task-error {
  background: rgba(234, 67, 53, 0.08);
  color: #ea4335;
  border-left: 3px solid #ea4335;
  animation: fadeInScale 0.3s ease-out;
}

.task-complete span:first-child,
.task-error span:first-child {
  font-size: 16px;
  flex-shrink: 0;
}

@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Agent Warning */
.agent-warning {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(251, 188, 4, 0.1);
  border-left: 3px solid #fbbc04;
  border-radius: 6px;
  margin-bottom: 12px;
}

.agent-warning .material-icons {
  font-size: 20px;
  color: #fbbc04;
}

.agent-warning span:last-child {
  font-size: 13px;
  color: var(--text-primary);
}

/* Agent Error Message */
.agent-error {
  background: transparent;
  border: none;
  padding: 0;
  margin: 24px auto;
  max-width: 900px;
}

.agent-error .message-content {
  background: linear-gradient(135deg, rgba(234, 67, 53, 0.1), rgba(234, 67, 53, 0.05));
  border: 1px solid #ea4335;
  border-radius: 12px;
  padding: 20px;
}

.error-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  color: #ea4335;
  font-weight: 600;
  font-size: 16px;
}

.error-header .material-icons {
  font-size: 24px;
}

.error-message {
  font-size: 14px;
  color: var(--text-primary);
  padding: 12px;
  background: var(--bg-primary);
  border-radius: 6px;
  font-family: 'Courier New', monospace;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .agent-mode-indicator {
    right: 12px;
    padding: 6px 12px;
  }

  .agent-indicator-text {
    display: none;
  }

  .agent-response,
  .agent-thinking {
    margin: 16px 8px;
  }

  .agent-response .message-content {
    padding: 16px;
  }

  .agent-header {
    font-size: 16px;
  }

  .plan-step {
    flex-direction: column;
    align-items: flex-start;
  }

  .step-description {
    padding-left: 0;
  }
}

/* Dark/Light theme adjustments */
@media (prefers-color-scheme: light) {
  .agent-response .message-content {
    background: #ffffff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  }

  .agent-context,
  .agent-plan {
    background: #f5f5f5;
  }

  .agent-status {
    background: #f5f5f5;
  }

  .thinking-dot {
    background: #1967d2;
  }
}

/* Animations */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.agent-step {
  animation: fadeInUp 0.3s ease-out;
}

.agent-status {
  animation: fadeInUp 0.2s ease-out;
}

/* Accessibility */
.agent-step:focus,
.plan-step:focus {
  outline: 2px solid #4285f4;
  outline-offset: 2px;
}

/* Print styles */
@media print {
  .agent-mode-indicator,
  .agent-thinking {
    display: none;
  }

  .agent-response {
    break-inside: avoid;
  }
}
