/* ════════════════════════════════════════════════════════════
   UI Components — styled to match Grafana's dark theme
   ════════════════════════════════════════════════════════════ */

/* ── Panel (base) ─────────────────────────────────────────── */
.panel {
  background: var(--bg-primary);
  border: none;
  overflow: hidden;
}

.panel-title {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-secondary);
  padding: 8px 12px 6px;
  border: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.panel-body {
  padding: 12px;
}

/* Transparent panels (logo, instructions, glossary) */
.panel-transparent {
  background: transparent;
  border: none;
}

/* ── Header: Logo ────────────────────────────────────────── */
.area-logo {
  background: #003399;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  aspect-ratio: 1 / 1;   /* cuadrado */
}
.area-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ── Header: Title + description ─────────────────────────── */
.area-title {
  background: transparent;
  border: none;
  padding: 14px 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.area-title h1 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}
.area-title p {
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 6px;
  font-size: 13px;
}
.area-title ol {
  color: var(--text-secondary);
  padding-left: 18px;
  line-height: 1.8;
  font-size: 13px;
}
.area-title .hl { color: var(--text-link); }

/* ── Form panel ───────────────────────────────────────────── */
.form-fields {
  display: flex;
  flex-direction: row;
  gap: 16px;
  align-items: flex-start;
}

/* Left column: coordinate inputs stacked — ancho mínimo para que quepan label+input */
.form-inputs {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 300px;
}

/* Right column: constellations + buttons — ancho fijo, no encoge */
.form-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  justify-content: flex-start;
  padding-top: 2px;
  flex-shrink: 0;
  min-width: 160px;
}

/* On narrow screens stack them back vertically */
@media (max-width: 600px) {
  .form-fields { flex-direction: column; }
}

/* Volkovlabs-style form row: [blue label] [input] */
.form-row {
  display: flex;
  align-items: stretch;
  overflow: hidden;
  height: 32px;
}

.form-row .f-label {
  background: var(--label-bg);
  color: #d0daf8;
  font-size: 12px;
  font-weight: bold;
  border-radius: var(--r-lg);
  padding: 0 10px;
  display: flex;
  align-items: center;
  white-space: nowrap;
  min-width: 110px;
  flex-shrink: 0;
}

.form-row input[type="number"],
.form-row input[type="datetime-local"] {
  flex: 1;
  background: transparent;
  border-radius: var(--r-lg);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  font-size: 13px;
  padding: 0 10px;
  outline: none;
  min-width: 0;
  margin-left: 8px;
}
.form-row input:focus { border-color: var(--border-selected); }
/* Remove native datetime spinner arrows */
.form-row input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.form-row input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  filter: invert(85%) sepia(15%) saturate(300%) hue-rotate(180deg);
  cursor: pointer;
}

/* Constellation filter checkboxes */
.constellation-row {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 4px 0;
}
.constellation-row label.c-label {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: 4px;
}
.constellation-row label.c-option {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  color: var(--text-disabled);
  cursor: pointer;
  transition: color 0.15s ease;
}
.constellation-row label.c-option:has(input:checked) {
  color: var(--text-secondary);
}
.constellation-row input[type="checkbox"] {
  appearance: none;
  width: 14px;
  height: 14px;
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  background: transparent;
  cursor: pointer;
  position: relative;

  transition: all 0.15s ease;
}
.constellation-row input[type="checkbox"]:checked {
  background: var(--border-selected);
  border-color: var(--text-secondary);
}
/* Action buttons */
.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: none;
  border-radius: var(--r-lg);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: filter 0.15s;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { filter: brightness(1.12); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-update  { background: #aad8a4; color: var(--bg-canvas); border: none; }
.btn-geo     { background: var(--bg-secondary); color: var(--text-primary); border: 1px solid var(--border-medium); }

/* Status message */
#status-msg {
  margin-top: 8px;
  font-size: 12px;
  min-height: 18px;
}
.status-loading { color: var(--c-blue); }
.status-success { color: var(--c-green); }
.status-error   { color: var(--c-red); }
.status-warning { color: var(--c-orange); }

/* ── KPI stat cards ───────────────────────────────────────── */
.kpi-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 90px;
}
.kpi-card .panel-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 10px 14px;
}
.kpi-title {
  font-size: 11px;
  font-weight: bold;
  color: var(--text-secondary);
  line-height: 1.3;
  margin-bottom: 6px;
}
.kpi-value {
  font-size: 38px;
  font-weight: 300;
  line-height: 1;
  letter-spacing: -0.5px;
  color: var(--text-primary);
}
.kpi-threshold {
  font-size: 11px;
  color: var(--text-disabled);
  margin-top: 5px;
}

/* Threshold coloring */
.kpi-ok   .kpi-value { color: var(--c-green-light); }
.kpi-fail .kpi-value { color: var(--c-red); }

/* Bargauge (PDOP %) */
.bargauge-value {
  font-size: 28px;
  font-weight: 300;
  color: var(--text-primary);
  margin-bottom: 6px;
}
.bargauge-track {
  height: 6px;
  background: var(--bg-secondary);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 2px;
}
.bargauge-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease, background-color 0.5s ease;
}

/* ── Mini stat (visible satellite counters) ───────────────── */
.mini-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px 8px;
  text-align: center;
  min-height: 70px;
}
.mini-stat-value {
  font-size: 30px;
  font-weight: 300;
  color: var(--c-blue-light);
  line-height: 1;
}
.mini-stat-label {
  font-size: 10px;
  color: var(--text-secondary);
  margin-top: 4px;
  line-height: 1.3;
}

/* ── PDOP table ───────────────────────────────────────────── */
.pdop-table { width: 100%; border-collapse: collapse; }
.pdop-table tr { border: none; }
.pdop-table tr:last-child { border-bottom: none; }
.pdop-table td {
  padding: 7px 4px;
  font-size: 12px;
}
.pdop-table td:first-child { color: var(--text-secondary); }
.pdop-table td:last-child  { text-align: right; font-weight: 600; }

/* ── Satellite status cells ───────────────────────────────── */
.sat-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  padding: 4px 0 2px;
}

/* textMode: "name", colorMode: "background" — matches Grafana exactly */
.sat-cell {
  padding: 4px 8px;
  border-radius: var(--r);
  font-size: 13px;
  font-weight: 500;
  min-width: 40px;
  text-align: center;
  cursor: default;
}

/* OSNMA: 0=gray(unavail), 1=blue(no auth), 2=green(auth) */
.sc-gray  { background: var(--cell-gray-bg);  color: var(--cell-gray-text); }
.sc-blue  { background: var(--cell-blue-bg);  color: var(--cell-blue-text); }
.sc-green { background: var(--cell-green-bg); color: var(--cell-green-text); }

/* ── Glossary (collapsible <details>) ─────────────────────── */
.db-glossary { cursor: default; }
.db-glossary-summary {
  cursor: pointer;
  list-style: none;          /* hide the default triangle on some browsers */
  user-select: none;
}
.db-glossary-summary::-webkit-details-marker { display: none; }
.db-glossary-summary::before {
  content: '▶ ';
  font-size: 9px;
  color: var(--text-disabled);
  transition: transform 0.15s;
  display: inline-block;
}
details[open] .db-glossary-summary::before { content: '▼ '; }

.glossary-list {
  list-style: none;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.9;
}
.glossary-list abbr {
  font-weight: 600;
  color: var(--text-primary);
  text-decoration: none;
}

/* ── Viz panel title row ──────────────────────────────────── */
.panel-viz .panel-title {
  font-size: 11px;
}

/* ── Spinner ──────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 11px; height: 11px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 4px;
}
@keyframes spin { to { transform: rotate(360deg); } }
