
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono&display=swap');

/* ---- Color & Font Variables ---- */
:root {
  --bg:       #0F111B;
  --fg:       #ECF0C1;
  --title:    #ECF0C1;
  --hl:       #5CCC96;
  --black:    #000000;
  --red:      #E33400;
  --green:    #5CCC96;
  --yellow:   #B3A1E6;
  --blue:     #00A3CC;
  --magenta:  #F2CE00;
  --cyan:     #7A5CCC;
}

/* Optionally let the HTML font-size scale a bit with viewport width */
html {
  font-size: clamp(14px, 1.2vw, 18px);
}

body {
  font-family: 'JetBrains Mono', monospace;
  color: var(--fg);
  background-color: var(--bg);
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-height: 100vh;
  padding: 20px; /* padding around the content */
}

/* If you have a site header or #main_header, position it as desired */
#main_header {
  position: relative;
  top: 2vh; 
}

/* The main content area with a top margin so the sticky toolbar doesn't overlap */
main {
  width: 100%;
  max-width: 800px;
  margin-top: 80px; /* space for the pinned top toolbar */
  margin-bottom: 2rem; /* extra bottom space */
}

/* ---- Sticky Top Toolbar ---- */
#top-toolbar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 2002;
  background-color: var(--bg);
  border-bottom: 1px solid var(--fg);
  padding: 10px;
  display: flex;
  gap: 10px;
  align-items: center;
}

/* Example styling for your top buttons */
#add-cell-btn,
#download-session-btn,
#load-session-btn {
  margin-top: 0;
  padding: 0.2vw 0.2vh;
  font-family: 'JetBrains Mono', monospace;
  font-size: 1rem;
  background-color: var(--magenta);
  color: var(--bg);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.3s ease;
}
#add-cell-btn:hover,
#download-session-btn:hover,
#load-session-btn:hover {
  background-color: var(--cyan);
}

#code-theme-settings-container #code-theme-select {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    background-color: var(--green);
    color: var(--bg);
    appearance: none; /* Remove default arrow */
    -webkit-appearance: none; /* Remove default arrow */
    -moz-appearance: none; /* Remove default arrow */
    background-image: url('image/svg+xml;utf8,<svg fill="%23ffffff" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/><path d="M0 0h24v24H0z" fill="none"/></svg>');
    background-repeat: no-repeat;
    background-position-x: 95%;
    background-position-y: 50%;
}

#code-theme-settings-container #code-theme-select:hover {
    background-color: var(--cyan);
}
#font-size-settings-container #font-size-input {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    background-color: var(--green);
    color: var(--bg);
    width: 100%;
}

#font-size-settings-container #font-size-input:hover {
    background-color: var(--cyan);
}
#close-theme-btn,
#close-hotkey-btn,
#close-code-theme-btn,
#close-font-size-btn {
    background-color: var(--green);
    color: var(--bg);
    border: none;
    border-radius: 4px;
    padding: 6px 12px;
    cursor: pointer;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    transition: background-color 0.3s ease;
}
#close-theme-btn:hover,
#close-hotkey-btn:hover,
#close-code-theme-btn:hover,
#close-font-size-btn:hover {
    background-color: var(--cyan);
}

/* Dropdown Button */
.dropbtn {
    margin-top: 0;
    padding: 0.2vw 0.2vh;
    font-family: 'JetBrains Mono', monospace;
    font-size: 1rem;
    background-color: var(--magenta);
    color: var(--bg);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.dropbtn:hover,
.dropbtn:focus {
  background-color: var(--cyan);
}

/* The container <div> - needed to position the dropdown content */
.dropdown {
    position: relative;
    display: inline-block;
}

/* Dropdown Content (Hidden by Default) */
.dropdown-content {
    display: none;
    position: absolute;
    background-color: #f9f9f9;
    min-width: 160px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
    z-index: 1;
    z-index: 2001; /* Ensure dropdown is above the console */
}

/* Dropdown links */
.dropdown-content a {
  color: black;
  padding: 12px 16px;
  text-decoration: none;
  display: block;
}

/* Change color of dropdown links on hover */
.dropdown-content a:hover {
    background-color: #f1f1f1
}

/* Show the dropdown menu on hover */
.dropdown:hover .dropdown-content {
    display: block;
}

/* ---- Notebook Cells ---- */
.tutorial-section {
  margin-bottom: 20px;
  border: 1px solid var(--fg);
  border-radius: 8px;
  background-color: var(--bg);
  padding: 10px;
}

.code-block {
  background-color: var(--bg);
  padding: 1vw;
  border-radius: 8px;
  border: 1px solid var(--fg);
}

/* Code editor text area (used if not using CodeMirror) */
textarea.editable-code {
  width: 100%;
  height: 5vh;
  font-family: 'JetBrains Mono', monospace;
  font-size: 1rem;
  margin-top: 0.2vh;
  padding: 0.2vw;
  border: 1px solid var(--fg);
  border-radius: 8px;
  resize: vertical;
  background: var(--bg);
  color: var(--fg);
}

/* Notes text area */
textarea.notes {
  width: 100%;
  min-height: 3vh;
  font-family: 'JetBrains Mono', monospace;
  font-size: 1rem;
  margin-top: 0.2vh;
  padding: 0.2vw;
  border: 1px solid var(--fg);
  border-radius: 8px;
  resize: vertical;
  background: var(--bg);
  color: var(--green);
}

/* Output area */
pre.output {
  background-color: var(--bg);
  color: var(--cyan);
  padding: 0.2vw;
  border: 1px solid var(--fg);
  border-radius: 8px;
  margin-top: 0.2vh;
  font-family: 'JetBrains Mono', monospace;
  white-space: pre-wrap;
  overflow-x: auto;
}

/* Cell header & toggling */
.cell-header {
  display: flex;
  align-items: center;
  margin-bottom: 0.2vh;
}

.cell-body {
  transition: max-height 0.3s ease;
  margin-bottom: 5px; /* Added margin below cell-body */
}
.cell-body.collapsed {
  display: none;
}

.toggle-cell {
  font-size: 1.4rem;
  background: var(--black);
  color: var(--fg);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  width: 1vw;
  height: 1vw;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Footer with run/remove */
.cell-footer {
  display: flex;
  gap: 10px;
  margin-top: 2px;
}

/* Run info at the bottom of each cell */
.run-info {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-top: 0.2vh;
  font-size: 0.8rem;
  color: #aaa;
}

.run-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #aaa;
  margin-right: 5px;
  transition: background-color 0.3s ease;
}

.run-dot.active {
  background-color: var(--green);
}

/* Remove & Run buttons at bottom of each cell */
.cell-footer .remove-cell,
.cell-footer .run-code,
#r-console-run,
#r-console-clear {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9rem;
  padding: 6px 12px; /* Adjusted padding */
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.3s ease;
  margin: 0; /* Remove default margins */
}
.cell-footer .remove-cell {
  background-color: var(--red);
  color: var(--bg);
}
.cell-footer .remove-cell:hover {
  background-color: var(--cyan);
}
.cell-footer .run-code {
  background-color: var(--green);
  color: var(--bg);
}
.cell-footer .run-code:hover {
  background-color: var(--cyan);
}
#r-console-run {
  background-color: var(--green);
  color: var(--bg);
}
#r-console-run:hover {
  background-color: var(--cyan);
}
#r-console-clear {
  background-color: var(--red);
  color: var(--bg);
}
#r-console-clear:hover {
  background-color: var(--cyan);
}

/* ---- Plot Container (top-right) ---- */
#plot-container {
  position: fixed;
  top: 8vh;            /* 8% from top viewport */
  right: 3vw;          /* 3% from right viewport edge */
  width: 5vw;
  height: 20vw;

  overflow: auto;
  background-color: var(--bg); /* Match console background */
  border: 1px solid var(--fg); /* Match console border */
  border-radius: 8px; /* Match console border-radius */
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
  padding: 1rem;
  z-index: 1000;
  font-family: 'JetBrains Mono', monospace; /* Match console font */
  resize: both;
  overflow: auto;
  color: var(--fg); /* Match console text color */
}

/* Plot canvas can scale to fit the container's width if desired */
#plot-canvas {
  width: 100%;
  height: auto;
  border: 1px solid #aaa;
  border-radius: 4px;
  background-color: white;
  max-height: 80%;
}

/* Plot nav buttons */
.plot-nav-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5em;
  margin-top: 0.1vh;
  margin-bottom: 10px;
}
.plot-nav-buttons button {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9rem;
  padding: 1px 0.1vw 0.1vh;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.3s ease;
  background-color: var(--green);
  color: var(--bg);
}
.plot-nav-buttons button:hover {
  background-color: var(--cyan);
}

/* ---- CodeMirror styling ---- */
.CodeMirror {
  font-family: 'JetBrains Mono', monospace !important;
}

/* ---- HOME button pinned top-left ---- */
#home_button {
  position: relative;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 1em;
  padding: 5px 18px;
  border: 2px solid var(--black);
  border-radius: 8px;
  background-color: var(--green);
  color: var(--bg);
  cursor: pointer;
  transition: all 0.3s ease;
  margin-left: 10px;
  margin-top: 0px;
  width: auto;
  text-align: center;
  white-space: nowrap;
}

/* ---- HOME button pinned top-left ---- */
#home_button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 1em;
  padding: 5px 18px;
  border: 2px solid var(--black);
  border-radius: 8px;
  background-color: var(--green);
  color: var(--bg);
  cursor: pointer;
  transition: all 0.3s ease;
  margin-left: 10px;
  margin-top: 0px;
  width: auto;
  text-align: center;
  white-space: nowrap;
}

/* ---- Console pinned left ---- */
#r-console {
  position: fixed;
  top: 8vh;
  left: 3vw;
  width: 20vw;
  height: 20vw;

  overflow: auto;
  border: 1px solid var(--fg);
  border-radius: 8px;
  background-color: var(--bg);
  color: var(--fg);
  z-index: 2000;
  padding: 1rem;
  resize: both;
  overflow: auto;
}

#r-console h2 {
  margin: 0 0 0.5rem 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.1rem;
}

#r-console-output {
  height: 10vw;
  width: 95%;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9rem;
  background-color: var(--bg);
  border: 1px solid var(--fg);
  border-radius: 4px;
  overflow-y: auto;
  padding: 5px;
  margin-bottom: 10px;
  white-space: pre-wrap;
  resize: vertical;
}

#r-console-input {
  width: 95%;
  height: 4vw;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9rem;
  margin-bottom: 10px;
  padding: 5px;
  border: 1px solid var(--fg);
  border-radius: 4px;
  background-color: var(--bg);
  color: var(--green);
  resize: vertical;
}

.console-buttons {
  display: flex;
  gap: 10px;
}

#r-console-run, #r-console-clear {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9rem;
  padding: 0.1vw 0.2vh;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.3s ease;
}
#r-console-run {
  background-color: var(--green);
  color: var(--bg);
}
#r-console-run:hover {
  background-color: var(--cyan);
}
#r-console-clear {
  background-color: var(--red);
  color: var(--bg);
}
#r-console-clear:hover {
  background-color: var(--cyan);
}

/* ---- Environment info pinned bottom-right ---- */
#environment-info {
  position: fixed;
  left: 3vw;
  bottom: 3vh;
  width: 20vw;
  height: 20vw;

  overflow: auto;
  background-color: var(--bg);
  border: 1px solid var(--fg);
  border-radius: 8px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
  padding: 1rem;
  z-index: 1000;
  font-family: 'JetBrains Mono', monospace;
  resize: both; /* Add resize property */
  overflow: auto;
  color: var(--fg);
}

#environment-info h2 {
  margin: 0 0 0.5rem 0;
  font-size: 1.1rem; /* Match console h2 font size */
  font-weight: normal; /* Remove bold */
}

#env-content {
  font-size: 0.9rem; /* Match console output font size */
  line-height: 1.2;
  white-space: pre-wrap;
}

/* ---- Optional: Basic responsive tweaks for narrower/wider screens ---- */
@media (max-width: 900px) {
  #r-console {
    left: 2vw;
    width: clamp(220px, 15vw, 480px);
  }
  #plot-container {
    right: 2vw;
    width: clamp(5vw, 20vw, 100vw);
  }
}

@media (min-width: 1800px) {
  #plot-container {
    width: clamp(5vw, 20vw, 100vw);
  }
}
