/* PRE Web GUI — Buttons, inputs, modals, toasts */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

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

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}
.btn-ghost:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.btn-icon {
  padding: 6px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-icon:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.btn-send {
  padding: 6px 10px;
  border-radius: 10px;
  min-width: 36px;
  transition: all 0.15s ease, transform 0.15s ease;
}
.btn-send:active {
  animation: sendPulse 0.3s ease;
}
.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn-danger:hover {
  opacity: 0.85;
}

/* Voice button */
.btn-voice {
  padding: 6px;
  border-radius: 8px;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.btn-voice:hover {
  color: var(--text);
  background: var(--surface-hover);
}
.btn-voice.recording {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.15);
  animation: voicePulse 1.5s ease-in-out infinite;
}
@keyframes voicePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* Escalation toggle (next message routes to eGPU) */
.btn-escalate {
  padding: 6px;
  border-radius: 8px;
  color: var(--text-secondary);
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
}
.btn-escalate:hover:not(:disabled) {
  color: var(--text);
  background: var(--surface-hover);
}
.btn-escalate:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.btn-escalate.armed {
  color: var(--success, #10b981);
  background: rgba(16, 185, 129, 0.15);
  box-shadow: 0 0 0 1px rgba(16, 185, 129, 0.4) inset;
}

/* Panel header */
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-family: 'Calendas Plus', Georgia, serif;
  font-weight: 700;
}

.panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

/* Toast notifications */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.85rem;
  box-shadow: 0 4px 24px var(--shadow);
  animation: toastSlideIn 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
.toast.error {
  border-color: var(--danger);
  background: rgba(248, 113, 113, 0.1);
}
.toast.success {
  border-color: var(--success);
  background: rgba(74, 222, 128, 0.1);
}

/* Confirmation dialog */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  animation: fadeSlideIn 0.2s ease;
}

.confirm-dialog {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  max-width: 480px;
  width: 90%;
  box-shadow: 0 20px 60px var(--shadow);
}

.confirm-title {
  font-family: 'Calendas Plus', Georgia, serif;
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--warning);
}

.confirm-tool {
  font-family: 'SF Mono', monospace;
  font-size: 0.9rem;
  color: var(--primary);
  margin-bottom: 8px;
}

.confirm-args {
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 6px;
  padding: 12px;
  font-size: 0.8rem;
  max-height: 200px;
  overflow: auto;
}
.confirm-args code {
  background: none;
  border: none;
  padding: 0;
}

.confirm-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
}

/* Tool card status indicators */
.tool-card-status.status-done { color: var(--success); }
.tool-card-status.status-skipped { color: var(--warning); }
.tool-card-status.status-running { color: var(--primary); animation: pulse 1s infinite; }

/* Artifact card */
.artifact-card {
  max-width: 800px;
  margin: 12px auto;
  border: 1px solid var(--primary);
  border-radius: 14px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: 0 4px 16px rgba(108, 180, 238, 0.1);
  animation: cardPopIn 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}
.artifact-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--primary-bg);
  border-bottom: 1px solid var(--border);
}
.artifact-card-icon {
  color: var(--primary);
  font-size: 1.1rem;
}
.artifact-card-title {
  font-weight: 600;
  font-size: 0.95rem;
  flex: 1;
}
.artifact-card-type {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.artifact-card-actions {
  padding: 10px 16px;
  display: flex;
  gap: 8px;
}
.artifact-card-share {
  padding: 8px 16px 10px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}
.artifact-share-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.3px;
}
.btn-share {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}
.btn-share:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(167, 139, 250, 0.08);
}
.btn-share-loading {
  opacity: 0.6;
  cursor: wait;
}
.btn-sm {
  padding: 5px 12px;
  font-size: 0.8rem;
  border-radius: 6px;
  text-decoration: none;
}

/* Document download card */
.document-card {
  max-width: 420px;
  margin: 12px auto;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  background: var(--surface);
  animation: cardPopIn 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}
.document-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface-hover);
  border-bottom: 1px solid var(--border);
}
.document-card-icon {
  color: var(--primary);
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.document-card-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.document-card-title {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.document-card-format {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 700;
  letter-spacing: 0.5px;
}
.document-card-actions {
  padding: 10px 16px;
  display: flex;
  gap: 8px;
}

/* Image generation card */
.image-card {
  max-width: 600px;
  margin: 12px 0;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  overflow: hidden;
  animation: cardPopIn 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}
.image-card-preview {
  position: relative;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
}
.image-card-preview img {
  width: 100%;
  display: block;
  border-radius: 12px 12px 0 0;
}
.image-card-footer {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.image-card-prompt {
  font-size: 0.78rem;
  color: var(--text-muted);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.image-card-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* Settings / Connections panel */
.settings-section {
  margin-bottom: 24px;
}
.settings-section-title {
  font-family: 'Calendas Plus', Georgia, serif;
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text);
}

.connection-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 8px;
  background: var(--surface);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.connection-card:hover {
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}
.connection-card.active {
  border-color: var(--success);
}

.connection-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.connection-card-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-hover);
  color: var(--text);
  font-size: 1rem;
  flex-shrink: 0;
}
.connection-card-info {
  flex: 1;
  min-width: 0;
}
.connection-card-name {
  font-weight: 600;
  font-size: 0.9rem;
}
.connection-card-status {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.connection-card-status.connected {
  color: var(--success);
}

.connection-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.connection-input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}
.connection-input-group input {
  width: 100%;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.8rem;
}
.connection-input-group input:focus {
  outline: none;
  border-color: var(--primary);
}
.connection-input-group input::placeholder {
  color: var(--text-muted);
}
.connection-input-row {
  display: flex;
  gap: 6px;
}
.connection-input-row input {
  flex: 1;
}
.connection-input-row .btn {
  flex-shrink: 0;
}

/* ── Toggle switch ── */
.setting-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  margin-bottom: 8px;
  transition: border-color 0.2s ease;
}
.setting-toggle.active {
  border-color: var(--success);
}
.setting-toggle-info {
  flex: 1;
  min-width: 0;
}
.setting-toggle-name {
  font-weight: 600;
  font-size: 0.9rem;
}
.setting-toggle-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
  margin-left: 12px;
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle-switch .slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--border);
  border-radius: 24px;
  transition: background 0.2s ease;
}
.toggle-switch .slider::before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s ease;
}
.toggle-switch input:checked + .slider {
  background: var(--success);
}
.toggle-switch input:checked + .slider::before {
  transform: translateX(20px);
}

/* ── Agent Feed panel ── */
.agent-feed-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 32px 16px;
}
.agent-feed-entry {
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 8px;
  background: var(--surface);
  overflow: hidden;
  transition: border-color 0.2s ease;
}
.agent-feed-entry.running {
  border-color: var(--primary);
}
.agent-feed-entry.completed {
  border-color: var(--success);
}
.agent-feed-entry.failed {
  border-color: var(--danger);
}
.agent-feed-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  cursor: pointer;
}
.agent-feed-header:hover {
  background: var(--surface-hover);
}
.agent-feed-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--text-muted);
}
.agent-feed-entry.running .agent-feed-status {
  background: var(--primary);
  animation: agent-pulse 1s ease-in-out infinite;
}
.agent-feed-entry.completed .agent-feed-status { background: var(--success); }
.agent-feed-entry.failed .agent-feed-status { background: var(--danger); }
.agent-feed-info {
  flex: 1;
  min-width: 0;
}
.agent-feed-task {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.agent-feed-meta {
  display: flex;
  gap: 10px;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.agent-feed-chevron {
  color: var(--text-muted);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}
.agent-feed-entry.expanded .agent-feed-chevron {
  transform: rotate(90deg);
}
.agent-feed-body {
  display: none;
  border-top: 1px solid var(--border);
  padding: 12px 14px;
  font-size: 0.8rem;
}
.agent-feed-entry.expanded .agent-feed-body {
  display: block;
}
.agent-feed-tools {
  list-style: none;
  padding: 0;
  margin: 0 0 10px 0;
}
.agent-feed-tools li {
  padding: 3px 0;
  font-family: 'SF Mono', monospace;
  font-size: 0.75rem;
  color: var(--text-secondary);
}
.agent-feed-tools li::before {
  content: '→ ';
  color: var(--text-muted);
}
.agent-feed-result {
  color: var(--text-secondary);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 300px;
  overflow-y: auto;
}
.agent-feed-result pre {
  margin: 4px 0;
  max-height: 200px;
  overflow: auto;
}
.agent-feed-session-btn {
  margin-top: 8px;
}

/* ── Cron toast notifications ── */
.cron-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 48px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: 10px;
  padding: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  z-index: 10000;
  animation: toast-slide-in 0.3s ease-out;
}
.cron-toast-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  color: var(--primary);
}
.cron-toast-header strong {
  flex: 1;
  font-size: 0.9rem;
  color: var(--text);
}
.cron-toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
.cron-toast-close:hover {
  color: var(--text);
}
.cron-toast-preview {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 12px;
  max-height: 80px;
  overflow: hidden;
}
.cron-toast-open {
  width: 100%;
}
@keyframes toast-slide-in {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ── Argus companion widget ── */
.argus-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9500;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: none;
}
.argus-widget > * { pointer-events: auto; }
.argus-widget.hidden { display: none; }

.argus-fab {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--border);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  transition: transform 0.2s ease, border-color 0.3s ease, box-shadow 0.3s ease;
  position: relative;
  box-shadow: 0 2px 12px var(--shadow);
}
.argus-fab:hover {
  transform: scale(1.1);
  border-color: var(--accent, #a78bfa);
}
.argus-fab--active {
  border-color: var(--accent, #a78bfa);
  animation: argus-pulse 2s infinite;
}

.argus-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent, #a78bfa);
  border: 2px solid var(--surface);
  display: none;
}
.argus-fab--active .argus-badge { display: block; }

.argus-panel {
  width: 340px;
  max-height: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 4px 24px var(--shadow);
  display: none;
  flex-direction: column;
  overflow: hidden;
}
.argus-panel--open {
  display: flex;
  animation: argus-pop-in 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}

.argus-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
}
.argus-panel-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}
.argus-panel-toggle {
  width: 36px;
  height: 20px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-hover);
  cursor: pointer;
  position: relative;
  transition: background 0.2s ease;
}
.argus-panel-toggle.active {
  background: var(--accent, #a78bfa);
  border-color: var(--accent, #a78bfa);
}
.argus-panel-toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: white;
  transition: transform 0.2s ease;
}
.argus-panel-toggle.active::after {
  transform: translateX(16px);
}

.argus-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.argus-reaction {
  padding: 10px 14px;
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  animation: argus-reaction-in 0.3s ease;
}
.argus-reaction:last-child { border-bottom: none; }
.argus-reaction-content {
  margin-bottom: 4px;
}
.argus-reaction-meta {
  font-size: 0.7rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.argus-reaction-trigger {
  background: var(--surface-hover);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.68rem;
}

.argus-empty {
  padding: 24px 14px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

@keyframes argus-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(167, 139, 250, 0.4); }
  50% { box-shadow: 0 0 0 10px rgba(167, 139, 250, 0); }
}
@keyframes argus-pop-in {
  from { opacity: 0; transform: translateY(8px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes argus-reaction-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* (#6c) Boosted reactions — cross-event pattern recognition */
.argus-reaction--boosted {
  border-left: 2px solid var(--accent, #a78bfa);
  padding-left: 12px;
}

/* (#7) Thinking indicator */
.argus-thinking {
  padding: 10px 14px;
  font-size: 0.82rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 2px;
  animation: argus-reaction-in 0.3s ease;
}
.argus-thinking-text {
  opacity: 0.7;
}
.argus-thinking-dots span {
  animation: argus-dot-bounce 1.4s infinite;
  display: inline-block;
}
.argus-thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.argus-thinking-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes argus-dot-bounce {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* (#8) Reply to Argus */
.argus-reply-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.68rem;
  cursor: pointer;
  padding: 0 4px;
  margin-left: auto;
  opacity: 0;
  transition: opacity 0.2s ease, color 0.2s ease;
}
.argus-reaction:hover .argus-reply-btn {
  opacity: 1;
}
.argus-reply-btn:hover {
  color: var(--accent, #a78bfa);
}

.argus-reply-input-wrap {
  padding: 6px 0;
}
.argus-reply-input {
  width: 100%;
  padding: 5px 8px;
  font-size: 0.78rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-hover);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s ease;
}
.argus-reply-input:focus {
  border-color: var(--accent, #a78bfa);
}
.argus-reply-input:disabled {
  opacity: 0.6;
}

.argus-reply-thread {
  margin: 6px 0 4px 0;
  padding-left: 10px;
  border-left: 2px solid var(--border);
  font-size: 0.78rem;
}
.argus-reply-user {
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: 2px;
}
.argus-reply-response {
  color: var(--text);
  line-height: 1.4;
}
