/* ============================================================================
   BartOS — macOS-style terminal on a dark canvas
   ============================================================================ */

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #1a1b26;
  --window-bg: #16161e;
  --titlebar-bg: #1e1f2b;
  --border: #2a2b3d;
  --text: #a9b1d6;
  --text-dim: #565a6e;
  --accent: #7aa2f7;
  --tab-bg: #16161e;
  --tab-active-bg: #1a1b26;
  --dot-close: #ff5f57;
  --dot-minimize: #febc2e;
  --dot-maximize: #28c840;
  --shadow: 0 25px 60px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05);
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  font-family: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ---- Terminal Window ---- */

#terminal-window {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(90vw, 920px);
  height: min(80vh, 600px);
  min-width: 400px;
  min-height: 250px;
  max-width: 100vw;
  max-height: 100vh;
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  overflow: hidden;
  resize: both;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  background: var(--window-bg);
  z-index: 10;
}

/* ---- Title Bar ---- */

#title-bar {
  display: flex;
  align-items: center;
  height: 40px;
  min-height: 40px;
  background: var(--titlebar-bg);
  border-bottom: 1px solid var(--border);
  padding: 0 12px;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}

#title-bar:active {
  cursor: grabbing;
}

#window-controls {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  margin-right: 16px;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  transition: opacity 0.15s;
  cursor: pointer;
}

.dot:hover {
  opacity: 0.8;
}

.dot-close { background: var(--dot-close); }
.dot-minimize { background: var(--dot-minimize); }
.dot-maximize { background: var(--dot-maximize); }

/* ---- Tabs ---- */

#tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
}

#tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  font-size: 12px;
  color: var(--text-dim);
  background: var(--tab-bg);
  border-radius: 6px 6px 0 0;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  color: var(--text);
  background: var(--tab-active-bg);
}

.tab-close {
  font-size: 14px;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.15s;
  cursor: pointer;
}

.tab:hover .tab-close {
  opacity: 0.6;
}

.tab-close:hover {
  opacity: 1 !important;
}

#tab-add {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 18px;
  cursor: pointer;
  padding: 2px 8px;
  line-height: 1;
  transition: color 0.15s;
}

#tab-add:hover {
  color: var(--accent);
}

/* ---- Terminal Container ---- */

#terminal-container {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.terminal-pane {
  position: absolute;
  inset: 0;
  display: none;
  padding: 8px 4px 8px 6px;
}

.terminal-pane.active {
  display: block;
}

.terminal-pane .xterm {
  height: 100%;
}

/* ---- Footer ---- */

#footer {
  position: fixed;
  bottom: 20px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 13px;
  color: var(--text-dim);
  font-family: 'JetBrains Mono', monospace;
  z-index: 1;
}

#footer span {
  color: var(--accent);
  opacity: 0.7;
  cursor: pointer;
  transition: opacity 0.15s;
}

/* ---- Resize handles ---- */

#terminal-window::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: 0;
  width: 16px;
  height: 16px;
  cursor: nwse-resize;
}

/* ---- xterm overrides ---- */

.xterm-viewport::-webkit-scrollbar {
  width: 8px;
}

.xterm-viewport::-webkit-scrollbar-track {
  background: transparent;
}

.xterm-viewport::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

/* ---- Responsive ---- */

@media (max-width: 600px) {
  #terminal-window {
    width: 100vw;
    height: 100vh;
    top: 0;
    left: 0;
    transform: none;
    border-radius: 0;
    border: none;
  }

  #footer {
    display: none;
  }
}
