/* this css file defines how each html element looks */

/* light mode is default */
body {
  background-color: #ffffff;
  color: #000000;
  transition: background-color 0.3s, color 0.3s;
  margin: 0;
  height: 100vh;
}

/* dark mode when body has dark-mode class */
body.dark-mode {
  background-color: #1a1a1a;
  color: #e0e0e0;
}

/* the main container holds everything and centers it */
.container {
  max-width: 90%;
  margin: 0 auto;
  padding: 20px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  font-family: Arial, sans-serif;
  /* Use flexbox column layout so child elements (like output-area) can dynamically fill remaining screen height */
  display: flex;
  flex-direction: column;
  height: 100%;
  box-sizing: border-box;
}

/* logo section at the top center */
.logo-section {
  text-align: center;
  margin-bottom: 10px;
  position: relative;
}

/* the logo image styling */
.logo {
  max-width: 200px;
  height: auto;
}

/* header action buttons */
#manual-help-button,
#dark-mode-toggle {
  position: absolute;
  top: 10px;
  background: none;
  border: 2px solid #02005f;
  border-radius: 50%;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  font-size: 18px;
  cursor: pointer;
  transition: all 0.3s;
}

#manual-help-button {
  right: 58px;
  color: #02005f;
  font-family: Arial, sans-serif;
  font-weight: bold;
  text-decoration: none;
}

#dark-mode-toggle {
  right: 10px;
}

#manual-help-button:hover,
#dark-mode-toggle:hover {
  background-color: #02005f;
  color: #ffffff;
  transform: scale(1.1);
}

/* header buttons in dark mode */
body.dark-mode #manual-help-button,
body.dark-mode #dark-mode-toggle {
  border-color: #e0e0e0;
  color: #e0e0e0;
}

body.dark-mode #manual-help-button:hover,
body.dark-mode #dark-mode-toggle:hover {
  background-color: #e0e0e0;
  color: #1a1a1a;
}

/* status bar shows connection info */
.status-bar {
  background-color: #f0f0f0;
  padding: 10px;
  border-radius: 5px;
  margin-bottom: 10px;
  transition: background-color 0.3s, color 0.3s;
}

/* dark mode status bar */
body.dark-mode .status-bar {
  background-color: #333333;
  color: #e0e0e0;
}

/* when connected, make the status green */
.status-connected {
  background-color: #d4edda;
  color: #155724;
}

/* when disconnected, make the status red */
.status-disconnected {
  background-color: #f8d7da;
  color: #721c24;
}

/* dark mode status colors */
body.dark-mode .status-connected {
  background-color: #2d5a3d;
  color: #90ee90;
}

body.dark-mode .status-disconnected {
  background-color: #5a2d2d;
  color: #ff6b6b;
}

/* input section where user types commands */
.input-section {
  margin-bottom: 20px;
  position: relative;
}

/* the text area where users type commands */
#command-input {
  width: 100%;
  height: 80px;
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 5px;
  font-family: monospace;
  font-size: 14px;
  resize: vertical;
  box-sizing: border-box;
  transition: background-color 0.3s, border-color 0.3s, color 0.3s;
}

/* dark mode text input */
body.dark-mode #command-input {
  background-color: #2a2a2a;
  border-color: #555;
  color: #e0e0e0;
}

body.dark-mode #command-input::placeholder {
  color: #888;
}

/* the execute button */
#execute-button {
  position: absolute;
  bottom: 10px;
  right: 10px;
  background-color: #02005f;
  color: white;
  border: none;
  padding: 8px;
  border-radius: 50%;
  cursor: pointer;
  width: 50px;
  height: 50px;
  font-size: 25px;
  font-weight: 385;
  font-family: 'Segoe UI', 'Helvetica Neue', sans-serif;
}

/* make button darker when hovering over it */
#execute-button:hover {
  background-color: #010040;
}

/* output area where results are displayed */
.output-area {
  border: 1px solid #999;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.05);
  border-radius: 5px;
  padding: 10px;
  
  flex-grow: 1;
  overflow-y: auto;
  min-height: 100px;
  margin-bottom: 15px;
  overflow-x: hidden;
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: pre-wrap;

  background-color: #f8f9fa;
  box-sizing: border-box;
  transition: background-color 0.3s, border-color 0.3s, color 0.3s;
}

/* log pane for raw frames */
.log-pane {
  border: 1px solid #ccc;
  border-radius: 5px;
  padding: 10px;
  min-height: 100px;
  max-height: 300px;
  margin-top: 10px;
  margin-bottom: 10px;
  background-color: #f8f9fa;
  box-sizing: border-box;
  overflow-y: auto;
  transition: background-color 0.3s, border-color 0.3s, color 0.3s;
}

/* dark mode output area */
body.dark-mode .output-area {
  background-color: #2a2a2a;
  border-color: #555;
  color: #e0e0e0;
}

/* dark mode log pane */
body.dark-mode .log-pane {
  background-color: #2a2a2a;
  border-color: #555;
  color: #e0e0e0;
}

/* each result entry in the output */
.result-entry {
  margin-bottom: 15px;
  padding: 10px;
  border-left: 3px solid #02005f;
  background-color: white;
  transition: background-color 0.3s, border-left-color 0.3s;
}

/* result entry when selected for editing */
.result-entry.selected-command {
  border-left: 3px solid #28a745;
  background-color: #f0fff0;
}

/* result header with timestamp and edit button */
.result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 5px;
}

/* edit command button */
.edit-command-button {
  background-color: #02005f;
  color: white;
  border: none;
  border-radius: 3px;
  padding: 2px 8px;
  font-size: 12px;
  cursor: pointer;
  transition: background-color 0.3s;
}

.edit-command-button:hover {
  background-color: #010040;
}

/* dark mode result entries */
body.dark-mode .result-entry {
  background-color: #333333;
  border-left-color: #4dabf7;
}

/* dark mode selected command */
body.dark-mode .result-entry.selected-command {
  border-left-color: #69db7c;
  background-color: #1a321a;
}

/* dark mode edit button */
body.dark-mode .edit-command-button {
  background-color: #4dabf7;
  color: #1a1a1a;
}

body.dark-mode .edit-command-button:hover {
  background-color: #228be6;
}

/* the command that was executed */
.command-text {
  font-family: monospace;
  color: #6f42c1;
  font-weight: bold;
  margin-bottom: 5px;
  transition: color 0.3s;
}

/* the result from the server */
.result-text {
  font-family: monospace;
  color: #008a20;
  transition: color 0.3s;
}

/* if there was an error, make it red */
.error-text {
  font-family: monospace;
  color: #dc3545;
  transition: color 0.3s;
}

/* dark mode result text colors */
body.dark-mode .command-text {
  color: #b085f5;
}

body.dark-mode .result-text {
  color: #69db7c;
}

body.dark-mode .error-text {
  color: #ff6b6b;
}

/* format controls styling */
.format-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin-bottom: 15px;
  padding: 15px;
  border: 1px solid #ccc;
  border-radius: 5px;
  background-color: #f8f9fa;
  transition: background-color 0.3s, border-color 0.3s;
  width: 100%;
  box-sizing: border-box;
}

body.dark-mode .format-controls {
  background-color: #2a2a2a;
  border-color: #555;
}

.format-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-right: 20px;
}

.format-group label:first-child {
  font-weight: bold;
  color: #02005f;
  min-width: 80px;
}

body.dark-mode .format-group label:first-child {
  color: #4dabf7;
}

.format-group label {
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  font-size: 14px;
}

.format-group input[type="radio"] {
  margin: 0;
}

/* tab container styling */
.tab-container {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.tab-buttons {
  display: flex;
  gap: 2px;
  background-color: #e9ecef;
  border-radius: 5px;
  padding: 2px;
  transition: background-color 0.3s;
  flex-wrap: nowrap;
}

body.dark-mode .tab-buttons {
  background-color: #495057;
}

.tab-button {
  padding: 6px 12px;
  border: none;
  background-color: transparent;
  color: #6c757d;
  cursor: pointer;
  border-radius: 3px;
  font-size: 14px;
  transition: all 0.3s;
  min-width: 40px;
  text-align: center;
}

.tab-button:hover {
  background-color: #dee2e6;
  color: #495057;
}

.tab-button.active {
  background-color: #02005f;
  color: white;
  font-weight: bold;
}

body.dark-mode .tab-button {
  color: #adb5bd;
}

body.dark-mode .tab-button:hover {
  background-color: #6c757d;
  color: #f8f9fa;
}

body.dark-mode .tab-button.active {
  background-color: #4dabf7;
  color: #1a1a1a;
}

/* debug controls styling */
.debug-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  margin-bottom: 15px;
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 5px;
  background-color: #f0f8ff;
  transition: background-color 0.3s, border-color 0.3s;
}

body.dark-mode .debug-controls {
  background-color: #1a2332;
  border-color: #555;
}

.debug-controls label {
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  font-size: 14px;
  color: #02005f;
}

body.dark-mode .debug-controls label {
  color: #4dabf7;
}

.debug-controls input[type="checkbox"] {
  margin: 0;
}

/* file operations styling */
.file-operations {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 15px;
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 5px;
  background-color: #f8fff8;
  transition: background-color 0.3s, border-color 0.3s;
}

body.dark-mode .file-operations {
  background-color: #1a321a;
  border-color: #555;
}

.file-input-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
}

.file-input-wrapper input[type="file"] {
  display: none;
}

.file-input-wrapper label {
  padding: 8px 15px;
  background-color: #6c757d;
  color: white;
  border-radius: 3px;
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.3s;
}

.file-input-wrapper label:hover {
  background-color: #5a6268;
}

#file-command-count {
  font-size: 12px;
  color: #6c757d;
  font-weight: bold;
}

body.dark-mode #file-command-count {
  color: #adb5bd;
}

#exec-file-button, #clear-output-button {
  padding: 8px 15px;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.3s;
}

#exec-file-button {
  background-color: #28a745;
  color: white;
}

#exec-file-button:hover:not(:disabled) {
  background-color: #218838;
}

#exec-file-button:disabled {
  background-color: #6c757d;
  cursor: not-allowed;
}

#clear-output-button {
  background-color: #dc3545;
  color: white;
}

#clear-output-button:hover {
  background-color: #c82333;
}

/* frame display styling */
.frame-entry {
  margin-bottom: 10px;
  padding: 8px;
  border-left: 3px solid #6c757d;
  background-color: #f8f9fa;
  font-family: monospace;
  font-size: 12px;
  transition: background-color 0.3s, border-left-color 0.3s;
}

body.dark-mode .frame-entry {
  background-color: #2a2a2a;
  border-left-color: #adb5bd;
}

.frame-text {
  color: #6c757d;
  white-space: pre-wrap;
}

body.dark-mode .frame-text {
  color: #adb5bd;
}

/* Utility classes */
.d-none {
  display: none !important;
}

/* Frame display for raw frames */
.frame {
  font-family: monospace;
  white-space: pre-wrap;
  word-break: break-all;
  margin-top: 5px;
  padding: 5px;
  background-color: #f5f5f5;
  border-radius: 3px;
  border: 1px solid #ddd;
}

body.dark-mode .frame {
  background-color: #333;
  border-color: #444;
}

/* event display styling */
.event-entry {
  margin-bottom: 10px;
  padding: 8px;
  border-left: 3px solid #fd7e14;
  background-color: #fff3cd;
  font-family: monospace;
  font-size: 12px;
  transition: background-color 0.3s, border-left-color 0.3s;
}

body.dark-mode .event-entry {
  background-color: #3d2914;
  border-left-color: #fd7e14;
}

.event-text {
  color: #fd7e14;
  white-space: pre-wrap;
}

/* CodeMirror Overrides */
.CodeMirror {
  height: 80px;
  border: 1px solid #999;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.05);
  border-radius: 5px;
  font-family: monospace;
  font-size: 14px;
}

/* CodeMirror light theme: string token colors */
body:not(.dark-mode) #command-pane .cm-s-idea span.cm-string,
body:not(.dark-mode) #command-pane .cm-s-idea span.cm-string-2 {
  color: #d14;
}

/* CodeMirror light theme: variable and property colors */
body:not(.dark-mode) #command-pane .cm-s-idea span.cm-variable,
body:not(.dark-mode) #command-pane .cm-s-idea span.cm-property {
  color: #6f42c1;
  font-weight: bold;
}
/* CodeMirror light theme: secondary variable colors */
body:not(.dark-mode) #command-pane .cm-s-idea span.cm-variable-2,
body:not(.dark-mode) #command-pane .cm-s-idea span.cm-variable-3 {
  color: #005cc5;
}

/* Improve bracket matching visibility in light mode */
body:not(.dark-mode) .CodeMirror-matchingbracket {
  font-weight: bold !important;
  color: #0055cc !important;
  background-color: rgba(0, 85, 204, 0.1) !important;
  border-bottom: 2px solid #0055cc !important;
}

/* Improve bracket matching visibility in dark mode */
body.dark-mode .CodeMirror-matchingbracket,
body.dark-mode .cm-s-dracula .CodeMirror-matchingbracket {
  font-weight: bold !important;
  color: #8be9fd !important;
  background-color: rgba(139, 233, 253, 0.2) !important;
  border-bottom: 2px solid #8be9fd !important;
}

body.dark-mode .CodeMirror {
  border-color: #555;
}

/* Custom Scrollbar for Output Area so it doesn't look weird in Dark Mode */
.output-area {
  scrollbar-width: thin;
  scrollbar-color: #ccc #f8f9fa;
}
.output-area::-webkit-scrollbar {
  width: 10px;
}
.output-area::-webkit-scrollbar-track {
  background: #f8f9fa;
  border-radius: 5px;
}
.output-area::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 5px;
}
.output-area::-webkit-scrollbar-thumb:hover {
  background: #bbb;
}

body.dark-mode .output-area {
  scrollbar-color: #555 #2a2a2a;
}
body.dark-mode .output-area::-webkit-scrollbar-track {
  background: #2a2a2a;
}
body.dark-mode .output-area::-webkit-scrollbar-thumb {
  background: #555;
}
body.dark-mode .output-area::-webkit-scrollbar-thumb:hover {
  background: #777;
}
