/* uart.css */
:root {
  --primary-color: #16a085;
  --primary-hover: #1abc9c;
  --danger-color: #e74c3c;
  --success-color: #27ae60;
  --info-color: #3498db;
  --warning-color: #f39c12;
  --dark-bg: #2c3e50;
  --darker-bg: #34495e;
  --text-color: #ecf0f1;
  --border-color: #7f8c8d;
  --muted-text: #bdc3c7;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

* {
  box-sizing: border-box;
}

::selection {
  background: #16a085;
  color: #ecf0f1;
}

body {
  background-color: #2c3e50;
  color: #ecf0f1;
  margin: 0;
  padding: 0;
  font-family: Arial, sans-serif;
}

/* UART specific styles with reduced top padding */
.uart-section {
  background: #34495e;
  border-radius: 8px;
  padding: 10px 20px 20px 20px;
  margin: 10px 20px 20px 20px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.uart-section h2 {
  border-bottom: 2px solid;
  padding-bottom: 8px;
  margin-bottom: 15px;
  position: relative;
}

/* Status indicator styles */
.uart-section h2.status-indicator::before {
  content: "";
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-right: 10px;
  vertical-align: middle;
}

.uart-section h2.status-indicator.disconnected {
  color: #e74c3c;
  border-bottom-color: #e74c3c;
}

.uart-section h2.status-indicator.disconnected::before {
  background: #e74c3c;
}

.uart-section h2.status-indicator.connected {
  color: #27ae60;
  border-bottom-color: #27ae60;
}

.uart-section h2.status-indicator.connected::before {
  background: #27ae60;
}

.connection-panel {
  display: flex;
  gap: 15px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 15px;
}

.connection-control {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 0 0 auto;
}

.connection-control select:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  filter: grayscale(25%);
}

.connection-control label {
  color: #ecf0f1;
  font-size: 14px;
  font-weight: bold;
}

/* Override global styles for select and input */
.connection-control select,
.connection-control input[type="text"],
.connection-control input {
  width: auto !important;
  min-width: 120px;
  max-width: 150px;
  padding: 8px;
  border: 1px solid #7f8c8d;
  border-radius: 4px;
  background: #2c3e50;
  color: #ecf0f1;
  box-sizing: border-box;
}

/* Specific styles for UART buttons */
.uart-section button,
.connect-btn,
.send-btn,
.log-btn {
  width: auto !important;
  margin-top: 0 !important;
}

.connect-btn {
  padding: 10px 20px;
  background: #16a085;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: bold;
  transition: background 0.2s;
  height: fit-content;
}

.connect-btn:hover {
  background: #1abc9c;
}

.connect-btn:disabled {
  background: #7f8c8d;
  cursor: not-allowed;
}

/* Settings button (gear) */
.settings-btn {
  padding: 8px;
  background: #7f8c8d;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  height: fit-content;
  min-width: 32px;
}

.settings-btn:hover {
  background: #95a5a6;
}

.settings-btn svg {
  width: 16px;
  height: 16px;
}

/* View toggle in header */
.view-toggle {
  display: flex;
  gap: 5px;
  margin-left: 10px;
}

.view-btn {
  padding: 4px 8px;
  background: #7f8c8d;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  gap: 4px;
}

.view-btn:hover {
  background: #95a5a6;
}

.view-btn.active {
  background: #16a085;
}

.view-btn svg {
  width: 14px;
  height: 14px;
}

/* Terminal split container */
.terminals-split-container {
  display: flex;
  gap: 15px;
  margin-bottom: 15px;
  height: 480px;
  box-sizing: border-box;
}

.terminal-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  box-sizing: border-box;
}

.terminal-label {
  margin: 0 5px 0 0;
  color: #16a085;
  font-size: 14px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 1px;
  line-height: 20px;
  flex-shrink: 0;
}

/* Terminal header with controls */
.terminal-header {
  display: flex;
  align-items: center;
  margin: 0 0 8px 0;
  min-height: 20px;
  flex-shrink: 0;
  gap: 10px;
}

/* Log controls */
.log-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-left: 0;
  justify-content: flex-start;
}

.log-btn {
  padding: 4px 8px;
  background: #7f8c8d;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  transition: background 0.2s;
}

.log-btn:hover {
  background: #95a5a6;
}

/* Terminal container */
.terminal-container {
  background: #2c3e50;
  border: 1px solid #7f8c8d;
  border-radius: 4px;
  height: calc(100% - 28px);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px;
  font-family: "Courier New", monospace;
  font-size: 14px;
  position: relative;
  box-sizing: border-box;
}

/* Oscilloscope container */
.oscilloscope-container {
  background: #2c3e50;
  border: 1px solid #7f8c8d;
  border-radius: 4px;
  height: calc(100% - 28px);
  overflow: hidden;
  padding: 10px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  position: relative;
}

#oscilloscopeCanvas {
  flex: 1;
  width: 100%;
  background: #1a252f;
  border-radius: 4px;
  min-height: 200px;
}

/* Oscilloscope controls */
.oscilloscope-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-left: auto;
}

.oscilloscope-controls .connection-control {
  margin: 0;
}

.oscilloscope-controls .connection-control label {
  font-size: 11px;
  margin-right: 5px;
}

.oscilloscope-controls .connection-control select {
  min-width: 50px;
  max-width: 70px;
  padding: 2px 4px;
  font-size: 11px;
}

/* Zoom controls */
.zoom-controls {
  display: flex;
  gap: 5px;
  align-items: center;
}

.zoom-btn {
  min-width: 24px;
  text-align: center;
  font-size: 14px;
  font-weight: bold;
  padding: 4px 6px;
}

#resetZoomBtn {
  font-size: 10px;
  padding: 4px 6px;
}

/* Play/Pause button */
.play-pause-btn {
  padding: 4px;
  background: #7f8c8d;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
}

.play-pause-btn:hover {
  background: #95a5a6;
}

.play-pause-btn.playing {
  background: #16a085;
}

.play-pause-btn svg {
  width: 16px;
  height: 16px;
}

/* Terminal lines */
.terminal-line {
  margin-bottom: 5px;
  word-wrap: break-word;
  word-break: break-all;
  white-space: pre-wrap;
  font-family: "Courier New", monospace;
  line-height: 1.4;
}

.terminal-line.sent {
  color: #3498db;
}

.terminal-line.received {
  color: #2ecc71;
}

.terminal-line.error {
  color: #e74c3c;
}

.terminal-line.info {
  color: #f39c12;
}

/* HEX mode */
.terminal-line.hex-mode {
  font-family: "Consolas", "Monaco", "Courier New", monospace;
  letter-spacing: 2px;
}

.terminal-line.hex-mode .byte {
  padding: 2px 4px;
  margin: 0 2px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 2px;
}

.terminal-line.hex-mode .byte:hover {
  background: rgba(26, 188, 156, 0.2);
  cursor: help;
}

/* Terminal input panel */
.terminal-input-panel {
  display: flex;
  gap: 10px;
  align-items: center;
}

.terminal-input {
  flex: 1;
  padding: 8px;
  border: 1px solid #7f8c8d;
  border-radius: 4px;
  background: #2c3e50;
  color: #ecf0f1;
  font-family: "Courier New", monospace;
  width: auto !important;
}

.send-btn {
  padding: 8px 15px;
  background: #16a085;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s;
}

.send-btn:hover {
  background: #1abc9c;
}

.send-btn:disabled {
  background: #7f8c8d;
  cursor: not-allowed;
}

.send-loop-btn {
  padding: 8px 15px;
  background: #16a085;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  height: 31.4px;
}

.send-loop-btn:hover {
  background: #1abc9c;
}

.send-loop-btn.active {
  background: #e74c3c;
}

.send-loop-btn.active:hover {
  background: #c0392b;
}

.send-loop-btn:disabled {
  background: #7f8c8d;
  cursor: not-allowed;
}

.send-loop-btn svg {
  width: 20px;
  height: 20px;
}

/* Loop interval input */
.loop-interval-input {
  width: 70px;
  padding: 8px;
  border: 1px solid #7f8c8d;
  border-radius: 4px;
  background: #2c3e50;
  color: #ecf0f1;
  font-family: "Courier New", monospace;
  text-align: center;
  height: 31.4px;
}

.loop-interval-input::-webkit-inner-spin-button,
.loop-interval-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.loop-interval-label {
  color: #95a5a6;
  font-size: 14px;
  margin-left: -5px;
  align-self: center;
}

.feature-panel {
  min-height: 100vh;
  padding: 10px;
}

.api-support-warning {
  background: #e67e22;
  color: white;
  padding: 15px;
  border-radius: 4px;
  margin-bottom: 15px;
  display: none;
}

.api-support-warning.show {
  display: block;
}

/* Scrollbar for terminal */
.terminal-container::-webkit-scrollbar {
  width: 8px;
}

.terminal-container::-webkit-scrollbar-track {
  background: #2c3e50;
}

.terminal-container::-webkit-scrollbar-thumb {
  background: #16a085;
  border-radius: 4px;
}

/* Custom checkboxes */
.checkbox-label {
  display: flex;
  align-items: center;
  cursor: pointer;
  color: #ecf0f1;
  font-size: 12px;
  user-select: none;
  gap: 6px;
}

.checkbox-label input[type="checkbox"] {
  display: none;
}

.checkbox-custom {
  width: 14px;
  height: 14px;
  border: 2px solid #7f8c8d;
  border-radius: 3px;
  background: #2c3e50;
  position: relative;
  transition: all 0.2s;
}

.checkbox-custom::after {
  content: "";
  position: absolute;
  left: 2px;
  top: -1px;
  width: 4px;
  height: 8px;
  border: solid #ecf0f1;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  opacity: 0;
  transition: opacity 0.2s;
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-custom {
  background: #16a085;
  border-color: #16a085;
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-custom::after {
  opacity: 1;
}

.checkbox-label:hover .checkbox-custom {
  border-color: #16a085;
}

/* Input mode radio buttons */
.input-mode-controls {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-right: 15px;
}

.radio-label {
  display: flex;
  align-items: center;
  cursor: pointer;
  color: #ecf0f1;
  font-size: 14px;
  user-select: none;
  gap: 8px;
}

.radio-label input[type="radio"] {
  display: none;
}

.radio-custom {
  width: 16px;
  height: 16px;
  border: 2px solid #7f8c8d;
  border-radius: 50%;
  background: #2c3e50;
  position: relative;
  transition: all 0.2s;
}

.radio-custom::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ecf0f1;
  opacity: 0;
  transition: opacity 0.2s;
}

.radio-label input[type="radio"]:checked + .radio-custom {
  background: #16a085;
  border-color: #16a085;
}

.radio-label input[type="radio"]:checked + .radio-custom::after {
  opacity: 1;
}

.radio-label:hover .radio-custom {
  border-color: #16a085;
}

/* Modal styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal-overlay.show {
  display: flex;
}

.modal-content {
  background: #34495e;
  border-radius: 8px;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.5);
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid #7f8c8d;
}

.modal-header h3 {
  margin: 0;
  color: #16a085;
  font-size: 18px;
}

.modal-close {
  background: none;
  border: none;
  color: #ecf0f1;
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.2s;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.1);
}

.modal-body {
  padding: 20px;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

/* Mobile responsive styles */
@media (max-width: 768px) {
  .connection-panel {
    flex-direction: column;
    align-items: stretch;
  }

  .connection-control {
    width: 100%;
  }

  .connection-control select,
  .connection-control input {
    width: 100% !important;
    max-width: none;
  }

  .log-controls {
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    margin-left: 0;
  }

  /* Terminals stacked on mobile */
  .terminals-split-container {
    flex-direction: column;
    height: auto;
  }

  .terminal-container {
    height: 350px;
    min-height: 350px;
    max-height: 350px;
  }

  .oscilloscope-container {
    height: 350px;
    min-height: 350px;
    max-height: 350px;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .modal-content {
    width: 95%;
    margin: 10px;
  }
}

/* Height-responsive adjustments for UART page */
html,
body {
  max-height: 100vh;
  overflow: hidden;
}

main {
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
}

.feature-panel {
  height: 100vh;
  overflow-y: auto;
  padding: 0;
}

/* Compact mode for laptop screens */
@media (max-height: 800px) {
  .uart-section {
    padding: 8px 15px 15px 15px;
    margin: 8px 15px 15px 15px;
  }

  .uart-section h2 {
    font-size: 1.1rem;
    margin-bottom: 10px;
    padding-bottom: 6px;
  }

  .connection-panel {
    margin-bottom: 10px;
    gap: 10px;
  }

  .connect-btn {
    padding: 8px 16px;
    font-size: 0.9rem;
  }

  .connection-control label {
    font-size: 12px;
  }

  .connection-control select,
  .connection-control input {
    padding: 6px;
    font-size: 0.9rem;
  }

  .terminals-split-container {
    height: calc(100vh - 250px);
    max-height: 400px;
    margin-bottom: 10px;
  }

  .terminal-header {
    margin-bottom: 5px;
  }

  .terminal-label {
    font-size: 12px;
  }

  .log-btn {
    padding: 3px 6px;
    font-size: 10px;
  }

  .terminal-container,
  .oscilloscope-container {
    height: calc(100% - 24px);
  }

  .send-container {
    padding: 8px;
    margin-top: 8px;
  }

  .send-controls {
    gap: 8px;
  }

  #terminalInput {
    padding: 6px;
    font-size: 0.9rem;
  }

  .send-btn {
    padding: 6px 12px;
    font-size: 0.9rem;
  }

  .api-support-warning {
    padding: 8px;
    margin: 8px 15px;
    font-size: 0.85rem;
  }
}

/* Ultra compact for very small heights */
@media (max-height: 650px) {
  .uart-section {
    padding: 5px 12px 12px 12px;
    margin: 5px 12px 12px 12px;
  }

  .uart-section h2 {
    font-size: 1rem;
    margin-bottom: 8px;
    padding-bottom: 5px;
  }

  .connection-panel {
    margin-bottom: 8px;
    gap: 8px;
  }

  .connect-btn {
    padding: 6px 12px;
    font-size: 0.85rem;
  }

  .settings-btn {
    padding: 6px;
    min-width: 28px;
  }

  .settings-btn svg {
    width: 14px;
    height: 14px;
  }

  .terminals-split-container {
    height: calc(100vh - 280px);
    max-height: 320px;
  }

  .terminal-container,
  .oscilloscope-container {
    font-size: 12px;
    padding: 8px;
  }

  .terminal-header {
    min-height: 18px;
  }

  .terminal-label {
    font-size: 11px;
    letter-spacing: 0.5px;
  }

  .log-controls {
    gap: 6px;
  }

  .log-btn,
  .view-btn {
    padding: 2px 5px;
    font-size: 9px;
  }

  .send-container {
    padding: 6px;
    margin-top: 6px;
  }

  #terminalInput {
    padding: 5px;
    font-size: 0.85rem;
  }

  .send-btn {
    padding: 5px 10px;
    font-size: 0.85rem;
  }

  .loop-controls {
    gap: 6px;
  }

  #loopIntervalInput {
    padding: 5px;
    font-size: 0.85rem;
    max-width: 60px;
  }

  .oscilloscope-controls {
    gap: 6px;
  }

  .oscilloscope-controls .connection-control select {
    padding: 2px 4px;
    font-size: 10px;
  }

  .zoom-btn,
  #resetZoomBtn {
    padding: 3px 5px;
    font-size: 11px;
  }

  .play-pause-btn {
    width: 24px;
    height: 24px;
  }

  .play-pause-btn svg {
    width: 14px;
    height: 14px;
  }
}

/* Ensure no scrollbars appear on the body */
body::-webkit-scrollbar {
  display: none;
}

body {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* Adjust feature panel to prevent overflow */
.feature-panel {
  display: flex;
  flex-direction: column;
  max-height: 100vh;
}

/* Make sure terminals container is flexible */
@media (max-height: 800px) {
  .feature-panel {
    padding-bottom: 10px;
  }

  /* Ensure send container stays at bottom */
  .send-container {
    margin-top: auto;
    flex-shrink: 0;
  }
}

/* Data mode controls for oscilloscope */
.data-mode-controls {
  display: flex;
  gap: 15px;
  align-items: center;
  margin-left: 10px;
}

/* Radio group container */
.radio-group {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 2px 6px;
  background: rgba(44, 62, 80, 0.5);
  border-radius: 4px;
}

/* Inline radio labels for compact display */
.radio-label-inline {
  display: flex;
  align-items: center;
  cursor: pointer;
  color: #bdc3c7;
  font-size: 11px;
  user-select: none;
  transition: color 0.2s;
}

.radio-label-inline span {
  padding: 2px 4px;
  border-radius: 3px;
  transition: all 0.2s;
}

.radio-label-inline input[type="radio"] {
  display: none;
}

.radio-label-inline input[type="radio"]:checked + span {
  background: #16a085;
  color: #ecf0f1;
  font-weight: bold;
}

.radio-label-inline:hover span {
  color: #ecf0f1;
}

/* Remove the zoom controls styles since we're removing them */
/* Deleted: .zoom-controls, .zoom-btn, #resetZoomBtn */

/* Adjust oscilloscope controls layout */
.oscilloscope-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-left: auto;
}

/* Ensure proper alignment when data mode controls are visible */
.terminal-header {
  display: flex;
  align-items: center;
  margin: 0 0 8px 0;
  min-height: 20px;
  flex-shrink: 0;
  gap: 5px;
  flex-wrap: wrap;
}

.terminal-header .log-controls {
  display: flex;
  gap: 5px;
  align-items: center;
  flex: 1;
  flex-wrap: wrap;
}

/* Responsive adjustments for data mode controls */
@media (max-width: 768px) {
  .data-mode-controls {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    margin-left: 0;
    margin-top: 5px;
    width: 100%;
  }

  .radio-group {
    width: 100%;
    justify-content: space-between;
  }
}

@media (max-height: 800px) {
  .radio-label-inline {
    font-size: 10px;
  }

  .radio-group {
    padding: 1px 4px;
    gap: 5px;
  }
}

@media (max-height: 650px) {
  .radio-label-inline {
    font-size: 9px;
  }

  .radio-group {
    padding: 1px 3px;
    gap: 3px;
  }

  .data-mode-controls {
    gap: 5px;
  }
}
