/* ==========================================================================
   IW0RQH - ALL-SKY OBSERVATORY STYLESHEET
   Sottodominio: allskycam.iw0rqh.it
   Layout per Frame Fisheye, Panorama 360°, Timelapse, Keogramma e Telemetrie
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. STRUTTURA & SPAZIATURE GLOBALI
   -------------------------------------------------------------------------- */
.container {
  padding-right: 24px !important;
  box-sizing: border-box;
}

.allsky-stack {
  display: flex;
  flex-direction: column;
  gap: 22px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding-right: 15px; /* Spazio di sicurezza rispetto al menu destro */
}

/* --------------------------------------------------------------------------
   2. INTESTAZIONI CARD & BADGE DI STATO SUPERIORI
   -------------------------------------------------------------------------- */
.card-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.card-header-bar h3 {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.05rem;
  font-weight: 700;
  color: #f1f5f9;
}

/* Gruppo contenitore per Timestamp e Modalità Sole/Luna */
.header-meta-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Timestamp compatto con icona orologio */
.meta-item-ts {
  font-size: 0.8rem;
  color: #94a3b8;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.03);
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.meta-item-ts i {
  color: #38bdf8;
  font-size: 0.85rem;
}

/* Badge Modalità: Dinamico con Sole / Luna */
.badge-mode {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  letter-spacing: 0.3px;
  transition: all 0.3s ease;
}

/* Modalità Notte: Luna ciano con bagliore */
.badge-mode.night {
  background: rgba(56, 189, 248, 0.12);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.badge-mode.night i {
  color: #38bdf8;
  filter: drop-shadow(0 0 4px rgba(56, 189, 248, 0.6));
}

/* Modalità Giorno: Sole caldo dorato */
.badge-mode.day {
  background: rgba(245, 158, 11, 0.12);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-mode.day i {
  color: #f59e0b;
  filter: drop-shadow(0 0 5px rgba(245, 158, 11, 0.5));
}

/* Badge informativo generico */
.badge-tag {
  font-size: 0.72rem;
  font-weight: 600;
  color: #8c9bb0;
  background: rgba(255, 255, 255, 0.04);
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

/* --------------------------------------------------------------------------
   3. FRAME 1: FISHEYE LIVE CIRCOLARE (IMX477)
   -------------------------------------------------------------------------- */
.allsky-large-viewer {
  width: 100%;
  box-sizing: border-box;
}

.allsky-large-frame {
  position: relative;
  width: 100%;
  height: auto;
  aspect-ratio: auto;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.05);
  display: block;
}

.allsky-large-frame img {
  width: 100%;
  height: auto;
  max-width: 100%;
  display: block;
  object-fit: contain;
}

/* --------------------------------------------------------------------------
   4. FRAME 2: PANORAMA 360° SROTOLATO (SCROLLABILE CON DRAG MOUSE)
   -------------------------------------------------------------------------- */
.allsky-panorama-viewer {
  width: 100%;
  box-sizing: border-box;
}

.allsky-panorama-viewport {
  position: relative;
  width: 100%;
  height: 280px;
  background: #000;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  overflow-x: auto;
  overflow-y: hidden;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -webkit-overflow-scrolling: touch;
}

.allsky-panorama-viewport:active,
.allsky-panorama-viewport.is-dragging {
  cursor: grabbing !important;
  scroll-behavior: auto;
}

.allsky-panorama-viewport img {
  height: 100%;
  width: auto;
  max-width: none;
  display: block;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
}

.allsky-panorama-viewport::-webkit-scrollbar {
  height: 6px;
}
.allsky-panorama-viewport::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.4);
  border-radius: 4px;
}
.allsky-panorama-viewport::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}
.allsky-panorama-viewport::-webkit-scrollbar-thumb:hover {
  background: #38bdf8;
}

.frame-overlay-ts {
  position: absolute;
  bottom: 8px;
  left: 8px;
  background: rgba(10, 14, 23, 0.85);
  backdrop-filter: blur(4px);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  color: #cbd5e1;
  border: 1px solid rgba(255, 255, 255, 0.1);
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   5. TIMELAPSE: FISHEYE STANDARD & PANORAMICO 360° (DEFISHEYE)
   -------------------------------------------------------------------------- */
.allsky-timelapse-viewer,
.allsky-panorama-timelapse-viewer {
  width: 100%;
  box-sizing: border-box;
}

.timelapse-video-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
}

.timelapse-video-wrapper video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  background: #000;
}

.panorama-video-wrapper {
  position: relative;
  width: 100%;
  height: auto;
  min-height: 0;
  aspect-ratio: auto;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: block;
}

.panorama-video-wrapper video {
  width: 100%;
  height: auto;
  max-height: none;
  display: block;
  object-fit: contain;
  background: #000;
}

/* ==========================================================================
   KEOGRAMMA DELLA SESSIONE (Adattamento Piena Larghezza 100%)
   ========================================================================== */

.allsky-keogram-viewer {
  width: 100%;
  box-sizing: border-box;
}

/* Contenitore flessibile: si adatta all'altezza naturale dell'immagine */
.allsky-keogram-viewport {
  position: relative;
  width: 100%;
  height: auto;             /* Rimuove l'altezza fissa che creava i vuoti neri */
  min-height: 120px;
  background: #000;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  overflow: hidden;
  display: block;
}

/* L'immagine occupa tutto lo spazio orizzontale preservando le proporzioni reali */
.allsky-keogram-viewport img {
  width: 100% !important;   /* Si estende per l'intera larghezza della card */
  height: auto !important;  /* L'altezza scala perfettamente senza schiacciare */
  max-width: 100%;
  display: block;
  object-fit: fill;         /* Riempie il perimetro da bordo a bordo */
  pointer-events: auto;
  user-select: none;
}

/* Selettore alternativo se presente nel template */
.keogram-frame-wrapper {
  position: relative;
  width: 100%;
  height: auto;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: block;
}

.keogram-frame-wrapper img {
  width: 100% !important;
  height: auto !important;
  max-width: 100%;
  display: block;
  object-fit: fill;
}

/* --------------------------------------------------------------------------
   7. PULSANTI D'AZIONE & NOTE INFORMATIVE
   -------------------------------------------------------------------------- */
.viewer-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.hint-text {
  font-size: 0.76rem;
  color: #8c9bb0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-action {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #f1f5f9;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  transition: all 0.2s ease;
}

.btn-action:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

/* --------------------------------------------------------------------------
   1. STRUTTURA & SPAZIATURE GLOBALI (NO SBORDAMENTI)
   -------------------------------------------------------------------------- */
.container {
  box-sizing: border-box;
}

.allsky-stack {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden; /* Blocca qualsiasi traboccamento orizzontale */
}

/* ==========================================================================
   STRUTTURA & GRIGLIA TELEMETRIA (PERFETTO ALLINEAMENTO 100%)
   ========================================================================== */

.allsky-stack {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding-right: 0 !important; /* Rimuove il vecchio padding che faceva uscire le card a destra */
}

.allsky-data-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  width: 100%;
  box-sizing: border-box;
}

@media (max-width: 1100px) {
  .allsky-data-grid {
    grid-template-columns: 1fr;
  }
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.metric-box {
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  min-width: 0;
  box-sizing: border-box;
}

.metric-box .lbl {
  color: #8c9bb0;
  font-size: 0.72rem;
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.metric-box .val {
  font-size: 1.25rem;
  font-weight: 700;
  color: #f8fafc;
  line-height: 1.2;
}

.metric-box .sub {
  color: #64748b;
  font-size: 0.68rem;
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Colori dinamici per il delta termico anticondensa */
.delta-safe {
  color: #2ed573 !important; /* Verde brillante */
}
.delta-warn {
  color: #ffa502 !important; /* Arancione allerta */
}
.delta-danger {
  color: #ff4757 !important; /* Rosso rischio rugiada */
}