/* ----- Stream Cards ----- */
.streams-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: scroll;
    overflow-x: hidden;
    min-height: 0;
    padding-right: 0;
    flex: 1;
    min-height: 40vh;
    scrollbar-gutter: stable both-edges;
}

.streams-list.virtualized {
    display: block;
    position: relative;
    overflow-y: auto;
}

.virtual-row {
    padding-bottom: 12px;
}

#streamsView {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    background-color: #6464641c;
    padding: 15px;
    border-radius: 10px;
}

@media (max-width: 900px) {
    body {
        overflow: auto;
        height: auto;
    }

    .main {
        min-height: auto;
    }

    .streams-list {
        overflow: visible;
        min-height: auto;
        max-height: none;
    }
}

.stream-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: visible;
    position: relative;
    content-visibility: auto;
    contain-intrinsic-size: 340px;
}

.stream-header {
    display: flex;
    align-items: flex-start;
    padding: 20px;
    gap: 12px;
}

.stream-select {
    display: flex;
    align-items: center;
    margin-top: 4px;
}

.stream-select input {
    width: 16px;
    height: 16px;
}

.stream-thumbnail {
    width: 120px;
    height: 68px;
    background: var(--bg-secondary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 1px solid var(--border);
    overflow: hidden;
    cursor: pointer;
}

.thumbnail-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    min-width: 120px;
}

.stream-card .thumbnail-wrap {
    display: none;
}

.stream-card.expanded .thumbnail-wrap,
.stream-card.thumb-pinned .thumbnail-wrap {
    display: flex;
}

.stream-card .thumb-updated {
    display: none;
}

.stream-card.expanded .thumb-updated {
    display: block;
}

.stream-thumbnail svg {
    width: 32px;
    height: 32px;
    color: var(--text-muted);
}

.stream-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.thumb-updated {
    margin-top: 3px;
    font-size: 10px;
    color: var(--text-muted);
    text-align: left;
}

.stream-info {
    flex: 1;
    min-width: 0;
}

.stream-title-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 6px;
    flex-wrap: wrap;
}

.stream-name {
    font-size: 16px;
    font-weight: 600;
}

.stream-badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-stopped { background: var(--bg-hover); color: var(--text-secondary); }
.badge-running { background: var(--accent-green-dim); color: var(--accent-green); }
.badge-error { background: var(--accent-red-dim); color: var(--accent-red); }
.badge-restarting { background: var(--accent-orange-dim); color: var(--accent-orange); animation: pulse 1s infinite; }
.badge-critical { background: var(--accent-red); color: white; }
.badge-high { background: var(--accent-orange); color: white; }
.badge-medium { background: var(--accent-blue); color: white; }
.badge-low { background: var(--accent-purple); color: white; }

.stream-description {
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    align-items: baseline;
    justify-content: space-between;
}

.media-summary {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-left: 8px;
    font-size: 12px;
    color: var(--text-muted);
}

.media-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 2px 6px;
}

.stream-card.expanded .media-summary {
    display: none;
}

.stream-error {
    font-size: 12px;
    color: var(--accent-red);
    background: var(--accent-red-dim);
    border: 1px solid var(--accent-red);
    padding: 6px 8px;
    border-radius: 6px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.stream-error button {
    background: transparent;
    border: none;
    color: var(--accent-red);
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
}

.stream-endpoints {
    display: flex;
   /*  gap: 24px; */
    flex-wrap: wrap;
    margin-left: auto;
    justify-content: flex-end;
}

.endpoint {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 10px;
}

.endpoint-label {
    font-weight: 600;
    color: var(--text-secondary);
}

.endpoint-title {
    font-weight: 600;
    color: var(--text-muted);
}

.endpoint-pill {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.2px;
}

.endpoint-pill-in {
    background: var(--accent-green-dim);
    color: var(--accent-green);
}

.endpoint-pill-out {
    background: var(--accent-green-dim);
    color: var(--accent-green);
}

.endpoint code {
    background: var(--bg-secondary);
    padding: 2px 8px;
    border-radius: 4px;
    font-family: 'SF Mono', 'Consolas', monospace;
    font-size: 12px;
}

.stream-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* ----- Dropdown Menu ----- */
.dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    min-width: 180px;
    padding: 8px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.15s;
    z-index: 50;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.dropdown.open .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    color: var(--text-primary);
    font-size: 13px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.1s;
}

.dropdown-item:hover {
    background: var(--bg-hover);
}

.dropdown-item svg {
    width: 16px;
    height: 16px;
    color: var(--text-secondary);
}

.dropdown-item.danger {
    color: var(--accent-red);
}

.dropdown-item.danger svg {
    color: var(--accent-red);
}

.dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 8px 0;
}

/* ----- Stream Stats Toggle ----- */
.stream-stats-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1px;
    border-top: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    gap: 8px;
    border-radius: 0 0 12px 12px;
    transition: background 0.1s;
}

.stream-stats-toggle:hover {
    background: var(--bg-hover);
}

.stream-stats-toggle svg {
    width: 16px;
    height: 16px;
    transition: transform 0.2s;
}

.stream-stats-toggle.open {
    border-radius: 0;
}

.stream-stats-toggle.open svg {
    transform: rotate(180deg);
}

/* ----- Stream Stats Panel ----- */
.stream-stats {
    display: none;
    padding: 20px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    border-radius: 0 0 12px 12px;
}

.stream-stats.open {
    display: block;
}

.stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 16px;
}

.stats-row:last-child {
    margin-bottom: 0;
}

.mini-stat {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.mini-stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-hover);
}

.mini-stat-icon svg {
    width: 20px;
    height: 20px;
    color: var(--text-muted);
}

.mini-stat-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.mini-stat-value {
    font-size: 18px;
    font-weight: 600;
}

.mini-stat-subvalue {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.media-info {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 16px;
    display: grid;
    gap: 10px;
}

.media-info-compact {
    background: var(--bg-secondary);
    border-radius: 10px;
    padding: 10px 12px;
    gap: 8px;
}

.media-col {
    display: flex;
    flex-direction: column;
    gap: 6px;
}


.media-title {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.media-list {
    display: grid;
    gap: 4px;
}

.media-list.compact {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}


.media-item {
    font-size: 13px;
    color: var(--text-primary);
    word-break: break-word;
}

.media-item.compact {
    padding: 2px 6px;
    font-size: 11px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
}



.mini-stat-unit {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 400;
}
