/* App CSS - Uses theme.css variables for consistency */
/* These local vars map to theme.css for backward compatibility */
:root {
  --bg: var(--color-bg-primary, #0a0a0f);
  --fg: var(--text-primary, #f4f4f8);
  --muted: var(--text-muted, #8b8b9e);
  --card: var(--color-bg-secondary, #12121a);
  --accent: var(--accent-primary, #00d2ff);
}

* {
  box-sizing: border-box;
}

/* Main app area */
.app-main {
  min-height: calc(100vh - 60px);
  padding-top: var(--space-6, 24px);
}

/* Links use theme accent */
a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--accent-secondary, #3a7bd5);
  text-decoration: underline;
}

.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 16px;
}

/* Header/Topbar - Unified with admin style */
.topbar {
  background: var(--glass-bg, rgba(255, 255, 255, 0.02));
  border-bottom: 1px solid var(--glass-border, rgba(255, 255, 255, 0.08));
  backdrop-filter: blur(var(--glass-blur, 20px));
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar .container {
  max-width: 1400px;
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3, 12px) 0;
  gap: var(--space-4, 16px);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-2, 8px);
  font-weight: 700;
  font-size: var(--font-size-lg, 1.125rem);
  color: var(--text-primary, #f4f4f8);
  letter-spacing: 0.5px;
  text-decoration: none;
}

.brand:hover {
  text-decoration: none;
  color: var(--accent-primary, #00d2ff);
}

.brand-icon {
  font-size: 1.25rem;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: var(--space-4, 16px);
}

.nav-links a {
  color: var(--text-secondary, #c4c4d4);
  font-size: var(--font-size-sm, 0.875rem);
  font-weight: 500;
  padding: var(--space-2, 8px) var(--space-3, 12px);
  border-radius: var(--radius-md, 8px);
  transition: all 0.2s ease;
}

.nav-links a:hover {
  color: var(--text-primary, #f4f4f8);
  background: var(--glass-bg-hover, rgba(255, 255, 255, 0.05));
  text-decoration: none;
}

.nav-links a.active {
  color: var(--accent-primary, #00d2ff);
  background: rgba(0, 210, 255, 0.1);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3, 12px);
}

.user-label {
  color: var(--text-muted, #8b8b9e);
  font-size: var(--font-size-sm, 0.875rem);
}

/* Button sizes for nav */
.btn-sm {
  padding: var(--space-2, 8px) var(--space-4, 16px);
  font-size: var(--font-size-sm, 0.875rem);
}

.flash {
  margin: 12px 0;
  padding: 10px 12px;
  background: rgba(58, 122, 254, 0.15);
  border: 1px solid rgba(58, 122, 254, 0.3);
  border-radius: 8px;
}

.card {
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 14px;
  margin: 12px 0;
}

.card h2 {
  margin: 0 0 8px;
  font-size: 18px;
}

.small {
  color: var(--muted);
  font-size: 13px;
}

.warning {
  color: #ffb3b3;
  border-left: 3px solid #ff7a7a;
  padding-left: 8px;
}

input,
textarea,
select,
button {
  width: 100%;
  padding: 10px 10px;
  margin: 6px 0 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(0, 0, 0, 0.25);
  color: var(--fg);
}

textarea {
  min-height: 320px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

button {
  background: var(--accent);
  border: none;
  cursor: pointer;
  font-weight: 700;
}

button:hover {
  filter: brightness(1.05);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding: 10px 8px;
  text-align: left;
  font-size: 14px;
}

.footer {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  margin-top: 40px;
  color: var(--muted);
}

.console-layout {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.console-column {
  flex: 1 1 0;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  padding: 10px;
  min-width: 220px;
}

.console-column h4 {
  margin: 0 0 8px;
  font-size: 15px;
}

.console-wide {
  flex: 2 1 0;
}

.console-stream {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 13px;
  background: rgba(0, 0, 0, 0.35);
  padding: 10px;
  min-height: 220px;
  max-height: 360px;
  overflow-y: auto;
  border-radius: 8px;
}

/* Console Event Cards */
.console-event {
  margin-bottom: 10px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  transition: all 0.2s ease;
}

.console-event:hover {
  background: rgba(255, 255, 255, 0.05);
}

.console-event-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.console-event-icon {
  font-size: 14px;
}

.console-event-header strong {
  font-size: 13px;
  color: var(--accent);
  flex: 1;
}

.console-event-badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 700;
  text-transform: uppercase;
}

.console-event-badge--success {
  background: rgba(34, 197, 94, 0.2);
  color: #22c55e;
}

.console-event-badge--error {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}

.console-event-badge--pending {
  background: rgba(234, 179, 8, 0.2);
  color: #eab308;
}

.console-event-badge--info {
  background: rgba(59, 130, 246, 0.2);
  color: #3b82f6;
}

.console-event-body {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  word-break: break-word;
}

/* Event type borders */
.console-event--transcript {
  border-left: 3px solid #3b82f6;
}

.console-event--tool_call {
  border-left: 3px solid #eab308;
}

.console-event--tool_result {
  border-left: 3px solid #22c55e;
}

.console-event--validation {
  border-left: 3px solid #a855f7;
}

.console-event--execution {
  border-left: 3px solid #f97316;
}

.console-event--error {
  border-left: 3px solid #ef4444;
}

.console-event--connection {
  border-left: 3px solid #22c55e;
}

@media (max-width: 840px) {
  .nav {
    flex-wrap: wrap;
    gap: 8px;
  }

  .nav a {
    margin-left: 0;
  }

  .brand {
    width: 100%;
  }
}

@media (max-width: 720px) {
  .container {
    padding: 12px;
  }

  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }

  th,
  td {
    padding: 8px 6px;
  }

  input,
  textarea,
  select,
  button {
    font-size: 16px;
  }

  .card {
    padding: 12px;
  }
}
