/* styles.css - app styles (Bootstrap-lite compatible) */

/* Reset-ish */
html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  font-family: sans-serif;
  overflow: hidden; /* prevent body scroll; panels scroll internally */
}

/* Fullscreen map */
#map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

/* Countdown styling */
.countdown-container {
  margin: 2px 0;
  font-family: monospace;
  font-weight: bold;
}

.countdown-item {
  font-family: monospace;
  font-size: 0.85rem;
  margin: 1px 0;
}

.countdown-item.active-pass {
  color: #28a745;
  font-weight: bold;
}

.countdown-item.expired {
  color: #6c757d;
  font-style: italic;
}

.popup-countdown, [data-countdown] {
  font-family: monospace;
  font-weight: bold;
  color: #007bff;
}

.countdown-expired {
  color: #dc3545 !important;
}

/* Current data grid in popup */
.current-data-grid {
  margin: 4px 0;
  font-size: 0.9rem;
}

.data-row {
  display: flex;
  justify-content: space-between;
  margin: 2px 0;
  padding: 1px 0;
}

.data-label {
  font-weight: 500;
  color: #495057;
  min-width: 100px;
}

.data-value {
  font-family: monospace;
  font-weight: bold;
  color: #212529;
}

/* Group tree view */
.group-tree {
  flex: 1 1 auto;
  overflow-y: auto;
  border: 1px solid #dee2e6;
  border-radius: 0.25rem;
  padding: 0.25rem;
  background: #fff;
  min-height: 0; /* Important for flex containers */
}

.group-item {
  display: flex;
  align-items: center;
  padding: 2px 4px;
  cursor: pointer;
  border-radius: 2px;
  font-size: 0.8rem;
  margin: 1px 0;
}

.group-item:hover {
  background: #f8f9fa;
}

.group-item.expanded {
  background: #e9ecef;
}

.group-toggle {
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 4px;
  font-size: 10px;
  color: #6c757d;
  user-select: none;
}

.group-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.group-count {
  font-size: 0.7rem;
  color: #6c757d;
  margin-left: 4px;
}

/* Map satellite icon */
.sat-map-icon {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 11px;
  white-space: nowrap;
  pointer-events: auto;
}
.sat-map-icon .sat-map-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1px solid #000;
  box-sizing: border-box;
}
.sat-map-icon .sat-map-label {
  background: rgba(255,255,255,.85);
  padding: 0 2px;
  border-radius: 2px;
  line-height: 1.1;
  color: #000;
}

/* Observer map marker */
.obs-icon .obs-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #3388ff;
  border: 2px solid #fff;
  box-shadow: 0 0 3px rgba(0,0,0,.8);
}

/* Floating panel basics */
.overlay-card {
  position: absolute;
  z-index: 1000;
  background: rgba(255,255,255,.92);
  border: 1px solid rgba(0,0,0,.15);
  border-radius: .25rem;
  min-width: 180px;
  min-height: 80px;
  pointer-events: auto;
  box-shadow: 0 2px 6px rgba(0,0,0,.2);
  font-size: .875rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Panel header drag area */
.overlay-card .drag-handle {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0,0,0,.05);
  cursor: move;
  padding: 2px 6px;
  font-weight: 600;
  font-size: .9rem;
  flex: 0 0 auto;
}

/* Close button */
.panel-close {
  border: none;
  background: transparent;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  color: #666;
  padding: 0 2px;
}
.panel-close:hover {
  color: #000;
}

/* Panel body scroll for overflow; flex grows */
.overlay-card .panel-body {
  padding: .5rem;
  flex: 1 1 auto;
  overflow: auto;
  max-height: calc(100vh - 100px); /* Leave space for header/footer */
  min-height: 0; /* Important for flex containers */  
}

/* --- Satellite panel body layout --- */
.panel-body-sat {
  display: flex;
  flex-direction: column;
  height: 100%; /* Ensure it fills the available height */
  max-height: none; /* Override the general panel-body max-height for satellites */
}
.panel-body-sat .sat-controls {
  flex: 0 0 auto;
}
#satListWrap {
  flex: 1 1 auto;
  margin-top: .5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
#satList {
  flex: 1 1 auto;
  overflow-y: auto;
}
.sat-list {
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0; /* Important for flex containers */
}

/* Satellite list entries */
.sat-item {
  display: flex;
  align-items: center;
  gap: .25rem;
  margin-bottom: .25rem;
  user-select: none;
  padding: 2px 0;
  font-size: 0.85rem;
  flex-wrap: wrap;
}
.sat-item .sat-color {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex: 0 0 12px;
  border: 1px solid #000;
}
.sat-item .sat-name {
  flex: 1 1 auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.sat-item .sat-azel {
  font-family: monospace;
  font-size: 0.75rem;
  color: #666;
  flex: 0 0 auto;
  text-align: right;
  min-width: 70px;
}
.sat-item .sat-azel.bad-low {
  color: #999;
}
.sat-item .sat-azel.bad-minel {
  color: #ff6600;
}
.sat-item .sat-extended-data {
  font-family: monospace;
  font-size: 0.65rem;
  color: #888;
  width: 100%;
  text-align: left;
  margin-top: 1px;
  word-wrap: break-word;
  line-height: 1.1;
}
.sat-item .sat-eye {
  flex: 0 0 auto;
  font-size: .9rem;
  opacity: .7;
  cursor: pointer;
}
.sat-item.hidden .sat-name {
  text-decoration: line-through;
  opacity: .5;
}
.sat-item.hidden .sat-color {
  opacity: .3;
}
.sat-item.hidden .sat-eye {
  opacity: .3;
}

/* --- Settings panel body layout --- */
.panel-body-params {
  padding: 0.75rem;
}

/* Settings sections */
.settings-section {
  margin-bottom: 1.5rem;
  border: 1px solid #e9ecef;
  border-radius: 0.375rem;
  background: #fafbfc;
  overflow: hidden;
}

.settings-section:last-child {
  margin-bottom: 0;
}

.settings-section-header {
  background: #f8f9fa;
  border-bottom: 1px solid #e9ecef;
  padding: 0.5rem 0.75rem;
}

.settings-section-title {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 600;
  color: #495057;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.settings-icon {
  font-size: 1rem;
}

/* Settings grid layout */
.settings-grid {
  padding: 0.75rem;
  display: grid;
  gap: 0.75rem;
}

.settings-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.settings-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: #6c757d;
  margin-bottom: 0;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.settings-actions {
  padding: 0.5rem 0.75rem;
  background: #f8f9fa;
  border-top: 1px solid #e9ecef;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Observer status */
.observer-status {
  font-size: 0.8rem;
  padding: 0.375rem 0.5rem;
  background: #fff3cd;
  border: 1px solid #ffeaa7;
  border-radius: 0.25rem;
  color: #856404;
  margin: 0.75rem;
  margin-bottom: 0;
}

.observer-status.set {
  background: #d1edff;
  border-color: #bee5eb;
  color: #0c5460;
}

/* Help icons and tooltips */
.help-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  background: #6c757d;
  color: white;
  border-radius: 50%;
  font-size: 10px;
  font-weight: bold;
  cursor: help;
  margin-left: auto;
  position: relative;
  transition: all 0.2s ease;
}

.help-icon:hover {
  background: #495057;
  transform: scale(1.1);
}

/* Tooltip styling */
.help-icon::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 120%;
  right: 0;
  background: #2c3e50;
  color: white;
  padding: 0.5rem;
  border-radius: 0.25rem;
  font-size: 0.7rem;
  line-height: 1.3;
  white-space: normal;
  width: 500px;
  max-width: 400px;
  word-wrap: break-word;
  z-index: 99999; /* Increased z-index to ensure tooltip is above all others */
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.help-icon::after {
  content: '';
  position: absolute;
  bottom: 110%;
  right: 6px;
  width: 0;
  height: 0;
  border: 4px solid transparent;
  border-top-color: #2c3e50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.help-icon:hover::before,
.help-icon:hover::after {
  opacity: 1;
}

/* Button icons */
.btn-icon {
  margin-right: 0.25rem;
  font-size: 0.8em;
}

/* Form improvements */
.panel-body-params .form-control {
  font-size: 0.8rem;
  border: 1px solid #ced4da;
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.panel-body-params .form-control:focus {
  border-color: #80bdff;
  box-shadow: 0 0 0 0.125rem rgba(0, 123, 255, 0.25);
}

.panel-body-params .input-group-sm .btn {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
}

/* Form switch improvements */
.form-check {
  padding: 0.75rem;
  margin: 0;
}

.form-check-label {
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.form-check-input:checked {
  background-color: #198754;
  border-color: #198754;
}

/* Responsive adjustments */
@media (max-width: 480px) {
  .overlay-card[data-panel="params"] {
    width: calc(100vw - 32px) !important;
    max-width: 320px;
  }
  
  .settings-actions {
    flex-direction: column;
  }
  
  .settings-actions .btn {
    width: 100%;
  }
}

/* --- Pass panel body layout: table fills height --- */
.panel-body-pass {
  display: flex;
  flex-direction: column;
}
.panel-body-pass .flex-table-wrapper {
  flex: 1 1 auto;
  width: 100%;
  overflow-y: auto;
}

/* Sortable headers */
.table-sortable th {
  cursor: pointer;
  user-select: none;
}
.table-sortable th.sort-asc::after {
  content: " ▲";
  font-size: .7em;
}
.table-sortable th.sort-desc::after {
  content: " ▼";
  font-size: .7em;
}

/* Resize handle (bottom-right) */
.overlay-card .resize-handle {
  position: absolute;
  width: 14px;
  height: 14px;
  right: 0;
  bottom: 0;
  cursor: se-resize;
  background: linear-gradient(135deg, transparent 50%, rgba(0,0,0,.2) 50%);
}

/* Chips for collapsed panels */
.panel-chip {
  position: absolute;
  z-index: 999;
  padding: .25rem .5rem;
  background: rgba(0,0,0,.7);
  color: #fff;
  font-size: .75rem;
  border-radius: .25rem;
  cursor: pointer;
  user-select: none;
}
#chip-sat { top: .5rem; left: .5rem; display: none; }
#chip-params { top: .5rem; right: .5rem; display: none; }
#chip-pass { bottom: .5rem; left: 50%; transform: translateX(-50%); display: none; }

/* Footer note */
#data-footnote {
  position: absolute;
  bottom: 0.25rem;
  right: 0.5rem;
  z-index: 500;
  background: rgba(255,255,255,.8);
  padding: 0 .5rem;
  border-radius: .25rem;
  font-size: .75rem;
  pointer-events: none;
}

/* local time display */
.local-time {
  font-size: .75em;
  color: #666;
}

#satFilter{width:100%;}

/* --- Satellite list az/el badges --- */
.sat-azel {
  flex: 0 0 auto;
  font-size: 0.75rem;
  color: #333;
  min-width: 70px;
  text-align: right;
}
.sat-azel.bad-low { color: #999; } /* below horizon */
.sat-azel.bad-minel { color: #d00; }

/* Polar panel layout */
.panel-body-pass .polar-pass-wrapper {
  display: flex;
  flex-direction: row;
  gap: .5rem;
  height: 100%;
}
@media (max-width: 480px) {
  .panel-body-pass .polar-pass-wrapper {
    flex-direction: column;
  }
}
.panel-body-pass .flex-table-wrapper {
  flex: 1 1 auto;
}
.polar-wrapper {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.panel-body-polar {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  min-height: 300px;
}

#polarCanvas {
  display: block;
  margin: 0 auto;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #f8f9fa;
}

.sat-azel{flex:0 0 auto;font-size:0.7rem;color:#333;min-width:110px;text-align:right;white-space:nowrap;}

/* Group tree styles */
.group-container {
  margin-bottom: 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #fff;
  /* Remove max-height to allow flexible growth */
  overflow: hidden;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

.group-header {
  padding: 6px 10px;
  background: #f8f9fa;
  border-radius: 3px 3px 0 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
  border-bottom: 1px solid #dee2e6;
  position: sticky;
  top: 0;
  z-index: 10;
  flex-shrink: 0;
}

.group-header:hover {
  background: #e9ecef;
}

.group-toggle {
  font-size: 10px;
  color: #6c757d;
  width: 12px;
}

.group-name {
  font-weight: bold;
  color: #212529;
  flex: 1;
}

.group-count {
  font-size: 0.8rem;
  color: #6c757d;
}

.group-visibility {
  font-size: 0.7rem;
  color: #28a745;
  font-weight: normal;
}

.group-scrollable-content {
  flex: 1;
  overflow-y: auto;
  /* Remove max-height to allow flexible growth */
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.group-controls {
  padding: 6px 10px;
  background: #f8f9fa;
  border-bottom: 1px solid #dee2e6;
  display: flex;
  gap: 4px;
  position: sticky;
  top: 0;
  z-index: 9;
  flex-shrink: 0;
}

.satellite-list {
  padding: 4px 0;
  background: #fff;
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0; /* Important for flex containers */
}

.satellite-list .sat-item {
  margin-left: 20px;
  padding: 3px 10px 3px 0;
}
