/* TESLA-BLE WebFlash - a TESLA BLE Scanner feluletehez igazitott stilus */
:root {
  font-family: system-ui, Arial, sans-serif;
  background: #0b0c0e;
  color: #f6f6f7;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: #0b0c0e;
  color: #f6f6f7;
}

body { min-height: 100vh; }
button, input, select { font: inherit; }

/* Fejlec - ugyanaz a karakter, mint a TESLA BLE Scanneren */
.topbar {
  height: 66px;
  min-height: 66px;
  padding: 0 28px;
  background: #15171a;
  border-bottom: 2px solid #e82127;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 18px;
}

.topbar strong {
  letter-spacing: 3px;
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.topbar strong b { color: #e82127; }

.page-shell {
  width: 100%;
  max-width: 1100px;
  padding: 24px;
  margin: 0 auto;
}

.panel {
  background: #181a1e;
  border: 1px solid #33363c;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 18px;
}

h2 {
  margin: 0 0 8px;
  font-size: 20px;
}

.muted {
  margin: 0 0 18px;
  color: #a9adb5;
  line-height: 1.5;
}

.panel-title-row,
.devices-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.panel-title-row .muted { margin-bottom: 0; }

.panel-statuses {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}


.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: #fff;
  background: #3b3e46;
  border-radius: 20px;
  padding: 6px 10px;
  white-space: nowrap;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #d7a940;
}

#sessionStatus.ok .status-dot { background: #42c66a; }
#sessionStatus.error .status-dot { background: #e82127; }

.fw-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.fw-summary > div {
  min-width: 0;
  padding: 14px;
  background: #23272d;
  border: 1px solid #3a4048;
  border-radius: 10px;
}

.fw-summary span,
.port-info span {
  display: block;
  margin-bottom: 5px;
  color: #8f98a5;
  font-size: 12px;
}

.fw-summary strong {
  display: block;
  color: #e5e7eb;
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fw-summary .fw-comment-card strong {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.port-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px;
  background: #23272d;
  border: 1px solid #3a4048;
  border-radius: 10px;
}

.port-info { min-width: 0; }
.port-info strong {
  display: block;
  margin-bottom: 4px;
  color: #fff;
}
.port-info small {
  color: #a9adb5;
  overflow-wrap: anywhere;
}

button {
  border: 0;
  border-radius: 7px;
  background: #282a30;
  color: #fff;
  padding: 12px 15px;
  cursor: pointer;
  font-weight: 600;
}

button:hover:not(:disabled) { filter: brightness(1.2); }
button:disabled { opacity: .42; cursor: not-allowed; }
.red { background: #e82127; }

.controls {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

.controls button { min-width: 150px; }

.progress-block {
  padding: 14px;
  background: #23272d;
  border: 1px solid #3a4048;
  border-radius: 10px;
}

.progress-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  color: #a9adb5;
  font-size: 13px;
}

.progress-meta strong { color: #fff; }

.progress-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #0e1013;
  border: 1px solid #303238;
}

.progress-bar {
  width: 0%;
  height: 100%;
  background: #e82127;
  transition: width .18s ease;
}

.devices-heading {
  align-items: center;
  margin-bottom: 14px;
}

.devices-heading h2 { margin: 0; }

.clear-results {
  background: transparent;
  border: 1px solid #e82127;
  color: #fff;
  white-space: nowrap;
}

.clear-results:hover { background: #e82127; }

.log {
  height: 300px;
  overflow: auto;
  margin: 0;
  background: #090a0c;
  border: 1px solid #303238;
  border-radius: 0;
  padding: 12px;
  font: 12px/1.6 ui-monospace, SFMono-Regular, Consolas, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: #b3e3c4;
}

.page-note {
  margin: 0;
  padding: 2px 2px 20px;
  color: #747983;
  font-size: 12px;
  text-align: center;
}

@media (max-width: 700px) {
  .topbar { padding: 14px; }
  .page-shell { padding: 12px; }
  .fw-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .port-box { flex-direction: column; align-items: stretch; }
  .controls { flex-direction: column; }
  .controls button { width: 100%; }
}

@media (max-width: 480px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }
  .topbar strong { font-size: 14px; }
  .fw-summary { grid-template-columns: 1fr; }
  .clear-results { padding: 9px 12px; font-size: 12px; }
}


/* ============================================================
   WEBFLASH AUTH / FELHASZNALO MENU / MODAL
   ============================================================ */
.topbar {
  justify-content: space-between;
}

.topbar-auth {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.topbar-user {
  color: #a9adb5;
  font-size: 12px;
  white-space: nowrap;
}

.topbar-user strong {
  color: #fff;
  letter-spacing: 0;
  font-size: 12px;
}

.topbar-action {
  padding: 8px 11px;
  border: 1px solid #3d4148;
  background: #23262b;
  font-size: 12px;
}

.topbar-action:hover { border-color: #e82127; }

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(0, 0, 0, .82);
}
.auth-overlay.open { display: flex; }

.auth-dialog {
  width: min(460px, 100%);
  overflow: hidden;
  border: 1px solid #3b3e45;
  border-radius: 12px;
  background: #181a1e;
  box-shadow: 0 22px 70px rgba(0,0,0,.7);
}
.auth-dialog-header {
  padding: 18px 20px;
  border-bottom: 1px solid #33363c;
  background: #202329;
}
.auth-dialog-header h2 { margin: 0; }
.auth-dialog-body { padding: 20px; }
.auth-field { margin-bottom: 14px; }
.auth-field label {
  display: block;
  margin-bottom: 7px;
  color: #a9adb5;
  font-size: 12px;
}
.auth-field input {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid #3a4048;
  border-radius: 8px;
  outline: none;
  background: #101216;
  color: #fff;
}
.auth-field input:focus {
  border-color: #e82127;
  box-shadow: 0 0 0 2px rgba(232,33,39,.12);
}
.auth-message {
  min-height: 20px;
  margin: 0 0 12px;
  color: #a9adb5;
  font-size: 12px;
}
.auth-message.error { color: #ff686d; }
.auth-message.ok { color: #65d786; }
.auth-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

@media (max-width: 700px) {
  .topbar-auth { gap: 6px; }
  .topbar-user { display: none; }
  .topbar-action { padding: 8px 9px; }
}

/* ============================================================
   FIRMWARE FORRAS VALASZTO
   ============================================================ */

.firmware-source-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.source-option {
  min-width: 0;
  padding: 14px 16px;
  border: 1px solid #3a4048;
  border-radius: 10px;
  background: #202329;
  color: #fff;
  text-align: left;
  transition: border-color .16s ease, background .16s ease, box-shadow .16s ease;
}

.source-option:hover:not(:disabled) {
  filter: none;
  border-color: #555b66;
  background: #252930;
}

.source-option.active {
  border-color: #e82127;
  background: #272126;
  box-shadow: 0 0 0 1px rgba(232, 33, 39, .12) inset;
}

.source-option-title {
  display: block;
  margin-bottom: 5px;
  font-size: 14px;
  font-weight: 700;
}

.source-option small {
  display: block;
  color: #9299a4;
  font-size: 11px;
  font-weight: 400;
  line-height: 1.45;
}

.firmware-file-row,
.custom-file-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 12px;
  padding: 14px;
  background: #23272d;
  border: 1px solid #3a4048;
  border-radius: 10px;
}

.firmware-file-row > div,
.custom-file-info {
  min-width: 0;
}

.firmware-file-row span,
.custom-file-info span {
  display: block;
  margin-bottom: 5px;
  color: #8f98a5;
  font-size: 12px;
}

.firmware-file-row strong,
.custom-file-info strong {
  display: block;
  color: #fff;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.firmware-file-row small,
.custom-file-info small {
  display: block;
  margin-top: 5px;
  color: #a9adb5;
  font-size: 11px;
  overflow-wrap: anywhere;
}

.offset-badge {
  flex: 0 0 auto;
  margin: 0 !important;
  padding: 7px 10px;
  border: 1px solid #41464f;
  border-radius: 999px;
  background: #181a1e;
  color: #d9dde4 !important;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 11px !important;
  white-space: nowrap;
}

.custom-firmware-panel[hidden],
#sessionFirmwarePanel[hidden] {
  display: none !important;
}

.custom-file-actions {
  flex: 0 0 auto;
}

.file-input-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.custom-file-warning {
  margin-top: 10px;
  padding: 10px 12px;
  border-left: 3px solid #d7a940;
  background: rgba(215, 169, 64, .08);
  color: #b8b0a0;
  font-size: 11px;
  line-height: 1.5;
}

@media (max-width: 700px) {
  .firmware-source-switch {
    grid-template-columns: 1fr;
  }

  .firmware-file-row,
  .custom-file-box {
    align-items: stretch;
    flex-direction: column;
  }

  .custom-file-actions,
  .custom-file-actions button {
    width: 100%;
  }

  .offset-badge {
    align-self: flex-start;
  }
}


/* ============================================================
   ESP32 FLASH / TORLES
   ============================================================ */

.danger-outline {
  background: transparent;
  border: 1px solid #e82127;
  color: #ff7b7f;
}

.danger-outline:hover:not(:disabled) {
  background: rgba(232, 33, 39, .13);
  color: #fff;
}

.erase-warning {
  margin: 12px 0 0;
  padding: 10px 12px;
  border: 1px solid rgba(232, 33, 39, .32);
  border-radius: 8px;
  background: rgba(232, 33, 39, .06);
  color: #a9adb5;
  font-size: 12px;
  line-height: 1.5;
}

.erase-warning strong { color: #ff7b7f; }

body.flash-busy button {
  cursor: wait;
}


/* ============================================================
   SOROS MONITOR
   ============================================================ */

#monitorBtn.monitor-active {
  background: #2d4735;
  border: 1px solid #4f8c61;
  color: #d9ffe3;
}

#monitorBtn.monitor-active:hover:not(:disabled) {
  background: #36563f;
  filter: none;
}

.serial-monitor-note {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-left: 3px solid #4f8c61;
  background: rgba(79, 140, 97, .08);
  color: #a9adb5;
  font-size: 12px;
  line-height: 1.5;
}

.serial-monitor-note strong {
  color: #d9ffe3;
}
