/* ═════════════════════════════════════════════════════════════════════════════
   AI Browser Agent — Dashboard Styles
   Dark glassmorphism theme with vibrant accents and micro-animations
   ═════════════════════════════════════════════════════════════════════════════ */

/* ─── Reset & Base ────────────────────────────────────────────────────────── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-primary: #08080f;
  --bg-secondary: #0f0f1a;
  --bg-card: rgba(255, 255, 255, 0.03);
  --bg-card-hover: rgba(255, 255, 255, 0.06);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(99, 102, 241, 0.3);
  --text-primary: #e4e4e7;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  --accent-start: #6366f1;
  --accent-end: #8b5cf6;
  --accent-glow: rgba(99, 102, 241, 0.15);
  --color-navigate: #60a5fa;
  --color-click: #fbbf24;
  --color-type: #34d399;
  --color-scroll: #a78bfa;
  --color-error: #f87171;
  --color-success: #4ade80;
  --color-ai: #e879f9;
  --color-verify: #2dd4bf;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Cascadia Code', monospace;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Ambient background glow */
body::before {
  content: '';
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(ellipse at 30% 20%, rgba(99, 102, 241, 0.06) 0%, transparent 50%),
              radial-gradient(ellipse at 80% 80%, rgba(139, 92, 246, 0.04) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* ─── Top Bar ─────────────────────────────────────────────────────────────── */
#top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--bg-card);
  backdrop-filter: blur(24px);
  border-bottom: 1px solid var(--border-color);
  position: relative;
  z-index: 10;
  flex-shrink: 0;
}

.top-bar-left, .top-bar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  font-size: 24px;
  filter: drop-shadow(0 0 8px rgba(99, 102, 241, 0.4));
}

.logo-text {
  font-size: 18px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent-start), var(--accent-end));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

.logo-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--accent-start), var(--accent-end));
  color: white;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* ─── Status Indicator ────────────────────────────────────────────────────── */
.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  font-size: 13px;
  font-weight: 500;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  transition: background var(--transition);
}

.status-dot.idle {
  background: var(--text-muted);
}

.status-dot.running {
  background: var(--color-success);
  box-shadow: 0 0 8px var(--color-success);
  animation: pulse 1.5s ease-in-out infinite;
}

.status-dot.complete {
  background: var(--color-navigate);
  box-shadow: 0 0 6px var(--color-navigate);
}

.status-dot.error {
  background: var(--color-error);
  box-shadow: 0 0 8px var(--color-error);
  animation: pulse 1s ease-in-out infinite;
}

.status-dot.paused {
  background: var(--color-click);
  box-shadow: 0 0 8px var(--color-click);
  animation: pulse 2s ease-in-out infinite;
}

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

/* ─── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  letter-spacing: 0.01em;
}

.btn-start {
  background: linear-gradient(135deg, var(--accent-start), var(--accent-end));
  color: white;
  box-shadow: 0 2px 12px rgba(99, 102, 241, 0.3);
}

.btn-start:hover {
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.5);
  transform: translateY(-1px);
}

.btn-start:active {
  transform: translateY(0);
}

.btn-start:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-stop {
  background: rgba(248, 113, 113, 0.15);
  color: var(--color-error);
  border: 1px solid rgba(248, 113, 113, 0.2);
}

.btn-stop:hover:not(:disabled) {
  background: rgba(248, 113, 113, 0.25);
}

.btn-stop:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.btn-icon:hover {
  color: var(--text-primary);
  background: var(--bg-card-hover);
}

/* ─── Main Content ────────────────────────────────────────────────────────── */
#main-content {
  flex: 1;
  display: flex;
  gap: 1px;
  background: var(--border-color);
  overflow: hidden;
  position: relative;
  z-index: 1;
}

.panel {
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
}

#browser-panel {
  flex: 1;
  min-width: 0;
}

#log-panel {
  width: 380px;
  flex-shrink: 0;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.panel-header h2 {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
}

/* ─── View Toggle ─────────────────────────────────────────────────────────── */
.view-toggle {
  display: flex;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  overflow: hidden;
}

.toggle-btn {
  padding: 5px 12px;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  letter-spacing: 0.02em;
}

.toggle-btn.active {
  background: linear-gradient(135deg, var(--accent-start), var(--accent-end));
  color: white;
}

.toggle-btn:not(.active):hover {
  color: var(--text-primary);
  background: var(--bg-card-hover);
}

/* ─── Screenshot Container ────────────────────────────────────────────────── */
.screenshot-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow: hidden;
  position: relative;
}

.screenshot-container.active {
  animation: borderGlow 2s ease-in-out infinite alternate;
}

@keyframes borderGlow {
  0% { box-shadow: inset 0 0 20px rgba(99, 102, 241, 0.05); }
  100% { box-shadow: inset 0 0 30px rgba(99, 102, 241, 0.12); }
}

.screenshot-img {
  max-width: 100%;
  max-height: 100%;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  transition: opacity 0.3s ease;
  object-fit: contain;
}

/* ─── Empty State ─────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 40px;
}

.empty-icon {
  font-size: 56px;
  margin-bottom: 16px;
  filter: grayscale(0.3);
}

.empty-state h3 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.empty-state p {
  font-size: 14px;
  color: var(--text-muted);
  max-width: 400px;
  margin: 0 auto 20px;
  line-height: 1.6;
}

.empty-hints {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.hint-tag {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
  background: var(--accent-glow);
  color: var(--accent-start);
  border: 1px solid rgba(99, 102, 241, 0.2);
  letter-spacing: 0.02em;
}

/* ─── Action Log ──────────────────────────────────────────────────────────── */
.log-container {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  scroll-behavior: smooth;
}

.log-container::-webkit-scrollbar {
  width: 4px;
}

.log-container::-webkit-scrollbar-track {
  background: transparent;
}

.log-container::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 2px;
}

.log-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  font-size: 13px;
  font-style: italic;
}

.log-entry {
  display: flex;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
  background: var(--bg-card);
  border: 1px solid transparent;
  transition: all var(--transition);
  animation: slideIn 0.3s ease-out;
}

.log-entry:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-color);
}

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

.log-entry .log-icon {
  font-size: 14px;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
  padding-top: 1px;
}

.log-entry .log-body {
  flex: 1;
  min-width: 0;
}

.log-entry .log-action {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 2px;
  word-break: break-word;
}

.log-entry .log-reasoning {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
  word-break: break-word;
}

.log-entry .log-time {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  flex-shrink: 0;
  padding-top: 2px;
}

/* Log entry colors */
.log-entry.navigate .log-action { color: var(--color-navigate); }
.log-entry.click .log-action    { color: var(--color-click); }
.log-entry.type .log-action     { color: var(--color-type); }
.log-entry.scroll .log-action   { color: var(--color-scroll); }
.log-entry.error .log-action    { color: var(--color-error); }
.log-entry.success .log-action  { color: var(--color-success); }
.log-entry.ai .log-action       { color: var(--color-ai); }
.log-entry.verify .log-action   { color: var(--color-verify); }
.log-entry.wait .log-action     { color: var(--text-muted); }

.log-entry.error {
  border-color: rgba(248, 113, 113, 0.15);
  background: rgba(248, 113, 113, 0.05);
}

.log-entry.success {
  border-color: rgba(74, 222, 128, 0.15);
  background: rgba(74, 222, 128, 0.05);
}

/* ─── Bottom Bar ──────────────────────────────────────────────────────────── */
#bottom-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 24px;
  background: var(--bg-card);
  backdrop-filter: blur(24px);
  border-top: 1px solid var(--border-color);
  position: relative;
  z-index: 10;
  flex-shrink: 0;
}

.task-input-group {
  flex: 1;
  display: flex;
  gap: 10px;
}

.input-wrapper {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 14px;
  color: var(--text-muted);
  pointer-events: none;
}

#task-input {
  width: 100%;
  padding: 10px 16px 10px 42px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 400;
  color: var(--text-primary);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  outline: none;
  transition: all var(--transition);
}

#task-input:focus {
  border-color: var(--accent-start);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

#task-input::placeholder {
  color: var(--text-muted);
}

#task-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.step-counter {
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--text-muted);
  white-space: nowrap;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
}

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

.toast {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  backdrop-filter: blur(16px);
  animation: toastIn 0.3s ease-out;
  max-width: 400px;
  word-break: break-word;
}

.toast.error {
  background: rgba(248, 113, 113, 0.15);
  color: var(--color-error);
  border: 1px solid rgba(248, 113, 113, 0.25);
}

.toast.success {
  background: rgba(74, 222, 128, 0.15);
  color: var(--color-success);
  border: 1px solid rgba(74, 222, 128, 0.25);
}

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

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

/* ─── Pause Banner ────────────────────────────────────────────────────────── */
.pause-banner {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  z-index: 20;
  animation: slideIn 0.3s ease-out;
}

.pause-content {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  border-radius: var(--radius-md);
  background: rgba(251, 191, 36, 0.1);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(251, 191, 36, 0.3);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

.pause-icon {
  font-size: 28px;
  flex-shrink: 0;
}

.pause-text {
  flex: 1;
}

.pause-text strong {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: var(--color-click);
  margin-bottom: 4px;
}

.pause-text p {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
  margin: 0;
}

.pause-content .btn-start {
  flex-shrink: 0;
  padding: 10px 20px;
  font-size: 14px;
}

/* ─── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  #main-content {
    flex-direction: column;
  }
  #log-panel {
    width: 100%;
    max-height: 250px;
  }
}
