/* ============================================
   COMPONENTS.CSS — Pipeline Monitoring System
   ============================================ */

/* ── Dot indicator ── */
.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-green);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

/* ── SIDEBAR ── */
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 16px;
}
.logo-icon { font-size: 24px; }
.logo-text {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}
.logo-text span {
  display: block;
  font-weight: 400;
  font-size: 11px;
  color: var(--text-secondary);
}

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: var(--bg-card); color: var(--text-primary); }
.nav-item.active {
  background: rgba(59,130,246,0.15);
  color: var(--accent-blue);
  font-weight: 600;
}
.nav-icon { font-size: 15px; width: 20px; text-align: center; }

.sidebar-bottom {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
  margin-top: auto;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: var(--shadow-card);
}
.status-card-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-green);
}
.status-desc {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 3px;
}
.copyright {
  font-size: 10px;
  color: var(--text-secondary);
  line-height: 1.5;
  padding: 4px 0;
}

/* ── HEADER ── */
.top-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.header-title {
  display: flex;
  align-items: center;
  gap: 12px;
}
.header-title h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
}
.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(34,197,94,0.15);
  color: var(--accent-green);
  border: 1px solid rgba(34,197,94,0.3);
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
}
.header-sub {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.icon-btn {
  position: relative;
  width: 36px;
  height: 36px;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  border: 1px solid var(--border-color);
}
.badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--accent-red);
  color: white;
  font-size: 9px;
  font-weight: 700;
  border-radius: 10px;
  padding: 1px 5px;
  min-width: 16px;
  text-align: center;
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 6px 12px;
  cursor: pointer;
}
.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-blue);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
}
.user-info {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
}
.user-info span {
  font-size: 10px;
  font-weight: 400;
  color: var(--text-secondary);
}

/* ── STAT CARDS ── */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat-card.warn  { border-color: rgba(234,179,8,0.35); }
.stat-card.critical { border-color: rgba(239,68,68,0.35); }
.stat-card.risk  { border-color: rgba(139,92,246,0.35); }

.stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
}
.stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
}
.stat-value .unit {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-secondary);
}
.stat-footer {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}
.stat-footer.positive  { color: var(--accent-green); }
.stat-footer.warn-text { color: var(--accent-yellow); }
.stat-footer.critical-text { color: var(--accent-red); }

/* ── PANEL (generic card) ── */
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-card);
}
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.panel-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}
.panel-sub {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}
.panel-select {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
}

/* ── CHART ── */
.chart-wrap {
  position: relative;
  height: 180px;
  width: 100%;
}

/* ── MAP ── */
#map {
  height: 210px;
  border-radius: var(--radius-md);
  overflow: hidden;
}
.map-footer {
  font-size: 10px;
  color: var(--text-secondary);
  text-align: right;
}

/* ── FORM (download panel) ── */
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-label  { font-size: 11px; color: var(--text-secondary); }
.form-input {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 12px;
  width: 100%;
}
.data-list { display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.data-list-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  background: var(--bg-panel);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
}
.data-list-item .check { color: var(--accent-green); }

/* ── BUTTONS ── */
.btn-primary {
  width: 100%;
  padding: 9px;
  border-radius: var(--radius-md);
  background: var(--accent-blue);
  color: white;
  border: none;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--accent-blue-hover); }
.btn-secondary {
  width: 100%;
  padding: 9px;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--accent-blue);
  border: 1px solid var(--accent-blue);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-secondary:hover { background: rgba(59,130,246,0.1); }

/* ── PREDICTION PANEL ── */
.risk-display {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.risk-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent-red);
}
.risk-conf {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}
.risk-detail-box {
  background: var(--bg-panel);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}
.risk-detail-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 2px;
}
.risk-detail-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}
.factor-list {
  list-style: disc;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--text-secondary);
}

/* ── NOTIFICATIONS ── */
.link-all {
  font-size: 11px;
  color: var(--accent-blue);
  cursor: pointer;
}
.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-color);
}
.notif-item:last-child { border-bottom: none; }
.notif-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.notif-content { display: flex; flex-direction: column; gap: 2px; }
.notif-time  { font-size: 10px; color: var(--text-secondary); }
.notif-title { font-size: 12px; font-weight: 600; color: var(--text-primary); }
.notif-desc  { font-size: 11px; color: var(--text-secondary); }

/* ── Sensor tooltip (Leaflet) ── */
.sensor-tooltip {
  background: var(--bg-card) !important;
  border: 1px solid var(--border-color) !important;
  color: var(--text-primary) !important;
  font-size: 11px !important;
  padding: 3px 7px !important;
  border-radius: var(--radius-sm) !important;
}

/* ── HAMBURGER (mobile only) ── */
.hamburger-btn {
  display: none;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 18px;
  width: 36px;
  height: 36px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

@media (max-width: 768px) {
  .hamburger-btn {
    display: flex;
  }

  .sidebar.open {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    width: 240px;
    height: 100vh;
    z-index: 999;
    box-shadow: 4px 0 20px rgba(0,0,0,0.5);
  }

  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 998;
  }
}

/* ── SKELETON LOADING ── */
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}

.skeleton {
  background: linear-gradient(90deg, var(--skeleton-base) 25%, var(--skeleton-shine) 50%, var(--skeleton-base) 75%);
  background-size: 400px 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius-sm);
  display: inline-block;
}

.skeleton-text {
  height: 14px;
  width: 80%;
  margin-bottom: 6px;
}

.skeleton-value {
  height: 28px;
  width: 60%;
  margin-bottom: 4px;
}

.skeleton-sub {
  height: 11px;
  width: 50%;
}

.skeleton-chart {
  height: 100%;
  width: 100%;
  border-radius: var(--radius-md);
}

.skeleton-ring {
  width: 64px;
  height: 64px;
  border-radius: 50%;
}

.skeleton-notif {
  height: 48px;
  width: 100%;
  margin-bottom: 8px;
  border-radius: var(--radius-md);
}

/* ── PRED-RING (statis, tidak ikut animasi skeleton) ── */
#pred-ring {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 4px solid var(--accent-red);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  flex-shrink: 0;
  background: transparent;
  animation: none !important;
}


/* ── Override paksa: pastikan pred-ring tidak ikut animasi skeleton ── */
#pred-ring,
#pred-ring.skeleton,
#pred-ring.skeleton-ring {
  animation: none !important;
  background: transparent !important;
  background-image: none !important;
}

/* Debug fix pred-ring */
#pred-ring {
  color: var(--text-primary) !important;
  font-size: 14px !important;
  font-weight: 700 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  animation: none !important;
  background: transparent !important;
  background-image: none !important;
  width: 64px !important;
  height: 64px !important;
  border-radius: 50% !important;
  border: 4px solid var(--accent-red) !important;
  flex-shrink: 0 !important;
}

/* Form pembungkus tombol logout - display:contents bikin <form> "transparan"
   secara layout, jadi tombol di dalamnya tetap ikut flex row topbar/sidebar
   persis seperti sebelum dibungkus form. */
.btn-logout-form {
  display: contents;
}

/* ===== CONFIRM MODAL (reusable - dipakai logout & konfirmasi lain ke depannya) ===== */
.confirm-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.confirm-modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  width: 90%;
  max-width: 340px;
  text-align: center;
  box-shadow: var(--shadow-elevated);
}
.confirm-modal-icon {
  font-size: 36px;
  margin-bottom: 10px;
}
.confirm-modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}
.confirm-modal-text {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.5;
}
.confirm-modal-actions {
  display: flex;
  gap: 10px;
}
.confirm-modal-actions button {
  flex: 1;
}
.confirm-modal-danger-btn {
  background: var(--accent-red) !important;
}