/* === Existing animations === */
@keyframes pulse-record {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
.recording-pulse { animation: pulse-record 1.5s ease-in-out infinite; }

@keyframes pulse-dot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.7; }
}
.status-dot-up { animation: pulse-dot 2s ease-in-out infinite; }

.tab-active {
  border-bottom: 2px solid #6366f1;
  color: #818cf8;
}

.chat-bubble-user { background: #4f46e5; color: white; border-radius: 1rem 1rem 0.25rem 1rem; }
.chat-bubble-assistant { background: #374151; color: #e5e7eb; border-radius: 1rem 1rem 1rem 0.25rem; }

.toast {
  animation: slide-in 0.3s ease-out, fade-out 0.3s ease-in 3.7s forwards;
}
@keyframes slide-in { from { transform: translateX(100%); } to { transform: translateX(0); } }
@keyframes fade-out { from { opacity: 1; } to { opacity: 0; } }

/* === Fade slide up animations (stagger) === */
@keyframes fade-slide-up {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.animate-in { animation: fade-slide-up 0.5s ease-out both; }
.animate-in-delay-1 { animation: fade-slide-up 0.5s ease-out 0.1s both; }
.animate-in-delay-2 { animation: fade-slide-up 0.5s ease-out 0.2s both; }
.animate-in-delay-3 { animation: fade-slide-up 0.5s ease-out 0.3s both; }
.animate-in-delay-4 { animation: fade-slide-up 0.5s ease-out 0.4s both; }
.animate-in-delay-5 { animation: fade-slide-up 0.5s ease-out 0.5s both; }

/* === Gradient text === */
.gradient-text {
  background: linear-gradient(135deg, #818cf8, #6366f1, #4f46e5);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* === Glow effects === */
.glow-indigo { box-shadow: 0 0 20px rgba(99, 102, 241, 0.3); }
.glow-green { box-shadow: 0 0 15px rgba(34, 197, 94, 0.3); }
.glow-red { box-shadow: 0 0 15px rgba(239, 68, 68, 0.3); }

/* === Recording ring (concentric pulse) === */
@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5); }
  70% { box-shadow: 0 0 0 20px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}
.recording-ring { animation: pulse-ring 1.5s infinite; }

/* === Pipeline visualization === */
.pipeline-stage {
  transition: all 0.4s ease-out;
  background: #1f2937;
  border: 1px solid #374151;
}
.pipeline-stage.active {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border-color: #818cf8;
  box-shadow: 0 0 20px rgba(99, 102, 241, 0.4);
}
.pipeline-stage.complete {
  background: linear-gradient(135deg, #059669, #10b981);
  border-color: #34d399;
  box-shadow: 0 0 15px rgba(16, 185, 129, 0.3);
}

@keyframes flow {
  from { background-position: 0 0; }
  to { background-position: 30px 0; }
}
.pipeline-connector {
  height: 2px;
  background: repeating-linear-gradient(90deg, #6366f1, #6366f1 8px, transparent 8px, transparent 16px);
  background-size: 30px 2px;
}
.pipeline-connector.active {
  animation: flow 0.8s linear infinite;
}

/* === Sound wave bars === */
@keyframes sound-wave {
  0%, 100% { transform: scaleY(0.3); }
  50% { transform: scaleY(1); }
}
.sound-bar {
  animation: sound-wave 0.8s ease-in-out infinite;
  transform-origin: bottom;
}
.sound-bar:nth-child(2) { animation-delay: 0.1s; }
.sound-bar:nth-child(3) { animation-delay: 0.2s; }
.sound-bar:nth-child(4) { animation-delay: 0.3s; }
.sound-bar:nth-child(5) { animation-delay: 0.4s; }

/* === Typing dots === */
@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-4px); }
}
.typing-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #6366f1;
  animation: typing-bounce 1.4s infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

/* === Shake (error) === */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
  20%, 40%, 60%, 80% { transform: translateX(4px); }
}
.shake { animation: shake 0.5s ease-in-out; }

/* === Card hover lift === */
.card-hover {
  transition: transform 0.2s ease-out, box-shadow 0.2s ease-out, border-color 0.2s ease-out;
}
.card-hover:hover {
  transform: translateY(-4px);
  box-shadow: 0 0 30px rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.3);
}

/* === Number counter transition === */
.counter-animate { transition: all 0.3s ease-out; }

/* === Gradient mesh background (for landing/login) === */
@keyframes gradient-shift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
.gradient-mesh {
  background: linear-gradient(-45deg, #111827, #0f172a, #1e1b4b, #111827, #0c1220);
  background-size: 400% 400%;
  animation: gradient-shift 15s ease infinite;
}

/* === Terminal cursor blink === */
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}
.terminal-cursor {
  display: inline-block;
  width: 8px;
  height: 16px;
  background: #22c55e;
  animation: blink 1s step-end infinite;
  vertical-align: middle;
  margin-left: 2px;
}

/* === Sidebar nav transitions === */
.nav-link {
  transition: all 0.15s ease-out;
}
.nav-link:hover {
  padding-left: 1rem;
}

/* === Scrollbar styling === */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #111827; }
::-webkit-scrollbar-thumb { background: #374151; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #4b5563; }

/* === Spin animation (for loaders) === */
@keyframes spin { to { transform: rotate(360deg); } }
.animate-spin { animation: spin 1s linear infinite; }

/* === Mobile sidebar overlay === */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 35;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.sidebar-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

/* === Mobile header === */
.mobile-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  background: #111827;
  border-bottom: 1px solid #1f2937;
  padding: 0.5rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
@media (min-width: 768px) {
  .mobile-header { display: none; }
}

/* === Hamburger === */
.hamburger {
  width: 24px;
  height: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
  padding: 0;
  border: none;
  background: none;
}
.hamburger span {
  display: block;
  width: 100%;
  height: 2px;
  background: #9ca3af;
  border-radius: 2px;
  transition: all 0.3s ease;
}
.hamburger.active span:nth-child(1) { transform: translateY(8px) rotate(45deg); }
.hamburger.active span:nth-child(2) { opacity: 0; }
.hamburger.active span:nth-child(3) { transform: translateY(-8px) rotate(-45deg); }

/* === Responsive nav hover fix (no hover shift on mobile) === */
@media (max-width: 767px) {
  .nav-link:hover { padding-left: 0.75rem; }
}

/* === Searchable select dropdown === */
.searchable-wrap { position: relative; }
.searchable-trigger {
  cursor: pointer;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3E%3C/svg%3E");
  background-position: right 0.5rem center;
  background-repeat: no-repeat;
  background-size: 1.25rem;
  padding-right: 2rem;
}
.searchable-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  min-width: 280px;
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 0.75rem;
  box-shadow: 0 20px 40px rgba(0,0,0,0.5);
  z-index: 50;
  overflow: hidden;
}
.searchable-panel input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: #111827;
  border: none;
  border-bottom: 1px solid #374151;
  color: white;
  font-size: 0.8125rem;
  outline: none;
}
.searchable-list {
  max-height: 240px;
  overflow-y: auto;
}
.searchable-group {
  padding: 0.375rem 0.75rem 0.25rem;
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6b7280;
  background: #111827;
  position: sticky;
  top: 0;
}
.searchable-opt {
  padding: 0.4rem 0.75rem;
  font-size: 0.8125rem;
  color: #d1d5db;
  cursor: pointer;
  transition: background 0.1s;
}
.searchable-opt:hover, .searchable-opt.focused { background: #374151; color: white; }
.searchable-opt.selected { color: #818cf8; }
.searchable-no-match {
  padding: 1rem;
  text-align: center;
  font-size: 0.75rem;
  color: #6b7280;
}

/* === Command Palette === */
.cmd-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
  animation: fade-in 0.15s ease;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.cmd-palette {
  width: 90%;
  max-width: 520px;
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 1rem;
  box-shadow: 0 25px 60px rgba(0,0,0,0.6);
  overflow: hidden;
}
.cmd-input {
  width: 100%;
  padding: 0.875rem 1rem;
  background: transparent;
  border: none;
  border-bottom: 1px solid #374151;
  color: white;
  font-size: 0.9375rem;
  outline: none;
}
.cmd-input::placeholder { color: #6b7280; }
.cmd-results {
  max-height: 320px;
  overflow-y: auto;
  padding: 0.375rem;
}
.cmd-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: background 0.1s;
  font-size: 0.8125rem;
  color: #d1d5db;
}
.cmd-item:hover, .cmd-item.focused { background: #374151; color: white; }
.cmd-item .cmd-icon {
  width: 1.25rem;
  height: 1.25rem;
  color: #6b7280;
  flex-shrink: 0;
}
.cmd-item .cmd-shortcut {
  margin-left: auto;
  font-size: 0.625rem;
  color: #4b5563;
  background: #111827;
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  font-family: monospace;
}
.cmd-section {
  padding: 0.375rem 0.75rem 0.25rem;
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #4b5563;
}
.cmd-footer {
  border-top: 1px solid #374151;
  padding: 0.5rem 0.75rem;
  display: flex;
  gap: 1rem;
  font-size: 0.625rem;
  color: #4b5563;
}
.cmd-footer kbd {
  background: #111827;
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  font-family: monospace;
  font-size: 0.625rem;
}

/* === Log error row highlight === */
.log-row-error { background: rgba(239, 68, 68, 0.05); }
.log-row-error:hover { background: rgba(239, 68, 68, 0.1) !important; }

/* === Log detail expansion === */
.log-detail {
  animation: fade-slide-up 0.2s ease-out;
}
.log-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
}

/* === Onboarding checklist === */
.onboard-step {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
  font-size: 0.8125rem;
  color: #9ca3af;
}
.onboard-check {
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  border: 2px solid #374151;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.3s;
}
.onboard-check.done {
  background: #059669;
  border-color: #059669;
}
.onboard-check.done svg { display: block; }

/* === Quick action buttons === */
.quick-action {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.875rem;
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 0.5rem;
  font-size: 0.75rem;
  color: #9ca3af;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.quick-action:hover {
  background: #374151;
  border-color: #4b5563;
  color: white;
}

/* === Settings card collapse === */
.settings-header { cursor: pointer; user-select: none; border-radius: 0.75rem; }
.settings-header:hover { background: rgba(99, 102, 241, 0.05); }
.settings-body {
  transition: max-height 0.35s ease, opacity 0.2s ease, padding 0.3s ease;
  overflow: hidden;
}
.settings-body.collapsed { max-height: 0 !important; opacity: 0; padding-top: 0 !important; padding-bottom: 0 !important; }
.settings-summary { transition: opacity 0.2s; }
.settings-chevron { transition: transform 0.25s ease; }
.settings-chevron.open { transform: rotate(180deg); }

/* === Dirty state === */
.settings-dirty { border-color: rgba(99, 102, 241, 0.5) !important; }
.settings-dirty .save-btn { animation: pulse-save 2s ease-in-out infinite; }
@keyframes pulse-save {
  0%, 100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.4); }
  50% { box-shadow: 0 0 0 6px rgba(99, 102, 241, 0); }
}

/* === Eye toggle (API key visibility) === */
.apikey-wrap { position: relative; }
.apikey-wrap input { padding-right: 2.25rem; }
.eye-toggle {
  position: absolute; right: 0.5rem; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: #6b7280; cursor: pointer; padding: 0.25rem;
}
.eye-toggle:hover { color: #9ca3af; }
