/* =========================================================
   Browser VM IDE
   VS Code-inspired dark interface
   ========================================================= */

:root {
  --bg: #1e1e1e;
  --bg-dark: #181818;
  --bg-darker: #141414;

  --sidebar: #181818;
  --sidebar-hover: #252526;

  --toolbar: #181818;
  --tab: #1e1e1e;
  --tab-active: #1e1e1e;

  --border: #2d2d2d;

  --text: #cccccc;
  --text-muted: #858585;
  --text-bright: #ffffff;

  --blue: #007acc;
  --blue-hover: #168bd2;

  --green: #3fb950;
  --red: #f85149;

  --button: #2d2d2d;
  --button-hover: #3a3a3a;

  --terminal: #111111;

  --toolbar-height: 46px;
  --sidebar-width: 220px;
  --terminal-height: 260px;
}

/* =========================================================
   Reset
   ========================================================= */

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;

  background: var(--bg);
  color: var(--text);

  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica,
    Arial, sans-serif;
}

button {
  font-family: inherit;
}

/* =========================================================
   Main application
   ========================================================= */

#app {
  display: flex;
  flex-direction: column;

  width: 100%;
  height: 100%;

  background: var(--bg);
}

/* =========================================================
   Toolbar
   ========================================================= */

#toolbar {
  height: var(--toolbar-height);
  min-height: var(--toolbar-height);

  display: flex;
  align-items: center;

  background: var(--toolbar);
  border-bottom: 1px solid var(--border);

  user-select: none;
}

/* Brand */

.brand {
  width: var(--sidebar-width);
  height: 100%;

  display: flex;
  align-items: center;

  padding: 0 14px;

  gap: 9px;

  font-size: 13px;
  font-weight: 500;

  color: var(--text);
}

.logo {
  width: 23px;
  height: 23px;

  display: flex;
  align-items: center;
  justify-content: center;

  color: #ffffff;
  background: #007acc;

  border-radius: 4px;

  font-size: 15px;
}

/* Toolbar buttons */

.toolbar-buttons {
  display: flex;
  align-items: center;

  gap: 6px;

  height: 100%;
}

.toolbar-buttons button {
  height: 30px;

  padding: 0 11px;

  border: 1px solid #3a3a3a;
  border-radius: 4px;

  background: var(--button);
  color: var(--text);

  font-size: 12px;

  cursor: pointer;

  transition: background 0.12s, border-color 0.12s;
}

.toolbar-buttons button:hover {
  background: var(--button-hover);
  border-color: #4b4b4b;
}

.toolbar-buttons button:active {
  background: #202020;
}

#compileButton {
  background: #126e3a;
  border-color: #18894a;
  color: white;
}

#compileButton:hover {
  background: #168747;
}

#runButton {
  background: var(--blue);
  border-color: var(--blue);
  color: white;
}

#runButton:hover {
  background: var(--blue-hover);
}

/* VM status */

#vmStatus {
  margin-left: auto;

  padding: 0 16px;

  font-size: 12px;
  color: var(--text-muted);
}

#vmStatusText {
  color: #e5c07b;
}

#vmStatusText.ready {
  color: var(--green);
}

#vmStatusText.error {
  color: var(--red);
}

/* =========================================================
   Main workspace
   ========================================================= */

#workspace {
  display: flex;

  flex: 1;
  min-height: 0;

  width: 100%;
}

/* =========================================================
   File explorer
   ========================================================= */

#sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);

  display: flex;
  flex-direction: column;

  background: var(--sidebar);

  border-right: 1px solid var(--border);

  overflow: hidden;
}

.sidebar-title {
  height: 35px;

  display: flex;
  align-items: center;

  padding: 0 14px;

  font-size: 11px;
  font-weight: 600;

  color: #bbbbbb;

  letter-spacing: 0.5px;
}

/* File list */

#fileList {
  flex: 1;

  overflow-y: auto;
  overflow-x: hidden;

  padding-top: 2px;
}

.file-item {
  height: 29px;

  display: flex;
  align-items: center;

  padding: 0 10px;

  gap: 8px;

  color: #cccccc;

  font-size: 13px;

  cursor: pointer;

  user-select: none;
}

.file-item:hover {
  background: var(--sidebar-hover);
}

.file-item.active {
  background: #37373d;
  color: #ffffff;
}

/* File icons */

.file-icon {
  width: 17px;

  display: inline-flex;
  justify-content: center;

  color: #519aba;

  font-size: 10px;
  font-weight: bold;
}

/* =========================================================
   Main editor / terminal area
   ========================================================= */

#mainArea {
  flex: 1;
  min-width: 0;
  min-height: 0;

  display: flex;
  flex-direction: column;

  background: var(--bg);
}

/* =========================================================
   Editor tabs
   ========================================================= */

#editorTabs {
  height: 36px;
  min-height: 36px;

  display: flex;

  background: #181818;

  border-bottom: 1px solid var(--border);

  overflow: hidden;
}

.editor-tab {
  height: 36px;

  min-width: 120px;

  display: flex;
  align-items: center;

  padding: 0 14px;

  border-right: 1px solid var(--border);

  color: var(--text-muted);

  font-size: 12px;

  background: #181818;
}

.editor-tab.active {
  color: #ffffff;

  background: #1e1e1e;

  border-top: 1px solid var(--blue);
}

/* =========================================================
   Monaco editor container
   ========================================================= */

#editor {
  flex: 1;
  min-height: 100px;

  position: relative;

  background: #1e1e1e;
}

/* Monaco needs its container to have real dimensions */

#editor > * {
  width: 100%;
  height: 100%;
}

/* =========================================================
   Terminal panel
   ========================================================= */

#terminalPanel {
  height: var(--terminal-height);
  min-height: 120px;

  display: flex;
  flex-direction: column;

  background: var(--terminal);

  border-top: 1px solid var(--border);
}

/* Terminal header */

#terminalHeader {
  height: 32px;
  min-height: 32px;

  display: flex;
  align-items: center;

  padding: 0 10px;

  background: #181818;

  border-bottom: 1px solid #252525;

  color: #bbbbbb;

  font-size: 11px;
  font-weight: 600;

  letter-spacing: 0.4px;
}

.terminal-buttons {
  margin-left: auto;
}

.terminal-buttons button {
  height: 23px;

  padding: 0 8px;

  border: 0;
  border-radius: 3px;

  background: transparent;
  color: #999999;

  font-size: 11px;

  cursor: pointer;
}

.terminal-buttons button:hover {
  background: #2a2a2a;
  color: #ffffff;
}

/* Actual xterm container */

#terminal {
  flex: 1;
  min-height: 0;

  padding: 7px 9px;

  background: var(--terminal);

  overflow: hidden;
}

/* xterm.js */

#terminal .xterm {
  width: 100%;
  height: 100%;
}

#terminal .xterm-viewport {
  background: var(--terminal) !important;
}

/* =========================================================
   Scrollbars
   ========================================================= */

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: #1e1e1e;
}

::-webkit-scrollbar-thumb {
  background: #424242;
}

::-webkit-scrollbar-thumb:hover {
  background: #555555;
}

/* =========================================================
   Selection
   ========================================================= */

::selection {
  background: #264f78;
}

/* =========================================================
   Mobile / small screens
   ========================================================= */

@media (max-width: 700px) {
  :root {
    --sidebar-width: 170px;
    --terminal-height: 220px;
  }

  .brand {
    width: var(--sidebar-width);
  }

  .toolbar-buttons button {
    padding: 0 7px;
  }

  #vmStatus {
    display: none;
  }
}

/* =========================================================
   Very small screens
   ========================================================= */

@media (max-width: 500px) {
  #sidebar {
    width: 150px;
    min-width: 150px;
  }

  .brand {
    width: 150px;
    min-width: 150px;
  }

  .brand span:last-child {
    display: none;
  }

  #terminalPanel {
    height: 190px;
  }
}
