/* Streaming View Stylesheet - VMS 4.0 Cyberpunk Refinement */

.view-streaming {
  animation: fadeIn 0.4s ease-out;
}

.streaming-sub-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 16px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(0, 242, 254, 0.12);
  border-radius: 6px;
}

.streaming-sub-tabs button {
  min-width: 148px;
  height: 34px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: rgba(255, 255, 255, 0.62);
  font: 700 12px var(--font-mono);
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.streaming-sub-tabs button.active {
  color: #06101d;
  background: linear-gradient(135deg, var(--primary), #42f59b);
  box-shadow: 0 0 16px rgba(0, 242, 254, 0.22);
}

.cctv-status-view {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.cctv-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 15px;
}

.cctv-control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.area-toggle-group {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(0, 242, 254, 0.1);
}

.area-toggle-group button {
  min-width: 84px;
  height: 32px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: rgba(255, 255, 255, 0.58);
  font: 700 12px var(--font-mono);
  cursor: pointer;
}

.area-toggle-group button.active {
  color: #06101d;
  background: var(--primary);
  box-shadow: 0 0 12px var(--primary-glow);
}

.cctv-summary {
  color: rgba(255, 255, 255, 0.45);
  font-size: 12px;
}

.site-list {
  padding: 12px;
  height: calc(100vh - 310px);
  min-height: 420px;
  overflow-y: auto;
}

.site-row {
  margin-bottom: 9px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.055);
  background: rgba(0, 0, 0, 0.16);
  overflow: hidden;
}

.site-row.has-offline {
  border-color: rgba(238, 82, 83, 0.26);
  background: rgba(238, 82, 83, 0.05);
}

.site-row.expanded {
  border-color: rgba(0, 242, 254, 0.2);
}

.site-row-head {
  width: 100%;
  min-height: 56px;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) 100px 104px;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.site-row-head:hover {
  background: rgba(255, 255, 255, 0.025);
}

.site-expand-caret {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(0, 242, 254, 0.18);
  color: var(--primary);
  font: 800 16px var(--font-mono);
}

.site-title {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.site-title strong,
.site-title small {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.site-title strong {
  color: #fff;
  font-size: 13px;
}

.site-title small {
  color: rgba(255, 255, 255, 0.42);
  font-size: 11px;
}

.site-count {
  color: rgba(255, 255, 255, 0.55);
  font-size: 12px;
  text-align: right;
}

.device-expand-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 12px 12px 56px;
}

.device-work-status {
  display: grid;
  grid-template-columns: minmax(150px, 0.85fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  align-items: stretch;
  padding: 8px;
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(7, 11, 25, 0.68);
}

.device-work-status.offline {
  border-color: rgba(238, 82, 83, 0.22);
  background: rgba(238, 82, 83, 0.07);
}

.device-name-cell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.device-name-cell strong {
  color: #fff;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 12px;
}

.work-channel {
  display: grid;
  grid-template-columns: 72px repeat(3, minmax(58px, 1fr)) 76px;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 6px 8px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.22);
  color: rgba(255, 255, 255, 0.62);
  font: 700 10px var(--font-mono);
}

.channel-label {
  color: var(--primary);
}

.work-status-badge {
  justify-self: start;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 800;
}

.work-status-badge.online {
  color: var(--green);
  background: rgba(16, 172, 132, 0.12);
  border: 1px solid rgba(16, 172, 132, 0.26);
}

.work-status-badge.offline {
  color: var(--red);
  background: rgba(238, 82, 83, 0.12);
  border: 1px solid rgba(238, 82, 83, 0.28);
}

/* Stats KPI Cards Grid at top */
.streaming-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 15px;
  margin-bottom: 15px;
}

.stat-card {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  overflow: hidden;
  border-left: 3px solid rgba(255, 255, 255, 0.1);
}

.stat-card::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 50px;
  height: 50px;
  background: radial-gradient(circle, rgba(255,255,255,0.03) 0%, transparent 70%);
  pointer-events: none;
}

.stat-card:nth-child(1) { border-left-color: var(--green); }
.stat-card:nth-child(2) { border-left-color: var(--primary); }
.stat-card:nth-child(3) { border-left-color: var(--secondary); }
.stat-card:nth-child(4) { border-left-color: var(--amber); }

.stat-label {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.45);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.stat-value-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.stat-value {
  font-size: 26px;
  font-weight: 800;
}

.stat-unit {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.4);
}

/* Glowing Neon Text classes */
.font-glow-green {
  color: var(--green);
  text-shadow: 0 0 10px var(--green-glow);
}
.font-glow-cyan {
  color: var(--primary);
  text-shadow: 0 0 10px var(--primary-glow);
}
.font-glow-purple {
  color: #c084fc;
  text-shadow: 0 0 10px rgba(192, 132, 252, 0.3);
}
.font-glow-amber {
  color: var(--amber);
  text-shadow: 0 0 10px var(--amber-glow);
}

/* Search Box Styles in Header */
.search-box-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-input {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-glass);
  border-radius: 20px;
  color: #fff;
  padding: 6px 15px 6px 32px;
  font-size: 11px;
  width: 280px;
  transition: all 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.search-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 10px var(--primary-glow);
  width: 320px;
}

.search-icon {
  position: absolute;
  left: 10px;
  font-size: 11px;
  opacity: 0.5;
  pointer-events: none;
}

/* Main Split Grid */
.streaming-body-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 15px;
  height: calc(100vh - 250px);
  overflow: hidden;
}

/* Streams Table Panel (Left) */
.streams-table-card {
  padding: 15px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.streams-table-card .cctv-table-wrapper {
  margin-top: 10px;
}

.streams-table-card .tech-table tr {
  transition: all 0.15s ease-in-out;
}

.streams-table-card .tech-table tr:hover {
  background: rgba(255, 255, 255, 0.025);
}

.streams-table-card .tech-table tr.active-row {
  background: rgba(0, 242, 254, 0.08) !important;
  border-left: 3px solid var(--primary);
}

.streams-table-card .tech-table tr.active-row td {
  color: #fff;
}

/* Table detail cells */
.route-badge {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.65);
  font-size: 9px;
  padding: 1px 4px;
  border-radius: 3px;
  margin-right: 4px;
  font-weight: 600;
}

.res-sub {
  display: block;
  font-size: 9px;
  color: rgba(255, 255, 255, 0.35);
  margin-top: 2px;
}

.fps-text {
  font-weight: 600;
}

.latency-text {
  display: block;
  font-size: 9px;
  color: var(--green);
  margin-top: 2px;
}

.latency-text.warning-text {
  color: var(--amber);
}

.bitrate-sub {
  font-size: 11px;
}

.conn-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  margin-top: 2px;
}

.conn-light {
  background: rgba(16, 172, 132, 0.1);
  color: var(--green);
  border: 1px solid rgba(16, 172, 132, 0.2);
}

.conn-medium {
  background: rgba(255, 159, 67, 0.1);
  color: var(--amber);
  border: 1px solid rgba(255, 159, 67, 0.2);
}

.conn-heavy {
  background: rgba(238, 82, 83, 0.1);
  color: var(--red);
  border: 1px solid rgba(238, 82, 83, 0.2);
  box-shadow: 0 0 5px rgba(238, 82, 83, 0.15);
}

.ip-cell {
  color: rgba(255, 255, 255, 0.45) !important;
}

/* Detail Panel (Right) */
.streaming-detail-card {
  padding: 15px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.detail-panel-content {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
  gap: 12px;
  padding-right: 2px;
}

.selected-stream-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.stream-icon {
  font-size: 24px;
  color: var(--primary);
  background: rgba(0, 242, 254, 0.05);
  border: 1px solid rgba(0, 242, 254, 0.12);
  width: 42px;
  height: 42px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 10px rgba(0, 242, 254, 0.1);
}

.header-text-group {
  flex: 1;
  overflow: hidden;
}

.stream-title {
  font-size: 14px;
  font-weight: 800;
  color: var(--primary);
}

.stream-subtitle {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.5);
  margin-top: 2px;
}

/* Specs Box */
.stream-specs-box {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 4px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.spec-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.45);
}

.spec-value {
  color: rgba(255, 255, 255, 0.85);
  font-family: var(--font-mono);
}

.spec-row.highlight {
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  padding-top: 6px;
  margin-top: 4px;
  font-size: 11px;
}

/* Alert Box */
.load-status-alert {
  padding: 10px 12px;
  border-radius: 4px;
  border: 1px solid transparent;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.load-status-alert.normal {
  background: rgba(16, 172, 132, 0.06);
  border-color: rgba(16, 172, 132, 0.15);
}

.load-status-alert.heavy {
  background: rgba(255, 159, 67, 0.06);
  border-color: rgba(255, 159, 67, 0.15);
}

.load-status-alert.offline {
  background: rgba(238, 82, 83, 0.06);
  border-color: rgba(238, 82, 83, 0.15);
}

.alert-title {
  font-size: 11px;
  font-weight: 700;
}

.load-status-alert.normal .alert-title { color: var(--green); }
.load-status-alert.heavy .alert-title { color: var(--amber); }
.load-status-alert.offline .alert-title { color: var(--red); }

.alert-desc {
  font-size: 9px;
  color: rgba(255, 255, 255, 0.55);
  line-height: 1.4;
}

/* Pull Clients Table */
.clients-list-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 0.5px;
  border-left: 2px solid var(--primary);
  padding-left: 6px;
}

.client-detail-table-wrapper {
  overflow-y: auto;
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.15);
  min-height: 150px;
  max-height: 250px;
}

.client-detail-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 10px;
}

.client-detail-table th {
  background: rgba(0, 0, 0, 0.3);
  color: rgba(255, 255, 255, 0.4);
  font-weight: 600;
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.client-detail-table td {
  padding: 6px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  color: rgba(255, 255, 255, 0.6);
}

.client-detail-table tr:hover {
  background: rgba(255, 255, 255, 0.015);
}

.client-ip {
  font-family: var(--font-mono);
  color: #fff;
  font-weight: 600;
}

.client-name {
  font-size: 8px;
  color: rgba(255, 255, 255, 0.35);
  margin-top: 1px;
}

.client-proto {
  font-size: 9px;
  font-family: var(--font-mono);
}

.client-lat {
  font-family: var(--font-mono);
}

.client-bw {
  font-size: 9px;
  font-family: var(--font-mono);
  margin-top: 1px;
}

/* Empty/Placeholder States */
.empty-clients-box, .empty-detail-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px 10px;
  color: rgba(255, 255, 255, 0.3);
  gap: 10px;
  border: 1px dashed rgba(255, 255, 255, 0.04);
  border-radius: 4px;
  flex: 1;
}

.empty-detail-box {
  border: none;
  padding: 80px 20px;
}

.empty-icon {
  font-size: 20px;
  opacity: 0.5;
}

.empty-detail-box p, .empty-clients-box p {
  font-size: 11px;
  text-align: center;
}

/* Authority Badges */
.auth-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  text-align: center;
  font-family: var(--font-family);
  border: 1px solid transparent;
  min-width: 90px;
}

.auth-tpe { background: rgba(0, 242, 254, 0.1); color: var(--primary); border-color: rgba(0, 242, 254, 0.2); }
.auth-nwt { background: rgba(165, 94, 234, 0.1); color: #c084fc; border-color: rgba(165, 94, 234, 0.2); }
.auth-khh { background: rgba(255, 159, 67, 0.1); color: var(--amber); border-color: rgba(255, 159, 67, 0.2); }
.auth-tnn { background: rgba(238, 82, 83, 0.1); color: var(--red); border-color: rgba(238, 82, 83, 0.2); }
.auth-tao { background: rgba(42, 150, 255, 0.1); color: var(--blue); border-color: rgba(42, 150, 255, 0.2); }
.auth-txg { background: rgba(16, 172, 132, 0.1); color: var(--green); border-color: rgba(16, 172, 132, 0.2); }
.auth-ttt { background: rgba(255, 255, 255, 0.05); color: rgba(255,255,255,0.7); border-color: rgba(255,255,255,0.1); }
.auth-kee { background: rgba(255, 255, 255, 0.05); color: rgba(255,255,255,0.7); border-color: rgba(255,255,255,0.1); }
.auth-nfb { background: rgba(16, 172, 132, 0.15); color: #2ecc71; border-color: rgba(16, 172, 132, 0.3); }
.auth-thb { background: rgba(46, 204, 113, 0.15); color: #2ecc71; border-color: rgba(46, 204, 113, 0.3); }
.auth-unknown { background: rgba(255, 255, 255, 0.05); color: rgba(255, 255, 255, 0.5); border-color: rgba(255, 255, 255, 0.08); }

/* Agency Filter Dropdown */
.select-ctrl-agency {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-glass);
  color: #fff;
  padding: 6px 28px 6px 12px;
  border-radius: 20px;
  font-size: 11px;
  outline: none;
  cursor: pointer;
  font-family: var(--font-family);
  transition: all 0.2s ease;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.select-ctrl-agency:focus {
  border-color: var(--primary);
  box-shadow: 0 0 10px var(--primary-glow);
}

.select-ctrl-agency option {
  background-color: var(--bg-dark);
  color: #fff;
}

/* Column Width Optimizations for CCTV Table */
.col-auth {
  width: 120px;
  max-width: 120px;
}

.col-id {
  width: 110px;
  max-width: 110px;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.col-area {
  width: 85px;
  max-width: 85px;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.col-ip {
  width: 110px;
  max-width: 110px;
}

.col-status {
  width: 80px;
  max-width: 80px;
  text-align: center;
}

@media (max-width: 1280px) {
  .cctv-kpi-grid,
  .streaming-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .device-work-status {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 840px) {
  .cctv-control-row,
  .view-streaming .view-header {
    flex-direction: column;
    align-items: stretch;
  }

  .streaming-sub-tabs,
  .area-toggle-group {
    width: 100%;
  }

  .streaming-sub-tabs button,
  .area-toggle-group button {
    flex: 1;
    min-width: 0;
  }

  .cctv-kpi-grid,
  .streaming-stats-grid {
    grid-template-columns: 1fr;
  }

  .site-row-head {
    grid-template-columns: 32px minmax(0, 1fr);
  }

  .site-row-head .site-count,
  .site-row-head .tech-badge {
    justify-self: start;
    margin-left: 44px;
  }

  .device-expand-panel {
    padding-left: 12px;
  }

  .work-channel {
    grid-template-columns: 1fr 1fr;
  }
}
