/* src/hls-bun/ui/styles.css */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  color: #e0e0e0;
  background: #0a0a0a;
  font-family: -apple-system, system-ui, BlinkMacSystemFont, Segoe UI, Roboto, Noto Sans, Ubuntu, Cantarell, Helvetica Neue, sans-serif;
}

h1 {
  color: #da4165;
  margin-bottom: 16px;
  font-size: 1.4em;
}

h2 {
  color: #aaa;
  margin: 20px 0 10px;
  font-size: 1.1em;
}

.app-layout {
  display: flex;
  overflow: hidden;
  height: 100vh;
}

.app-main {
  overflow-y: auto;
  flex: 1;
  min-width: 0;
  padding: 20px;
}

.sidebar {
  overflow-y: auto;
  border-left: 1px solid #222;
  flex-shrink: 0;
  width: 280px;
  padding: 12px;
}

.tree-nav {
  overflow-y: auto;
  background: #111;
  border-right: 1px solid #222;
  flex-shrink: 0;
  width: 220px;
  padding: 8px 0;
  font-size: .82em;
}

.tree-nav.collapsed {
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items:  flex-start;
  width: 36px;
  padding-top: 12px;
}

.tree-toggle {
  color: #888;
  font-size: 1.2em;
}

.tree-header {
  display: flex;
  justify-content: space-between;
  align-items:  center;
  padding: 8px 12px 12px;
}

.tree-collapse {
  cursor: pointer;
  color: #555;
  font-size: 1.1em;
}

.tree-collapse:hover {
  color: #e0e0e0;
}

.tree-item {
  display: flex;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  align-items:  center;
  gap: 4px;
  padding: 3px 8px;
}

.tree-item:hover {
  background: #1a1a1a;
}

.tree-item.active {
  color: #da4165;
  background: #da416522;
}

.tree-arrow {
  color: #555;
  text-align: center;
  flex-shrink: 0;
  width: 14px;
  font-size: .7em;
}

.tree-label {
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.tree-stats {
  display: flex;
  flex-shrink: 0;
  align-items:  center;
  gap: 4px;
  margin-left: auto;
}

.tree-size {
  color: #777;
  font-size: .75em;
}

.tree-badge {
  color: #555;
  flex-shrink: 0;
  font-size: .8em;
}

.tree-badge.complete {
  color: #3a5;
}

.tree-badge.partial {
  color: #a83;
}

.tree-year {
  padding-left: 8px;
  font-weight: 600;
}

.tree-product {
  padding-left: 20px;
}

.tree-day {
  color: #aaa;
  padding-left: 32px;
}

.tree-event {
  color: #ccc;
  padding-left: 44px;
  font-size: .95em;
}

.tree-stage {
  padding-left: 44px;
  font-size: .95em;
}

.tree-event-children .tree-stage {
  padding-left: 56px;
}

.grid-view {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.grid-card {
  overflow: hidden;
  cursor: pointer;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 8px;
  transition: border-color .2s;
}

.grid-card:hover {
  border-color: #da4165;
}

.grid-thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #111;
}

.grid-thumb img {
  object-fit: cover;
  width: 100%;
  height: 100%;
}

.grid-thumb-placeholder {
  display: flex;
  color: #333;
  justify-content: center;
  align-items:  center;
  width: 100%;
  height: 100%;
  font-size: 2em;
}

.grid-pct {
  position: absolute;
  color: #fff;
  border-radius: 3px;
  padding: 1px 6px;
  font-size: .7em;
  font-weight: 600;
  bottom: 4px;
  right: 4px;
}

.grid-live {
  position: absolute;
  color: #fff;
  text-transform: uppercase;
  background: #da4165;
  border-radius: 3px;
  padding: 1px 6px;
  font-size: .65em;
  font-weight: 600;
  top: 4px;
  left: 4px;
}

.grid-info {
  padding: 8px;
}

.grid-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: .85em;
  font-weight: 600;
}

.grid-meta {
  color: #666;
  margin-top: 2px;
  font-size: .72em;
}

.data-table {
  border-collapse: collapse;
  width: 100%;
  font-size: .82em;
}

.data-table th {
  text-align: left;
  color: #888;
  white-space: nowrap;
  border-bottom: 2px solid #333;
  padding: 6px 10px;
  font-weight: 600;
}

.data-table td {
  border-bottom: 1px solid #1a1a1a;
  padding: 6px 10px;
}

.data-table tbody tr:hover {
  background: #1a1a1a;
}

.data-table tfoot td {
  color: #aaa;
  border-top: 2px solid #333;
  padding-top: 8px;
  font-weight: 600;
}

.mini-bar {
  overflow: hidden;
  background: #333;
  border-radius: 2px;
  flex-shrink: 0;
  width: 50px;
  height: 4px;
}

.badge-sm {
  text-transform: uppercase;
  border-radius: 3px;
  padding: 1px 6px;
  font-size: .8em;
}

.badge-sm.dvr {
  color: #69c;
  background: #36a3;
}

.badge-sm.live, .badge-sm.active {
  color: #da4165;
  background: #da416533;
}

.badge-sm.ended {
  color: #3a5;
  background: #3a53;
}

.thumb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.layout {
  display: flex;
  gap: 20px;
}

.main {
  flex: 1;
  min-width: 0;
}

.streams {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stream {
  cursor: pointer;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 16px;
  transition: border-color .2s;
}

.stream:hover {
  border-color: #555;
}

.stream.active {
  border-color: #da4165;
}

.stream.selected {
  border-color: #da4165;
  box-shadow: 0 0 0 1px #da4165;
}

.stream-header {
  display: flex;
  justify-content: space-between;
  align-items:  center;
  margin-bottom: 8px;
}

.stream-key {
  font-size: 1.05em;
  font-weight: 600;
}

.badge {
  text-transform: uppercase;
  letter-spacing: .5px;
  border-radius: 4px;
  padding: 2px 8px;
  font-size: .75em;
}

.badge.active {
  color: #da4165;
  background: #da416533;
}

.badge.ended {
  color: #3a5;
  background: #3a53;
}

.badge.exported {
  color: #36a;
  background: #36a3;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 8px;
}

.stat {
  display: flex;
  flex-direction: column;
}

.stat-val {
  font-variant-numeric: tabular-nums;
  font-size: 1.2em;
  font-weight: 600;
}

.stat-label {
  color: #888;
  text-transform: uppercase;
  font-size: .7em;
}

.progress-bar {
  overflow: hidden;
  display: flex;
  background: #333;
  border-radius: 3px;
  height: 6px;
  margin-top: 10px;
}

.pb-stored {
  background: #3a5;
}

.pb-pending {
  background: #a83;
}

.pb-expired {
  background: #555;
}

.pb-failed {
  background: #a33;
}

.meta {
  color: #555;
  margin-top: 6px;
  font-size: .78em;
}

.chunk-map-wrap {
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 8px;
  margin-top: 12px;
  padding: 16px;
}

.chunk-map-wrap h3 {
  color: #aaa;
  margin-bottom: 8px;
  font-size: .9em;
}

.chunk-map-wrap canvas {
  image-rendering: pixelated;
  cursor: pointer;
  border-radius: 4px;
  width: 100%;
}

.chunk-legend {
  display: flex;
  color: #888;
  gap: 14px;
  margin-top: 8px;
  font-size: .75em;
}

.chunk-legend span:before {
  content: "";
  display: inline-block;
  vertical-align: middle;
  border-radius: 2px;
  width: 10px;
  height: 10px;
  margin-right: 4px;
}

.leg-stored:before {
  background: #3a5;
}

.leg-pending:before {
  background: #a83;
}

.leg-expired:before {
  background: #444;
}

.leg-failed:before {
  background: #a33;
}

.leg-missing:before {
  background: #1a1a1a;
  border: 1px solid #333;
}

.chunk-hover {
  color: #888;
  height: 1.2em;
  margin-top: 4px;
  font-size: .75em;
}

.player-wrap {
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 8px;
  margin-top: 12px;
  padding: 16px;
}

.player-wrap h3 {
  color: #aaa;
  margin-bottom: 8px;
  font-size: .9em;
}

.player-wrap video {
  background: #000;
  border-radius: 4px;
  width: 100%;
}

.player-controls {
  display: flex;
  align-items:  center;
  gap: 8px;
  margin-top: 8px;
}

.player-controls button {
  color: #e0e0e0;
  cursor: pointer;
  background: #333;
  border: none;
  border-radius: 4px;
  padding: 4px 12px;
  font-size: .8em;
}

.player-controls button:hover {
  background: #444;
}

.player-info {
  color: #666;
  font-size: .75em;
}

.panel {
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 8px;
  margin-bottom: 12px;
  padding: 16px;
}

.panel h3 {
  color: #aaa;
  margin-bottom: 10px;
  font-size: .9em;
}

.panel input, .panel select {
  color: #e0e0e0;
  background: #111;
  border: 1px solid #333;
  border-radius: 4px;
  width: 100%;
  margin-bottom: 8px;
  padding: 8px;
  font-size: .85em;
}

.panel input:focus {
  outline: none;
  border-color: #da4165;
}

.panel button, .btn {
  color: #fff;
  cursor: pointer;
  background: #da4165;
  border: none;
  border-radius: 4px;
  width: 100%;
  padding: 8px 16px;
  font-size: .85em;
}

.panel button:hover, .btn:hover {
  background: #c73858;
}

.panel button:disabled, .btn:disabled {
  cursor: not-allowed;
  background: #555;
}

.btn-sm {
  border-radius: 3px;
  width: auto;
  padding: 2px 8px;
  font-size: .7em;
}

.btn-green {
  background: #3a5;
}

.btn-green:hover {
  background: #2a9048;
}

.btn-red {
  background: #a33;
}

.btn-red:hover {
  background: #952a2a;
}

.btn-yellow {
  background: #a83;
}

.btn-yellow:hover {
  background: #957728;
}

.btn-blue {
  background: #36a;
}

.btn-blue:hover {
  background: #2a5590;
}

.product-list {
  list-style: none;
}

.product-list li {
  display: flex;
  border-bottom: 1px solid #222;
  justify-content: space-between;
  padding: 6px 0;
  font-size: .85em;
}

.live-dot {
  display: inline-block;
  animation: pulse 2s infinite;
  background: #da4165;
  border-radius: 50%;
  width: 8px;
  height: 8px;
  margin-right: 6px;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }

  50% {
    opacity: .3;
  }
}

.empty {
  color: #555;
  text-align: center;
  padding: 40px;
}

@media (width <= 900px) {
  .app-layout {
    flex-direction: column;
    height: auto;
  }

  .tree-nav {
    border-bottom: 1px solid #222;
    border-right: none;
    width: 100%;
    height: auto;
    max-height: 200px;
  }

  .tree-nav.collapsed {
    width: 100%;
    height: 36px;
  }

  .sidebar {
    border-top: 1px solid #222;
    border-left: none;
    width: 100%;
  }
}
