/* AI Maestro V2 — UX Enhancements (Phase 17) */
/* Animations, transitions, responsive, theme toggle */

/* Smooth transitions on all themed elements */
body, .dashboard, .header, .sidebar-skills, .sidebar-timeline,
.center-area, .input-bar, .response-pane, .tab-btn, .skill-btn,
.settings-panel, .history-panel, .files-panel {
  transition: background var(--transition-medium), color var(--transition-medium),
              border-color var(--transition-medium);
}

/* Agent tab animations */
.tab-btn { transition: all var(--transition-fast); }
.tab-btn:hover { transform: translateY(-1px); }
.tab-btn.active { box-shadow: 0 2px 0 0 currentColor; }

/* Pane content fade-in */
.response-pane > * {
  animation: fadeIn 0.2s ease-in;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Timeline entry slide-in */
.timeline-entry {
  animation: slideIn 0.2s ease-out;
}
@keyframes slideIn {
  from { opacity: 0; transform: translateX(10px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Skill button hover effects */
.skill-btn {
  transition: all var(--transition-fast);
  border-radius: 4px;
}
.skill-btn:hover {
  background: var(--color-bg-tertiary, #21262d);
  transform: scale(1.02);
}
.skill-btn:active {
  transform: scale(0.98);
}

/* Submit button pulse when ready */
#submit-btn:not(:disabled) {
  animation: subtlePulse 2s infinite;
}
@keyframes subtlePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(35, 134, 54, 0.4); }
  50% { box-shadow: 0 0 0 4px rgba(35, 134, 54, 0); }
}

/* Routing badge animation */
.routing-badge.visible {
  animation: badgePop 0.3s ease-out;
}
@keyframes badgePop {
  0% { transform: scale(0); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* Media elements — smooth load */
.response-pane img, .response-pane video, .response-pane audio {
  animation: mediaLoad 0.3s ease;
}
@keyframes mediaLoad {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

/* Copy button on code blocks */
.copy-btn {
  position: absolute;
  top: 4px; right: 4px;
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 0.7rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--transition-fast);
}
pre:hover .copy-btn { opacity: 1; }
.copy-btn:hover {
  background: var(--color-accent-link);
  color: #fff;
}

/* Scrollbar styling (dark theme) */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-text-muted); }

/* Thinking block — collapsible reasoning */
.thinking-block {
  border: 1px solid rgba(212, 165, 116, 0.2);
  border-radius: 6px;
  padding: 8px 12px;
  margin: 8px 0;
  background: rgba(212, 165, 116, 0.05);
  font-size: 0.8rem;
  color: var(--color-text-muted);
}
.thinking-block summary {
  cursor: pointer;
  color: var(--color-accent-claude);
  font-weight: 600;
  font-size: 0.75rem;
}
.thinking-block[open] summary { margin-bottom: 8px; }

/* Health status dot */
.health-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #484f58;
  display: inline-block;
  margin-right: 8px;
  transition: background var(--transition-medium);
}
.health-dot.ok { background: var(--color-success); }
.health-dot.degraded { background: #f0883e; }
.health-dot.error { background: var(--color-error); }

/* Typing indicator dots */
.typing-dots::after {
  content: '';
  animation: dots 1.5s steps(4, end) infinite;
}
@keyframes dots {
  0% { content: ''; }
  25% { content: '.'; }
  50% { content: '..'; }
  75% { content: '...'; }
}

/* Agent working spinner */
.agent-spinner {
  display: inline-block;
  animation: spin 1s linear infinite;
  color: var(--color-accent-claude);
  font-size: 1rem;
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Tool status indicator (agent mode) */
.tool-status {
  display: inline-block;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(88, 166, 255, 0.08);
  border-left: 2px solid var(--color-accent-claude);
  animation: toolPulse 1.5s ease-in-out infinite;
}
.tool-status code {
  color: var(--color-accent-link);
  font-size: 0.75rem;
}
@keyframes toolPulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

/* Tool use blocks in agent mode */
.response-pane blockquote {
  border-left: 3px solid var(--color-accent-claude);
  padding: 4px 12px;
  margin: 8px 0;
  background: rgba(212, 165, 116, 0.05);
  border-radius: 0 4px 4px 0;
  font-size: 0.85rem;
}

/* Media card — ChatGPT-style inline preview */
.media-card {
  display: inline-block;
  max-width: 512px;
  background: var(--color-panel);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  overflow: hidden;
  margin: 12px 0;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  transition: transform var(--transition-fast);
}
.media-card:hover { transform: scale(1.01); }
.media-preview {
  width: 100%;
  max-height: 400px;
  object-fit: contain;
  display: block;
  cursor: pointer;
  background: #000;
}
.media-preview:hover { opacity: 0.95; }
.media-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  border-top: 1px solid var(--color-border);
}
.media-download {
  color: var(--color-accent-link);
  text-decoration: none;
  font-weight: 600;
  padding: 2px 8px;
  border: 1px solid var(--color-accent-link);
  border-radius: 4px;
  font-size: 0.75rem;
  transition: all var(--transition-fast);
}
.media-download:hover {
  background: var(--color-accent-link);
  color: #fff;
}

/* Lightbox overlay for full-size image view */
.media-lightbox {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  cursor: zoom-out;
}
.media-lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

/* Mermaid diagram container */
.mermaid {
  background: var(--color-panel);
  border-radius: var(--border-radius);
  padding: 16px;
  margin: 12px 0;
  text-align: center;
  overflow-x: auto;
}
.mermaid svg { max-width: 100%; height: auto; }

/* Mode selector enhancement */
#routing-override {
  background: var(--color-base);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  border-radius: 4px;
  padding: 6px 10px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color var(--transition-fast);
}
#routing-override:focus {
  border-color: #58a6ff;
  box-shadow: 0 0 0 2px rgba(88, 166, 255, 0.15);
  outline: none;
}
#routing-override option { background: var(--color-panel); color: var(--color-text); }

/* Header layout fix — don't overflow */
.header {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
}
.header::-webkit-scrollbar { display: none; }
.header-title {
  font-weight: 700;
  white-space: nowrap;
}

/* Submit button enhancement */
#submit-btn {
  transition: all var(--transition-fast);
}
#submit-btn:hover:not(:disabled) {
  background: #2ea043;
  transform: scale(1.02);
}
#submit-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Responsive — tablet */
@media (max-width: 1200px) {
  .dashboard {
    grid-template-columns: 200px 1fr 240px;
  }
  .sidebar-skills { --sidebar-skills: 200px; }
  .sidebar-timeline { --sidebar-timeline: 240px; }
}

/* Welcome screen */
.welcome-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  padding: 40px;
  animation: fadeIn 0.5s ease;
}
.welcome-tips {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 20px;
}
.tip {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}
.tip code {
  background: var(--color-bg-tertiary);
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 0.8rem;
  color: var(--color-accent-link);
}
.welcome-modes {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
.mode-badge {
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}
.mode-badge.agent { background: rgba(212,165,116,0.15); color: var(--color-accent-claude); }
.mode-badge.coworker { background: rgba(88,166,255,0.15); color: var(--color-accent-link); }
.mode-badge.auto { background: rgba(163,230,53,0.15); color: var(--color-accent-gemini); }

/* Full-body drag overlay */
.drag-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(88, 166, 255, 0.1);
  border: 3px dashed var(--color-accent-link);
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: var(--color-accent-link);
  pointer-events: none;
}

/* Responsive — narrow */
@media (max-width: 900px) {
  .dashboard {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr auto auto;
    grid-template-areas:
      "header"
      "skills"
      "center"
      "timeline"
      "input";
  }
  .sidebar-skills, .sidebar-timeline {
    max-height: 120px;
    overflow-y: auto;
  }
}
