/*
===============================================================================
  GENESIS PREDICT - Estilos do painel de manutenção preditiva
===============================================================================
  Prefixo .pdt-* / #pdtModal. Segue o MODELO DE JANELA do AIoT:
   - janela flutuante semi-transparente (opaca no hover), arrastável pelo
     header, redimensionável pelo canto (resize: both)
   - header compacto com ícones de janela (⌃ recolher, ⤢ fullscreen,
     − minimizar, ✕ fechar)
   - filter bar com busca, chips de classe, botões de visão (▦ cards /
     ≡ tabela) e refresh
   - fullscreen estica a janela e escurece o backdrop
*/

.pdt-modal{
  position: fixed;
  inset: 0;
  z-index: 9100;
  display: none;
  font-family: 'Rajdhani', 'Orbitron', sans-serif;
  color: #e0f7ff;
  pointer-events: none;      /* cliques passam - só a janela captura */
}
.pdt-modal.pdt-open{ display: block; }

.pdt-modal-backdrop{
  position: absolute; inset: 0;
  background: transparent;
  pointer-events: none;
  transition: background .25s;
}
.pdt-modal.pdt-fullscreen .pdt-modal-backdrop{
  background: rgba(0, 5, 16, .55);
  pointer-events: auto;
}

/* ---------- janela flutuante ---------- */
.pdt-modal-box{
  position: absolute;
  top: 70px;
  right: 20px;
  width: 380px;               /* mesma largura de abertura do AIoT */
  height: calc(100vh - 100px);
  max-height: 720px;
  min-width: 320px;
  min-height: 400px;
  max-width: 92vw;
  container-type: inline-size;
  container-name: pdt-box;
  background: linear-gradient(180deg, rgba(0, 10, 25, 0.85), rgba(0, 20, 45, 0.78));
  border: 1px solid rgba(0, 240, 255, 0.45);
  border-radius: 14px;
  backdrop-filter: blur(18px) saturate(1.3);
  -webkit-backdrop-filter: blur(18px) saturate(1.3);
  box-shadow: 0 16px 50px rgba(0, 240, 255, 0.35),
              0 0 0 1px rgba(0, 240, 255, 0.22);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0.82;             /* semi-transparente em idle */
  pointer-events: auto;
  resize: both;              /* canto inferior direito redimensiona */
  animation: pdtIn .3s cubic-bezier(.4, 0, .2, 1);
  transition: opacity .25s;
}
.pdt-modal-box:hover,
.pdt-modal-box:focus-within{ opacity: 1; }

@keyframes pdtIn{
  from { opacity: 0; transform: scale(0.97) translateY(8px); }
  to   { opacity: 0.82; transform: scale(1) translateY(0); }
}

/* fullscreen: janela estica na viewport toda */
.pdt-modal.pdt-fullscreen .pdt-modal-box{
  top: 0 !important; left: 0 !important;
  right: 0 !important; bottom: 0 !important;
  width: auto !important;
  height: auto !important;
  max-height: none !important;
  max-width: none !important;
  border-radius: 0;
  border-width: 0;
  opacity: 1;
  resize: none;
  background: linear-gradient(180deg, rgba(0, 10, 25, 0.97), rgba(0, 20, 45, 0.95));
}
.pdt-modal.pdt-fullscreen .pdt-header{ cursor: default; }

/* minimizado: só o header visível */
.pdt-modal.pdt-minimized .pdt-modal-box{
  height: auto !important;
  min-height: 0 !important;
  resize: none;
}
.pdt-modal.pdt-minimized .pdt-status,
.pdt-modal.pdt-minimized .pdt-kpis,
.pdt-modal.pdt-minimized .pdt-toolbar,
.pdt-modal.pdt-minimized .pdt-body,
.pdt-modal.pdt-minimized .pdt-detail,
.pdt-modal.pdt-minimized .pdt-resize-handle{ display: none !important; }

/* header recolhido: esconde KPIs + toolbar (maximiza a lista) */
.pdt-modal-box.pdt-header-collapsed .pdt-kpis,
.pdt-modal-box.pdt-header-collapsed .pdt-toolbar{ display: none; }

/* handle visual do resize (o resize em si é nativo do CSS) */
.pdt-resize-handle{
  position: absolute;
  right: 3px; bottom: 3px;
  width: 14px; height: 14px;
  border-right: 2px solid rgba(0,240,255,.5);
  border-bottom: 2px solid rgba(0,240,255,.5);
  border-radius: 0 0 4px 0;
  opacity: 0;
  transition: opacity .2s;
  pointer-events: none;
}
.pdt-modal-box:hover .pdt-resize-handle{ opacity: 1; }
.pdt-modal.pdt-fullscreen .pdt-resize-handle{ display: none; }

/* ---------- header (padrão AIoT: título + ícones, arrastável) ---------- */
.pdt-header{
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 12px 16px;
  background: linear-gradient(180deg, rgba(0, 240, 255, 0.16), rgba(0, 240, 255, 0.04));
  border-bottom: 1px solid rgba(0, 240, 255, 0.35);
  flex-shrink: 0;
  gap: 12px;
  cursor: grab;
  user-select: none;
  touch-action: none;
}
.pdt-header:active{ cursor: grabbing; }

.pdt-title{
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Orbitron', sans-serif;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 2.5px;
  color: #00f0ff;
  text-shadow: 0 0 8px rgba(0, 240, 255, 0.5);
}
.pdt-title-badge{ font-size: 15px; }
.pdt-header-actions{ display: flex; gap: 6px; margin-left: auto; }

.pdt-btn-icon{
  width: 28px; height: 28px;
  background: transparent;
  border: 1px solid rgba(0, 240, 255, 0.35);
  color: rgba(0, 240, 255, 0.85);
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  border-radius: 50%;
  cursor: pointer;
  transition: .2s;
  font-family: 'Orbitron', sans-serif;
}
.pdt-btn-icon:hover{
  background: rgba(0, 240, 255, 0.18);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.35);
}

.pdt-btn{
  background: transparent;
  border: 1px solid rgba(0,240,255,.35);
  color: rgba(0,240,255,.85);
  border-radius: 5px;
  padding: 0 10px;
  height: 32px;
  font-family: 'Orbitron', sans-serif;
  font-size: 11px;
  letter-spacing: 1.5px;
  cursor: pointer;
  transition: .2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.pdt-btn:hover{ background: rgba(0,240,255,.18); box-shadow: 0 0 12px rgba(0,240,255,.25); }
.pdt-btn-on{
  background: rgba(255,210,63,.16);
  border-color: rgba(255,210,63,.6);
  color: #ffd23f;
}
.pdt-btn-primary{
  background: rgba(0,240,255,.16);
  border-color: rgba(0,240,255,.6);
}

/* ---------- status ---------- */
.pdt-status{
  padding: 5px 16px;
  font-size: 11px;
  opacity: .7;
  border-bottom: 1px solid rgba(0,240,255,.1);
  letter-spacing: .5px;
  flex-shrink: 0;
}
.pdt-status-loading{ color: #00f0ff; opacity: 1; }
.pdt-status-loading::after{ content: ' ⏳'; }
.pdt-status-error{ color: #ff4d5e; opacity: 1; }

/* ---------- KPIs ---------- */
.pdt-kpis{
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 8px;
  padding: 10px 16px;
  flex-shrink: 0;
}
.pdt-kpi{
  background: rgba(0,240,255,.05);
  border: 1px solid rgba(0,240,255,.18);
  border-radius: 10px;
  padding: 8px 10px;
  text-align: center;
}
.pdt-kpi-v{ font-size: 20px; font-weight: 700; color: #00f0ff; }
.pdt-kpi-l{ font-size: 9px; opacity: .65; margin-top: 2px; letter-spacing: .5px; }
.pdt-kpi-crit .pdt-kpi-v{ color: #ff4d5e; text-shadow: 0 0 10px rgba(255,77,94,.4); }
.pdt-kpi-alto .pdt-kpi-v{ color: #ff9040; }
.pdt-kpi-p30 .pdt-kpi-v{ color: #ffd23f; }

/* ---------- toolbar (filter bar) ---------- */
.pdt-toolbar{
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 0 16px 10px;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.pdt-search{
  flex: 1 1 170px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0,20,40,.6);
  border: 1px solid rgba(0,240,255,.3);
  border-radius: 5px;
  padding: 0 10px;
  height: 32px;
}
.pdt-search-icon{ font-size: 12px; opacity: .6; }
.pdt-search input{
  flex: 1;
  background: transparent;
  border: 0;
  outline: 0;
  color: inherit;
  font-family: inherit;
  font-size: 12px;
  min-width: 0;
}
.pdt-classes{ display: flex; gap: 5px; flex-wrap: wrap; }
.pdt-chip{
  background: transparent;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 20px;
  color: inherit;
  padding: 4px 9px;
  font-size: 10px;
  letter-spacing: .5px;
  cursor: pointer;
  opacity: .75;
}
.pdt-chip b{ opacity: .9; }
.pdt-chip-on{
  opacity: 1;
  border-color: var(--chip, #00f0ff);
  color: var(--chip, #00f0ff);
  box-shadow: 0 0 8px color-mix(in srgb, var(--chip, #00f0ff) 40%, transparent);
}

/* botões de visão (▦ cards / ≡ tabela) - mesmo desenho do AIoT */
.pdt-view-toggle{ display: flex; gap: 5px; }
.pdt-view-btn{
  background: transparent;
  border: 1px solid rgba(0, 240, 255, 0.3);
  color: rgba(0, 240, 255, 0.55);
  width: 32px; height: 32px;
  border-radius: 5px;
  font-size: 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: .15s;
}
.pdt-view-btn:hover{ color: #00f0ff; }
.pdt-view-btn.pdt-active{
  background: rgba(0, 240, 255, 0.18);
  border-color: #00f0ff;
  color: #00f0ff;
}
.pdt-refresh-ctrl{ display: flex; gap: 6px; align-items: center; }

/* ---------- corpo / tabela ---------- */
.pdt-body{
  flex: 1;
  overflow: auto;
  padding: 0 16px 14px;
}
.pdt-table{
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.pdt-table th{
  text-align: left;
  font-size: 10px;
  letter-spacing: 1px;
  opacity: .75;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(0,240,255,.25);
  position: sticky;
  top: 0;
  background: rgba(0,12,28,.95);
  z-index: 1;
}
.pdt-table td{
  padding: 9px 10px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  vertical-align: top;
}
.pdt-table tbody tr{ cursor: pointer; transition: background .15s; }
.pdt-table tbody tr:hover{ background: rgba(0,240,255,.06); }
.pdt-eq{ font-weight: 600; }
.pdt-eq-sub{ font-size: 10px; opacity: .55; margin-top: 2px; }
.pdt-num{ font-variant-numeric: tabular-nums; font-weight: 600; }
.pdt-dim{ opacity: .55; font-size: 10px; }
.pdt-action{ font-size: 11px; opacity: .85; }

.pdt-badge{
  display: inline-block;
  min-width: 38px;
  text-align: center;
  padding: 3px 8px;
  border-radius: 8px;
  font-weight: 700;
  border: 1px solid var(--k, #00f0ff);
  color: var(--k, #00f0ff);
  box-shadow: 0 0 10px color-mix(in srgb, var(--k, #00f0ff) 35%, transparent);
}

/* ---------- visão CARDS ---------- */
.pdt-cards{
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 10px;
}
.pdt-asset-card{
  background: rgba(0,240,255,.05);
  border: 1px solid rgba(0,240,255,.18);
  border-left: 3px solid var(--k, #00f0ff);
  border-radius: 10px;
  padding: 11px 12px;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
}
.pdt-asset-card:hover{
  transform: translateY(-2px);
  box-shadow: 0 6px 18px color-mix(in srgb, var(--k, #00f0ff) 25%, transparent);
}
.pdt-asset-card-head{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.pdt-asset-card-name{ font-weight: 700; font-size: 12.5px; }
.pdt-asset-card-sub{ font-size: 10px; opacity: .55; margin-top: 2px; }
.pdt-asset-card-klass{ font-size: 10px; letter-spacing: 1.5px; margin: 5px 0 7px; }
.pdt-asset-card-rows div{
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  padding: 2.5px 0;
}
.pdt-asset-card-rows span{ opacity: .55; }
.pdt-asset-card-rows b{ text-align: right; font-weight: 600; }
.pdt-asset-card-rows i{ font-style: normal; opacity: .55; font-size: 10px; }

/* DESTAQUE nos cards: probabilidade de falhar + prazo até a falha */
.pdt-hero{
  display: flex;
  align-items: stretch;
  gap: 10px;
  margin: 4px 0 9px;
  padding: 9px 10px;
  background: rgba(0,0,0,.28);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 9px;
}
.pdt-hero-cell{ flex: 1; text-align: center; min-width: 0; }
.pdt-hero-sep{ width: 1px; background: rgba(255,255,255,.12); }
.pdt-hero-v{
  font-family: 'Orbitron', sans-serif;
  font-size: 24px;
  font-weight: 800;
  line-height: 1.1;
  text-shadow: 0 0 14px currentColor;
}
.pdt-hero-l{
  font-size: 9px;
  letter-spacing: .5px;
  opacity: .6;
  margin-top: 3px;
  text-transform: uppercase;
}
.pdt-hero-l i{ font-style: normal; opacity: .8; text-transform: none; }

/* DESTAQUE na tabela: números-chave maiores e coloridos por urgência */
.pdt-key-num{
  font-family: 'Orbitron', sans-serif;
  font-size: 16px;
  font-weight: 800;
  text-shadow: 0 0 10px currentColor;
}

/* DESTAQUE no detalhe: cards de prob./prazo com número grande */
.pdt-card-hero{
  border-color: rgba(255,255,255,.25);
  background: rgba(0,0,0,.3);
}
.pdt-card-v-hero{
  font-family: 'Orbitron', sans-serif;
  font-size: 26px;
  font-weight: 800;
  text-shadow: 0 0 16px currentColor;
}

.pdt-empty{
  padding: 40px 20px;
  text-align: center;
  opacity: .7;
  font-size: 13px;
  line-height: 1.7;
}
.pdt-insufficient{
  margin-top: 10px;
  font-size: 11px;
  opacity: .55;
  font-style: italic;
}

/* ---------- detalhe ---------- */
.pdt-detail{
  position: absolute;
  inset: 0;
  display: none;
  background: rgba(0,5,16,.88);
  backdrop-filter: blur(4px);
  padding: 20px;
  overflow: auto;
  z-index: 5;
}
.pdt-detail.pdt-detail-open{ display: block; }

.pdt-detail-card{
  max-width: 860px;
  margin: 0 auto;
  background: linear-gradient(180deg, rgba(0,20,42,.98), rgba(0,10,24,.98));
  border: 1px solid rgba(0,240,255,.35);
  border-radius: 14px;
  padding: 16px;
}
.pdt-detail-head{
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(0,240,255,.18);
}
.pdt-detail-head > div:first-child{ flex: 1; min-width: 0; }
.pdt-detail-name{ font-size: 16px; font-weight: 700; }
.pdt-detail-sub{ font-size: 11px; opacity: .6; margin-top: 3px; }
.pdt-detail-score{ text-align: right; }
.pdt-detail-aprs{
  font-size: 28px;
  font-weight: 800;
  color: var(--k, #00f0ff);
  text-shadow: 0 0 14px color-mix(in srgb, var(--k, #00f0ff) 50%, transparent);
}
.pdt-detail-aprs span{ font-size: 12px; opacity: .55; }
.pdt-detail-klass{ font-size: 10px; letter-spacing: 2px; color: var(--k, #00f0ff); }

.pdt-detail-grid{
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  padding: 12px 0;
}
.pdt-card{
  background: rgba(0,240,255,.05);
  border: 1px solid rgba(0,240,255,.15);
  border-radius: 10px;
  padding: 11px;
}
.pdt-card-t{ font-size: 10px; letter-spacing: 1px; opacity: .6; text-transform: uppercase; }
.pdt-card-v{ font-size: 15px; font-weight: 700; margin-top: 4px; }
.pdt-card-s{ font-size: 11px; opacity: .65; margin-top: 5px; line-height: 1.5; }

.pdt-detail-os{ padding-top: 4px; }
.pdt-os-row{
  display: flex;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px dashed rgba(255,255,255,.08);
  font-size: 11px;
  align-items: baseline;
}
.pdt-os-date{ opacity: .6; min-width: 74px; }
.pdt-os-symptom{ color: #ffd23f; min-width: 124px; }
.pdt-os-motivo{ opacity: .75; flex: 1; }

.pdt-detail-actions{
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 12px;
}

/* ---------- janela estreita (container query) ---------- */
@container pdt-box (max-width: 560px){
  .pdt-table th:nth-child(2), .pdt-table td:nth-child(2),
  .pdt-table th:nth-child(6), .pdt-table td:nth-child(6){ display: none; }
  .pdt-kpis{ grid-template-columns: repeat(4, 1fr); }
}

/* ---------- responsivo mobile ---------- */
@media (max-width: 480px){
  .pdt-modal-box{
    top: 60px;
    right: 8px;
    width: calc(100vw - 16px);
    max-width: calc(100vw - 16px);
  }
  .pdt-detail{ padding: 10px; }
}

/* ---------- tema claro ---------- */
body.light-theme .pdt-modal-box{
  background: linear-gradient(180deg, rgba(240,248,252,.95), rgba(225,238,246,.92));
  border-color: rgba(0,120,160,.4);
  color: #0b2836;
}
body.light-theme .pdt-modal.pdt-fullscreen .pdt-modal-box{
  background: linear-gradient(180deg, rgba(240,248,252,.99), rgba(225,238,246,.97));
}
body.light-theme .pdt-header{
  background: linear-gradient(180deg, rgba(0,150,190,.16), rgba(0,150,190,.05));
  border-bottom-color: rgba(0,120,160,.3);
}
body.light-theme .pdt-table th{ background: rgba(235,245,250,.96); }
body.light-theme .pdt-detail{ background: rgba(220,235,244,.9); }
body.light-theme .pdt-detail-card,
body.light-theme .pdt-kpi,
body.light-theme .pdt-asset-card,
body.light-theme .pdt-card{
  background: rgba(0,120,160,.06);
  border-color: rgba(0,120,160,.22);
}
body.light-theme .pdt-title{ color: #007a99; text-shadow: none; }
body.light-theme .pdt-kpi-v{ color: #007a99; }
body.light-theme .pdt-search{ background: rgba(255,255,255,.7); border-color: rgba(0,120,160,.3); }
