/* ==========================================================================
   Console Panel
   Slide-up panel with log entries, toolbar, and command input.
   All values sourced from tokens.css — zero hardcoded colors or keyframes.
   ========================================================================== */

/* --- 1. Console Panel --- */

.console-panel {
  position: fixed;
  bottom: 0;
  left: var(--sidebar-width);
  right: 0;
  height: 0;
  background: var(--bg);
  border-top: 2px solid transparent;
  display: flex;
  flex-direction: column;
  z-index: var(--z-console);
  transition: height var(--duration-normal) var(--ease-default),
              border-color var(--duration-normal) var(--ease-default);
  overflow: hidden;
}

.console-panel.open {
  height: var(--console-height);
  border-top-color: var(--accent);
}

/* --- 2. Console Toolbar --- */

.console-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-1-5) var(--space-3);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  min-height: 44px;
}

.console-toolbar-left {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.console-toolbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.console-title {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
}

.console-status {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  padding: var(--space-0-5) var(--space-2);
  border-radius: var(--radius-full);
  background: var(--bg-surface-hover);
  color: var(--text-muted);
}

.console-status.connected {
  background: var(--success-subtle);
  color: var(--success);
}

.console-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: var(--space-2) var(--space-2);
  min-height: 44px;
  min-width: 44px;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-family: var(--font-mono);
  display: flex;
  align-items: center;
  gap: var(--space-1);
  transition: background var(--duration-fast), color var(--duration-fast);
}

.console-btn:hover {
  background: var(--bg-surface-hover);
  color: var(--text);
}

.console-btn.active {
  background: var(--accent);
  color: var(--text-inverse);
}

/* --- 3. Console Output --- */

.console-output {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
  color: var(--text);
  scroll-behavior: smooth;
  background: var(--bg);
}

.console-output::-webkit-scrollbar {
  width: 6px;
}

.console-output::-webkit-scrollbar-track {
  background: transparent;
}

.console-output::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: var(--radius-full);
}

/* --- 4. Console Entries --- */

.console-entry {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-px) 0;
  word-break: break-all;
}

.console-entry .ts {
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  flex-shrink: 0;
  user-select: none;
}

.console-entry .level {
  flex-shrink: 0;
  width: 40px;
  text-align: right;
  user-select: none;
}

.console-entry .level.info,
.console-entry .level.log {
  color: var(--info);
}

.console-entry .level.warn {
  color: var(--warning);
}

.console-entry .level.error {
  color: var(--danger);
}

.console-entry .level.debug {
  color: var(--text-muted);
}

.console-entry .text {
  flex: 1;
  white-space: pre-wrap;
}

.console-entry.warn .text {
  color: var(--warning);
}

.console-entry.error .text {
  color: var(--danger);
}

.console-entry.cmd-result .text {
  color: var(--success);
}

.console-entry.cmd-input .text {
  color: var(--accent);
}

/* --- 5. Console Input --- */

.console-input-area {
  display: flex;
  align-items: center;
  padding: var(--space-1-5) var(--space-3);
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.console-prompt {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--accent);
  margin-right: var(--space-2);
  user-select: none;
  font-weight: 600;
}

.console-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  caret-color: var(--accent);
}

.console-input::placeholder {
  color: var(--text-muted);
}

/* --- 6. Maximized State --- */

.console-panel.maximized {
  height: calc(100vh - var(--topbar-height));
  height: calc(100dvh - var(--topbar-height));
}

/* --- 7. Console Badge --- */

.console-toggle-btn {
  position: relative;
}

.console-badge,
.console-toggle-btn .badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: var(--space-2);
  height: var(--space-2);
  background: var(--success);
  border-radius: var(--radius-full);
  display: none;
}

.console-badge.active,
.console-toggle-btn .badge.active {
  display: block;
}

/* --- 8. Console System Messages --- */

.console-system-msg {
  color: var(--text-muted);
  font-style: italic;
}

/* --- 9. Responsive --- */

@media (max-width: 768px) {
  .console-panel {
    left: 0;
  }
  /* Leave more chat visible on phones — 45dvh instead of the 340px desktop
     default which swallows most of a 667px screen after topbar/input. */
  .console-panel.open {
    height: 45dvh;
    /* Respect the home indicator so the command input isn't under it. */
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
}
