/* ============================================================
   dashboard.css SP2ONG - 2025-11-03
   ============================================================ */

/* ============================================================
   1. PODSTAWOWE STYLE BODY I MOTYWÓW
   ============================================================ */

body {
  font: 11pt Arial, sans-serif;
  color: white;
  text-align: center;
  transition: background-color 0.5s ease, color 0.5s ease;
  zoom: 100%; 
}

/* Tryb nocny (domyślny) */
body.dark-mode {
  background-color: #393a3d;
  color: white;
}

/* Tryb jasny (stonowany, nie oślepiający) */
body.light-mode {
  background-color: #b8b8b8;
  color: #1e1e1e;
}

/* ============================================================
   2. FIELDSET (RAMKI SEKCJI)
   ============================================================ */

fieldset {
  box-shadow: 0 0 10px #222;
  border: 1px solid #4a4a4a;
  border-radius: 10px;
  background-color: #7a7784;
  background-image: linear-gradient(to bottom, #86838f 0%, #6d6a77 100%);
  padding: 14px 18px;
  margin: 18px auto;
  width: 880px;
  font-size: 13px;
  transition: all 0.3s ease;
}

fieldset:hover {
  box-shadow: 0 0 15px rgba(255, 255, 255, 0.3);
}

/* Indywidualne tła ramek */
fieldset:nth-of-type(1) { /* Aktywne QSO */
  background-image: linear-gradient(to bottom, #b5b5b5 100%, #b5b5b5 100%);
  color: black;
}

fieldset:nth-of-type(2) { /* Ostatnio słyszane */
  background-image: linear-gradient(to bottom, #7a7784 0%, #7a7784 100%);
  color: white;
}

fieldset:nth-of-type(3) { /* Wykaz nodów */
  background-image: linear-gradient(to bottom, #7a7774 90%, #a0a0a0 100%);
  color: black;
  box-shadow: 0 0 12px #444 inset, 0 0 10px #555;
}

/* Ramki w trybie jasnym */
body.light-mode fieldset {
  background-image: linear-gradient(to bottom, #bfbfbf 0%, #9f9f9f 100%);
  border: 1px solid #7a7a7a;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.25);
  color: #202020;
}

body.light-mode fieldset:nth-of-type(3) {
  background-image: linear-gradient(to bottom, #9e9e9e 0%, #7f7f7f 100%);
}

/* ============================================================
   3. NAGŁÓWKI (H2)
   ============================================================ */

h2 {
  margin: 0 0 10px 0;
  text-shadow: 1px 1px 2px #000;
  letter-spacing: 0.5px;
  font-weight: bold;
  font-size: 12pt;
  color: white;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI",'Oswald', 
                Roboto, "Helvetica Neue", Arial, sans-serif;
  position: relative;
  padding-bottom: 6px;
  margin-bottom: 12px;
}

/* Dekoracyjna linia pod nagłówkami */
h2::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 60%;
  height: 2px;
  background: linear-gradient(to right, transparent, rgba(255,255,255,0.7), transparent);
  border-radius: 1px;
}

/* Nagłówki w trybie ciemnym */
body.dark-mode fieldset h2 {
  color: #ffffff;
  text-shadow: 1px 1px 2px #000;
}

body.dark-mode fieldset:nth-of-type(1) h2 {
  color: #003366;
  text-shadow: none;
}

/* Nagłówki w trybie jasnym */
body.light-mode fieldset h2::after {
  background: linear-gradient(to right, transparent, rgba(40,40,40,0.35), transparent);
}

body.light-mode fieldset:nth-of-type(1) h2,
body.light-mode fieldset:nth-of-type(3) h2 {
  color: #222222;
  text-shadow: none;
}

body.light-mode fieldset:nth-of-type(2) h2 {
  color: #003366;
  text-shadow: none;
}

/* Dodatkowy akcent dla "Ostatnio słyszane stacje" */
fieldset:nth-of-type(2) h2::after {
  background: linear-gradient(to right, transparent, rgba(255,255,255,0.7), transparent);
  opacity: 0.8;
}

/* Node count w sekcji wykazu nodów */
fieldset:nth-of-type(3) #nodeCount {
  color: yellow;
}

/* ============================================================
   4. AKTYWNE QSO
   ============================================================ */

#activeQSO {
  min-height: 60px;
  line-height: 1.6;
  font-weight: bold;
  font-size: 10pt;
  font-family: 'Oswald', Roboto, -apple-system, BlinkMacSystemFont, 
             "Segoe UI", "Helvetica Neue", Arial, sans-serif; 
}

.callsign {
  color: #223bc9;
  font-weight: bold;
  font-size: 13pt;
  font-family: 'Oswald', Roboto, -apple-system, BlinkMacSystemFont, 
             "Segoe UI", "Helvetica Neue", Arial, sans-serif; 
}

.arrow {
  color: red;
  font-weight: bold;
  font-size: 13pt;
  font-family: 'Oswald', Roboto, -apple-system, BlinkMacSystemFont, 
             "Segoe UI", "Helvetica Neue", Arial, sans-serif; 
}

.tg {
  color: #7b3f00;
  font-weight: bold;
  font-size: 13pt;
  font-family: 'Oswald', Roboto, -apple-system, BlinkMacSystemFont, 
             "Segoe UI", "Helvetica Neue", Arial, sans-serif; 
}

/* ============================================================
   5. TABELA (OSTATNIO SŁYSZANE)
   ============================================================ */

table {
  border-collapse: collapse;
  width: 100%;
  /* font-family: "Lucida Console", Monaco, monospace; */
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", 
               Roboto, "Helvetica Neue", Arial, sans-serif;
  border: 1px solid #454545;
  transition: all 0.5s ease;
}

table th {
  text-align: left;
  background: #2595dd;
  color: white;
  text-shadow: 0px 0px #8b0000;
  border: 1px solid #454545;
  padding: 4px 0px 2px 16px;
  white-space: nowrap;
  font-size: 15px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", 
               Roboto, "Helvetica Neue", Arial, sans-serif;
}

table td {
  border: 1px solid #454545;
  padding: 4px 4px;
  font-weight: bold;
  color: #222222;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", 
               Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Kolory wierszy naprzemienne */
table tr:nth-child(even) {
  background: #c5c5c5;
  color: black;
}

table tr:nth-child(odd) {
  background: #afb1b2;
  color: black;
}

/* Wyrównanie kolumn */
td:first-child,
td:nth-child(2),
td:nth-child(3) {
  text-align: left;
  padding-left: 8px;
}

td:last-child {
  text-align: center;
}

.time-last {
  white-space: nowrap;
  font-weight: bold;
  font-size: 10.5pt; 
}

.callsign-last {
  color: #123287;
  font-weight: bold;
}

.tg-last {
  color: #7b3f00;
  font-weight: bold;
  font-size: 10.5pt; 
}

/* Tabela w trybie jasnym */
body.light-mode table th {
  background-color: #457fa3;
  color: #ffffff;
}

body.light-mode table tr:nth-child(even) {
  background: #bdbdbd;
}

body.light-mode table tr:nth-child(odd) {
  background: #a8a8a8;
}

/* ============================================================
   6. PRZYCISKI NODÓW
   ============================================================ */

.nodes-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin-top: 8px;
}

.nodeButton {
  display: flex;
  align-items: center;
  position: relative;
  justify-content: center;
  width: 125px;
  height: 30px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s ease, box-shadow 0.15s ease, all 0.2s ease-in-out;
  padding: 2px;
  margin-top: 3px;
  text-align: center;
  font-weight: 600;
}

.nodeButton:hover {
  transform: scale(1.06);
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.6);
  filter: brightness(1.15);
}

.nodeIcon {
  position: absolute;
  left: 4px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 15px;
  padding: 0px 0px 5px 0px;
}

.nodeText {
  flex: 1;
  text-align: center;
  font-weight: bold;
  font-size: 10pt;
  /* font-family: arial, sans-serif; */
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", 
               Roboto, "Helvetica Neue", Arial, sans-serif; 
  text-shadow: none;
}

.nodeMedal {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 15px;
}

/* Kolory dla różnych typów nodów */
.nodeButton.talker {
  background-image: linear-gradient(to bottom, #ff4e50 0%, #f60000 100%);
  color: #fff;
  border: 1px solid #800;
}

.nodeButton.type1 {
  background-image: linear-gradient(to bottom, #337ab7 0%, #265a88 100%);
  color: white;
}

.nodeButton.type2 {
  background-image: linear-gradient(to bottom, #1ca9c9 20%, #0047ab 100%);
  color: white;
}

.nodeButton.type3 {
  background-image: linear-gradient(to bottom, #20cf52 30%, #4aa02c 100%);
  color: #000;
}

.nodeButton.type4 {
  background-image: linear-gradient(to bottom, #b37b4b 0%, #835c3b 100%);
  color: #fff;
}

.nodeButton.type5 {
  background-image: linear-gradient(to bottom, #b37b4b 0%, #835c3b 100%);
  color: #ffffff;
}

.nodeButton.type6 {
  background-image: linear-gradient(to bottom, #656565 0%, #212121 100%);
  color: #fff;
}

.nodeButton.type7 {
  background-image: linear-gradient(to bottom, #4a9fd8 0%, #1f5e85 100%);
  color: #fff;
}

/* Dla nodów LATRY (bez typu) - wygląd jak Type 4 */
.nodeButton.type {
  background-image: linear-gradient(to bottom, #b37b4b 0%, #835c3b 100%);
  color: #fff;
}

/* Efekty dla ciemnego i jasnego trybu */
body.dark-mode .nodeButton {
  box-shadow: 0 0 5px rgba(255, 255, 255, 0.1);
}

body.light-mode .nodeButton {
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
}

/* ============================================================
   7. TOOLTIP
   ============================================================ */

#tooltip {
  display: none;
  position: fixed;
  min-width: 260px;
  background: rgba(50, 50, 50, 0.9);
  backdrop-filter: blur(6px);
  color: #fff;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.8);
  z-index: 1000;
  padding: 12px;
  font-size: 13px;
  max-width: 300px;
  text-align: left;
  transition: all 0.3s ease-in-out, all 0.5s ease;
}

#tooltip h3 {
  margin: 0 0 6px 0;
  font-size: 15px;
  color: #f7d44c;
}

#tooltip p {
  margin: 4px 0;
  line-height: 1.3em;
}

#tooltip button,
#tooltip .close {
  float: right;
  position: absolute;
  top: 15px;
  right: 10px;
  background: transparent;
  border: none;
  color: #ccc;
  font-size: 14px;
  cursor: pointer;
}

/* Tooltip w trybie jasnym */
body.light-mode #tooltip {
  background: rgba(180, 180, 180, 0.97);
  color: #202020;
  border: 1px solid rgba(0, 0, 0, 0.15);
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.35);
}

body.light-mode #tooltip h3 {
  color: #0077b6;
}

body.light-mode #tooltip button {
  color: black;
}

/* ============================================================
   8. PRZYCISK ZMIANY TRYBU
   ============================================================ */

#themeToggle {
  position: fixed;
  top: 10px;
  right: 10px;
  background-color: #4a4a4a;
  color: white;
  border: none;
  border-radius: 20px;
  padding: 6px 14px;
  cursor: pointer;
  font-weight: bold;
  box-shadow: 0 0 5px #000;
  transition: all 0.3s ease;
  z-index: 999;
}

#themeToggle:hover {
  background-color: #666;
}

body.light-mode #themeToggle {
  background-color: #555;
  color: #f0f0f0;
}

/* ============================================================
   9. REGULACJA JASNOŚCI
   ============================================================ */

#brightnessControl {
  position: fixed;
  top: 55px;
  right: 10px;
  background: rgba(50, 50, 50, 0.55);
  border-radius: 10px;
  padding: 6px 10px;
  box-shadow: 0 0 8px rgba(0,0,0,0.3);
  z-index: 999;
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  gap: 6px;
}

body.light-mode #brightnessControl {
  background: rgba(245, 245, 245, 0.9);
  color: #222;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

#brightnessControl label {
  font-size: 11px;
  font-weight: 600;
  color: #f0f0f0;
  text-shadow: 0 0 2px rgba(0,0,0,0.6);
  user-select: none;
}

body.light-mode #brightnessControl label {
  color: #222;
  text-shadow: none;
}

#brightnessRange {
  vertical-align: middle;
  width: 80px;
  accent-color: #007acc;
}

#brightnessIcon {
  font-size: 13px;
  color: #ffd700;
  text-shadow: 0 0 4px rgba(255, 255, 255, 0.5);
}

/* ============================================================
   10. STATUS POŁĄCZENIA WEBSOCKET
   ============================================================ */

#connectionStatus {
  position: fixed;
  top: 12px;
  left: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: bold;
  color: white;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 20px;
  padding: 4px 10px;
  box-shadow: 0 0 5px #000;
  z-index: 999;
}

#statusDot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  background-color: gray;
  box-shadow: 0 0 5px #000;
}

/* Kolory statusu */
.status-connected #statusDot {
  background-color: #00ff3c;
  box-shadow: 0 0 8px #00ff3c;
}

.status-connecting #statusDot {
  background-color: #ffcc00;
  box-shadow: 0 0 8px #ffcc00;
}

.status-disconnected #statusDot {
  background-color: #ff3c3c;
  box-shadow: 0 0 8px #ff3c3c;
}

body.light-mode #connectionStatus {
  background: rgba(255, 255, 255, 0.7);
  color: black;
  box-shadow: 0 0 4px #666;
}

/* ============================================================
   11. EKRAN ŁADOWANIA DANYCH
   ============================================================ */

#loadingOverlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  color: white;
  font-family: "Segoe UI", Arial, sans-serif;
  flex-direction: column;
  text-align: center;
  transition: opacity 0.5s ease;
}

#loadingOverlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.loadingBox {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.loadingBox p {
  font-size: 1.2em;
  margin-top: 28px;
  line-height: 1.4em;
}

.loadingFooter {
  margin-top: 16px;
  font-size: 0.8em;
  color: #ccc;
  letter-spacing: 0.5px;
}

body.light-mode .loadingFooter {
  color: #666;
}

/* Pulsujący pierścień z efektem radarowego błysku */
.spinner {
  position: relative;
  width: 70px;
  height: 70px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.spinner::before,
.spinner::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 4px solid #4fc3f7;
  opacity: 0.6;
  animation: pulse 1.8s infinite ease-in-out;
}

.spinner::after {
  animation-delay: 0.9s;
  box-shadow: 0 0 25px rgba(79, 195, 247, 0.4);
}

.spinner::before {
  mask-image: conic-gradient(
    from 0deg,
    transparent 0deg,
    rgba(255, 255, 255, 0.9) 40deg,
    transparent 60deg
  );
  -webkit-mask-image: conic-gradient(
    from 0deg,
    transparent 0deg,
    rgba(255, 255, 255, 0.9) 40deg,
    transparent 60deg
  );
  animation: pulse 1.8s infinite ease-in-out, rotateBeam 2.8s linear infinite;
}

@keyframes pulse {
  0%   { transform: scale(0.6); opacity: 0.9; }
  70%  { transform: scale(1.2); opacity: 0.3; }
  100% { transform: scale(0.6); opacity: 0.9; }
}

@keyframes rotateBeam {
  0%   { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Wersja nocna spinnera z turkusowym blaskiem */
body.dark-mode .spinner::before,
body.dark-mode .spinner::after {
  border-color: #00bcd4;
  box-shadow: 0 0 35px rgba(0, 188, 212, 0.45),
              0 0 60px rgba(0, 188, 212, 0.25);
}

body.dark-mode .spinner::before {
  animation: pulse 2s infinite ease-in-out, rotateBeamDark 3.5s linear infinite;
}

@keyframes rotateBeamDark {
  0%   { transform: rotate(0deg); filter: brightness(1.2); }
  50%  { filter: brightness(0.9); }
  100% { transform: rotate(360deg); filter: brightness(1.2); }
}

/* Jasny motyw - inny odcień niebieskiego */
body.light-mode .spinner::before,
body.light-mode .spinner::after {
  border-color: #2595dd;
  box-shadow: 0 0 20px rgba(37, 149, 221, 0.25);
}

/* ============================================================
   12. RESPONSYWNOŚĆ - TABLET (max-width: 1024px)
   ============================================================ */

@media (max-width: 1024px) {
  .top-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin: 10px auto;
    text-align: center;
  }

  #connectionStatus,
  #themeToggle,
  #brightnessControl {
    position: static !important;
    margin: 0 !important;
  }

  body.dark-mode #brightnessControl {
    display: none !important;
  }

  body.light-mode #brightnessControl {
    display: flex !important;
    align-items: center;
  }

  #brightnessControl label {
    margin-right: 5px;
  }

  fieldset h2 {
    text-align: center;
    margin-top: 10px;
  }

  /* Zapobieganie efektowi zoom */
  html, body {
    touch-action: manipulation !important;
    -webkit-text-size-adjust: none !important;
  }

  fieldset {
    touch-action: manipulation !important;
    transform: none !important;
    -webkit-transform: none !important;
  }

  button, .nodeButton {
    -webkit-tap-highlight-color: transparent !important;
    -webkit-user-select: none !important;
    user-select: none !important;
  }

  input, select, textarea {
    font-size: 16px !important;
  }

  #tooltip {
    position: absolute; /* zmiana z fixed na absolute */
    min-width: 200px;
    max-width: 280px;
    font-size: 12px;
    padding: 10px;
    /* Usuń wcześniej ustawione top/left jeśli były */
    top: auto;
    left: auto;
  }
  
  #tooltip h3 {
    font-size: 14px;
  }
  
  #tooltip button,
  #tooltip .close {
    top: 8px;
    right: 8px;
    font-size: 16px;
  }

}

/* ============================================================
   13. RESPONSYWNOŚĆ - MOBILE (max-width: 600px)
   ============================================================ */

@media (max-width: 600px) {
  /* Mniejsze marginesy i fonty */
  body {
    font-size: 0.9em;
    padding: 5px;
  }

  fieldset {
    width: 96% !important;
    margin: 6px auto !important;
    padding: 6px !important;
    border-radius: 10px;
    touch-action: none;
    overflow: hidden;
  }

  fieldset h2 {
    font-size: 1em;
    margin-bottom: 6px;
  }

  /* Aktywne QSO - bardziej kompaktowe */
  #activeQSO {
    font-size: 0.95em;
    line-height: 1.3em;
  }

  /* Tabela ostatnio słyszane */
  #lastHeardTable th, 
  #lastHeardTable td {
    padding: 3px 4px;
    font-size: 0.85em;
  }

  #lastHeardTable th {
    font-weight: bold;
  }

  /* Ukrycie ikon i medali */
  .nodeIcon,
  .nodeMedal {
    display: none !important;
  }

  /* Przyciski nodów */
  .nodeButton {
    width: 100px !important;
    min-height: 40px !important;
    font-size: 1em !important;
    justify-content: center !important;
    padding: 6px 4px !important;
    margin: 3px !important;
    line-height: 1.2 !important;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    outline: none;
  }

  .nodeText {
    text-align: center !important;
    font-size: 0.95em !important;
    padding: 0 6px !important;
    white-space: nowrap !important;
  }

  /* Tooltip na całą szerokość ekranu */
  #tooltip {
    max-width: 95vw;
    font-size: 0.85em;
    padding: 6px;
  }

  /* Pasek z połączeniem, motywem i jasnością */
  .top-bar {
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 6px;
  }

  #connectionStatus, 
  #themeToggle, 
  #brightnessControl {
    font-size: 0.85em;
  }

  #connectionStatus span, 
  #themeToggle span, 
  #brightnessControl span {
    vertical-align: middle;
  }

  .qso-entry {
    font-size: 0.9em;
  }

#tooltip {
    position: absolute; /* zmiana z fixed na absolute */
    min-width: 200px;
    max-width: 280px;
    font-size: 12px;
    padding: 10px;
    /* Usuń wcześniej ustawione top/left jeśli były */
    top: auto;
    left: auto;
  }
  
  #tooltip h3 {
    font-size: 14px;
  }
  
  #tooltip button,
  #tooltip .close {
    top: 8px;
    right: 8px;
    font-size: 16px;
  }

}