.terminal-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background-color: var(--terminal-background, #1e1e1e);
  color: var(--terminal-foreground, #d4d4d4);
  font-family: var(--terminal-font-family, monospace);
  font-size: var(--terminal-font-size, 14px);
  line-height: var(--terminal-line-height, 1.2);
  padding: 10px;
}

.terminal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 10px;
  background-color: var(--terminal-background, #1e1e1e);
  border-bottom: 1px solid var(--terminal-foreground, #d4d4d4);
}

.terminal-title {
  font-weight: bold;
}

.terminal-controls {
  display: flex;
  gap: 10px;
}

.terminal-controls button {
  padding: 5px 10px;
  background-color: var(--terminal-background, #1e1e1e);
  color: var(--terminal-foreground, #d4d4d4);
  border: 1px solid var(--terminal-foreground, #d4d4d4);
  border-radius: 3px;
  cursor: pointer;
}

.terminal-controls button:hover {
  background-color: var(--terminal-foreground, #d4d4d4);
  color: var(--terminal-background, #1e1e1e);
}

.terminal-wrapper {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.terminal {
  font-family: var(--terminal-font-family, "Fira Code", "DejaVu Sans Mono", "Menlo", "Monaco", "Courier New", monospace);
  font-size: var(--terminal-font-size, 14px);
  line-height: var(--terminal-line-height, 1.2);
  background-color: var(--terminal-background, #000000);
  color: var(--terminal-foreground, #ffffff);
  padding: 10px;
  position: relative;
  overflow: hidden;
  white-space: pre;
  tab-size: 8;
  user-select: text;
  will-change: transform;
  transform: translateZ(0);
  backface-visibility: hidden;
}

/* Screen and scrollback */
.screen, .scrollback {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  white-space: pre;
  will-change: transform;
  transform: translateZ(0);
}

.scrollback {
  opacity: 0.7;
}

/* Rows */
.row {
  position: absolute;
  white-space: pre;
  height: var(--terminal-line-height, 1.2em);
  will-change: transform;
  transform: translateZ(0);
}

/* Cells */
.cell {
  position: absolute;
  display: inline-block;
  width: 1ch;
  height: var(--terminal-line-height, 1.2em);
  text-align: center;
  vertical-align: middle;
  will-change: transform;
  transform: translateZ(0);
}

/* Cursor styles */
.cursor-block {
  position: absolute;
  width: 1ch;
  height: var(--terminal-line-height, 1.2em);
  background-color: var(--terminal-cursor-color, #ffffff);
  opacity: 0.7;
  z-index: 1;
}

.cursor-underline {
  position: absolute;
  width: 1ch;
  height: 2px;
  background-color: var(--terminal-cursor-color, #ffffff);
  bottom: 0;
  z-index: 1;
}

.cursor-bar {
  position: absolute;
  width: 2px;
  height: var(--terminal-line-height, 1.2em);
  background-color: var(--terminal-cursor-color, #ffffff);
  z-index: 1;
}

.cursor-block.blink,
.cursor-underline.blink,
.cursor-bar.blink {
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 0; }
}

/* Selection */
.selection {
  position: absolute;
  background-color: var(--terminal-selection-color, rgba(255, 255, 255, 0.2));
  z-index: 0;
  pointer-events: none;
}

/* Text attributes */
.bold {
  font-weight: bold;
}

.underline {
  text-decoration: underline;
}

.italic {
  font-style: italic;
}

.reverse {
  background-color: currentColor;
  color: var(--terminal-background, #000000);
}

/* Standard colors */
.fg-black { color: var(--terminal-black, #000000); }
.fg-red { color: var(--terminal-red, #cd0000); }
.fg-green { color: var(--terminal-green, #00cd00); }
.fg-yellow { color: var(--terminal-yellow, #cdcd00); }
.fg-blue { color: var(--terminal-blue, #0000cd); }
.fg-magenta { color: var(--terminal-magenta, #cd00cd); }
.fg-cyan { color: var(--terminal-cyan, #00cdcd); }
.fg-white { color: var(--terminal-white, #e5e5e5); }

.bg-black { background-color: var(--terminal-black, #000000); }
.bg-red { background-color: var(--terminal-red, #cd0000); }
.bg-green { background-color: var(--terminal-green, #00cd00); }
.bg-yellow { background-color: var(--terminal-yellow, #cdcd00); }
.bg-blue { background-color: var(--terminal-blue, #0000cd); }
.bg-magenta { background-color: var(--terminal-magenta, #cd00cd); }
.bg-cyan { background-color: var(--terminal-cyan, #00cdcd); }
.bg-white { background-color: var(--terminal-white, #e5e5e5); }

/* Bright colors */
.fg-bright-black { color: var(--terminal-bright-black, #7f7f7f); }
.fg-bright-red { color: var(--terminal-bright-red, #ff0000); }
.fg-bright-green { color: var(--terminal-bright-green, #00ff00); }
.fg-bright-yellow { color: var(--terminal-bright-yellow, #ffff00); }
.fg-bright-blue { color: var(--terminal-bright-blue, #0000ff); }
.fg-bright-magenta { color: var(--terminal-bright-magenta, #ff00ff); }
.fg-bright-cyan { color: var(--terminal-bright-cyan, #00ffff); }
.fg-bright-white { color: var(--terminal-bright-white, #ffffff); }

.bg-bright-black { background-color: var(--terminal-bright-black, #7f7f7f); }
.bg-bright-red { background-color: var(--terminal-bright-red, #ff0000); }
.bg-bright-green { background-color: var(--terminal-bright-green, #00ff00); }
.bg-bright-yellow { background-color: var(--terminal-bright-yellow, #ffff00); }
.bg-bright-blue { background-color: var(--terminal-bright-blue, #0000ff); }
.bg-bright-magenta { background-color: var(--terminal-bright-magenta, #ff00ff); }
.bg-bright-cyan { background-color: var(--terminal-bright-cyan, #00ffff); }
.bg-bright-white { background-color: var(--terminal-bright-white, #ffffff); }

/* Special characters */
.cell:empty::before {
  content: " ";
}

.cell[data-char="\t"]::before {
  content: "→";
  opacity: 0.5;
}

.cell[data-char=" "]::before {
  content: "·";
  opacity: 0.3;
}

/* Performance optimizations */
.terminal {
  contain: content;
  content-visibility: auto;
}

.screen, .scrollback {
  contain: content;
  content-visibility: auto;
}

.row {
  contain: content;
  content-visibility: auto;
}

.cell {
  contain: content;
  content-visibility: auto;
}

/* Responsive design */
@media (max-width: 768px) {
  .terminal {
    font-size: calc(var(--terminal-font-size, 14px) * 0.9);
  }
}

@media (max-width: 480px) {
  .terminal {
    font-size: calc(var(--terminal-font-size, 14px) * 0.8);
  }
}

.terminal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 10px;
  background-color: var(--terminal-background, #1e1e1e);
  border-top: 1px solid var(--terminal-foreground, #d4d4d4);
}

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

.status-connected {
  color: var(--terminal-green, #00cd00);
}

.status-disconnected {
  color: var(--terminal-red, #cd0000);
}

.terminal-dimensions {
  font-size: 12px;
  opacity: 0.7;
} 