@import url("/css/tools.css");

/* Portable Payne - Win32 PE Emulator */
:root {
  --accent: #06b6d4;
}

[data-theme="ayu-mirage"] {
  --accent: #5ccfe6;
}

html, body {
  height: 100dvh;
  overflow: hidden;
}

body {
  display: grid;
  grid-template-rows: 40px 1fr 24px;
  grid-template-columns: minmax(0, 1fr);
}

/* Header */
header {
  height: 40px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 16px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--accent);
  text-decoration: none;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 2px;
  text-transform: uppercase;
  transition: color 0.2s;
}

.logo:hover { color: var(--text-primary); text-decoration: none; }

.logo .icon {
  width: 18px;
  height: 18px;
}

.emulator-info {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 1px;
  color: var(--text-muted);
  text-transform: uppercase;
}

/* Footer */
footer {
  height: 24px;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
}

.quote {
  font-style: italic;
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.6;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Main layout - Flex panels */
main {
  display: flex;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

/* Panels */
.panel {
  flex: var(--size, 1) 1 0;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--bg-base);
}

.panel-header {
  height: 36px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 8px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.panel-content {
  flex: 1;
  overflow: auto;
  padding: 12px;
  font-family: var(--font-mono);
  font-size: 11px;
}

/* Resize handles */
.resize-handle {
  flex: 0 0 1px;
  background: var(--border-subtle);
  cursor: col-resize;
  user-select: none;
  touch-action: none;
  position: relative;
  transition: background 150ms;
}

.resize-handle::after {
  content: "";
  position: absolute;
  inset: 0 -4px;
}

.resize-handle:hover,
.resize-handle[data-state="dragging"] {
  background: var(--text-muted);
  box-shadow: 0 0 6px rgba(250, 250, 250, 0.2);
}

.resize-handle-h {
  flex: 0 0 1px;
  background: var(--border-subtle);
  cursor: row-resize;
  user-select: none;
  touch-action: none;
  position: relative;
  transition: background 150ms;
}

.resize-handle-h::after {
  content: "";
  position: absolute;
  inset: -4px 0;
}

.resize-handle-h:hover,
.resize-handle-h[data-state="dragging"] {
  background: var(--text-muted);
  box-shadow: 0 0 6px rgba(250, 250, 250, 0.2);
}

/* Left panel - Canvas display */
.panel-display {
  --size: 55;
  display: flex;
  flex-direction: column;
  background: var(--bg-base);
}

.canvas-wrapper {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background: linear-gradient(135deg, var(--bg-elevated) 0%, var(--bg-surface) 100%);
  overflow: hidden;
}

#display {
  max-width: 100%;
  max-height: 100%;
  min-width: 0;
  width: auto;
  height: auto;
  image-rendering: pixelated;
  display: block;
}

/* File input overlay */
.file-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  z-index: 10;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.file-label:hover {
  background: var(--bg-surface);
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 0 30px color-mix(in oklch, var(--accent) 15%, transparent);
}

.file-label:active { transform: translate(-50%, -50%) scale(0.98); }
body.loaded .file-label { display: none; }
input[type="file"] { display: none; }

/* Right panel - Inspector area */
.panel-inspector {
  --size: 45;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.inspector-row {
  display: flex;
  flex: 1;
  min-height: 0;
}

.inspector-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-left: 1px solid var(--border-subtle);
}

.inspector-col:first-child {
  border-left: none;
}

/* Subpanels within inspector */
.subpanel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-bottom: 1px solid var(--border-subtle);
}

.subpanel:last-child {
  border-bottom: none;
}

/* Copy button */
.copy-btn {
  background: transparent;
  border: 1px solid var(--border-default);
  border-radius: 4px;
  padding: 4px 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: all 0.2s;
  color: var(--text-muted);
  margin-left: auto;
}

.copy-btn:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
  color: var(--accent);
}

.copy-btn.copied {
  color: #4ade80;
  border-color: #4ade80;
}

.copy-btn .icon {
  width: 14px;
  height: 14px;
}

/* Registers */
.registers {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px 12px;
  padding: 12px;
}

.reg {
  display: flex;
  align-items: center;
  gap: 8px;
}

.reg-name {
  color: var(--text-muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  min-width: 35px;
}

.reg-value {
  color: var(--accent);
  font-weight: 500;
  font-size: 12px;
  font-family: var(--font-mono);
  transition: all 0.2s;
}

.cpu-cycles {
  margin-left: auto;
  font-size: 11px;
  color: var(--accent);
  font-weight: 500;
  font-family: var(--font-mono);
  opacity: 0.8;
}

/* Console logs */
.log {
  display: grid;
  grid-template-columns: 60px 18px 1fr;
  gap: 8px;
  align-items: center;
  padding: 3px 0;
  font-family: var(--font-mono);
  font-size: 11px;
  transition: background 0.15s;
  animation: fadeIn 0.3s ease;
  opacity: 0.8;
}

.log.error, .log.warn, .log.success, .log.info { opacity: 1; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateX(-10px); }
  to { opacity: inherit; transform: translateX(0); }
}

.log:hover { background: rgba(255, 255, 255, 0.02); }

.log-time {
  color: var(--text-muted);
  text-align: right;
  font-size: 10px;
}

.log-icon {
  display: flex;
  justify-content: center;
  align-items: center;
}

.log-icon svg {
  width: 14px;
  height: 14px;
  stroke-width: 2;
  fill: none;
  stroke: currentColor;
}

.log.success .log-icon svg,
.log.error .log-icon svg,
.log.warn .log-icon svg {
  filter: drop-shadow(0 0 3px currentColor);
}

.log-message {
  word-break: break-all;
  line-height: 1.4;
}

.log.error .log-icon { color: #f87171; }
.log.info .log-icon { color: #60a5fa; }
.log.warn .log-icon { color: #fbbf24; }
.log.success .log-icon { color: #4ade80; }
.log.debug .log-icon { color: var(--text-muted); opacity: 0.6; }
.log .log-icon { color: var(--text-secondary); }

/* VFS Tree */
.vfs-entry {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
  position: relative;
}

.vfs-entry:hover {
  background: var(--bg-hover);
  margin: 0 -8px;
  padding: 4px 8px;
  border-radius: 4px;
}

.vfs-entry > .icon-chevron { transition: transform 0.15s; }
.vfs-entry.vfs-expanded > .icon-chevron { transform: rotate(90deg); }

.vfs-children {
  margin-left: 20px;
  display: none;
}

.vfs-children.expanded { display: block; }

.vfs-dir {
  color: var(--accent);
  font-weight: 500;
}

.vfs-file { color: var(--text-secondary); }

.vfs-size {
  margin-left: auto;
  font-size: 10px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* File Activity */
.file-count {
  margin-left: auto;
  font-size: 10px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.file-activity-entry {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  font-size: 11px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-subtle);
}

.file-activity-entry:last-child {
  border-bottom: none;
}

.file-activity-entry .icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.file-activity-entry .file-action-create { color: #22c55e; }
.file-activity-entry .file-action-write { color: #3b82f6; }
.file-activity-entry .file-action-delete { color: #ef4444; }
.file-activity-entry .file-action-copy { color: #f59e0b; }
.file-activity-entry .file-action-mkdir { color: #8b5cf6; }

.file-activity-entry .file-name {
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

.file-activity-entry .file-dir {
  color: var(--text-muted);
  font-size: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.file-activity-entry .file-size {
  margin-left: auto;
  font-size: 10px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  flex-shrink: 0;
}

.file-activity-empty {
  padding: 12px;
  color: var(--text-muted);
  font-size: 11px;
  text-align: center;
}

.file-activity-more {
  padding: 8px;
  color: var(--text-muted);
  font-size: 10px;
  text-align: center;
  border-top: 1px solid var(--border-subtle);
}

/* Icons */
.icon {
  display: block;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-chevron {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* Scrollbars: base.css, globally, at the same 10px this block declared. */

/* Responsive */
@media (max-width: 900px) {
  main {
    flex-direction: column;
  }
  .inspector-row {
    flex-direction: column;
  }
  .resize-handle {
    flex: 0 0 1px;
    cursor: row-resize;
  }
  .resize-handle::after {
    inset: -4px 0;
  }
  .panel-display,
  .panel-inspector {
    --size: 50;
  }
}
